Replies: 3 comments 2 replies
-
|
I also have a use case for this. A permission could be granted to add inputs just to an specific Cartesi application by limiting the scope of the InputBox.addInput call for a particular Just for comparison, ZeroDev Kernel CallPolicy supports this with the following structure. source code // An array of conditions, each corresponding to an argument for
// the function.
args: [
{
condition: ParamCondition.EQUAL,
value: value,
},
],
|
Beta Was this translation helpful? Give feedback.
-
|
For your cases, is the app permitting itself to sign? or is the app permitting a key that belongs to a third-party (that will sign)? Alternative could be to add a |
Beta Was this translation helpful? Give feedback.
-
|
If we were to go down comparison operator approach, I would envision an API for this similar to how we describe arguments when invoking contract calls in Viem, however, instead represent the respective values as a tuple of Operators
Definitiontype CallPermissions = {
signature?: string | undefined,
to?: string | undefined,
args?: [operator: "=", "!=", "<", "<=", ">", ">=", value: unknown][]
}[]Usage// Case 1: Valid args
wallet_grantPermissions({
permissions: {
calls: [{
signature: 'approve(address, uint256)',
args: [null, ['<', 1_000n]]
}]
}
})
// Case 2: Invalid value type
wallet_grantPermissions({
permissions: {
calls: [{
signature: 'approve(address, uint256)',
args: [null, ['<', 'foobar']]
// ^? Type 'string' is not assignable to type 'bigint'.
}]
}
})
// Case 3: Invalid operator type
wallet_grantPermissions({
permissions: {
calls: [{
signature: 'approve(address, uint256)',
args: [['<', '0x...']
// ^? Type '"<"' does not satisfy the expected type '"=" | "!="'
}]
}
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🧩 Current Design
The wallet_grantPermissions function currently supports the following structure for defining authorized smart contract calls:
This allows scoping based on function signature and target contract, but does not allow for controlling function arguments.
🚫 Problem
This structure permits calls to a function like approve(address,uint256) for any address and any amount — which is too permissive for many use cases.
In scenarios like automated trading or delegated execution, finer-grained control is needed. For example:
Approving only a specific address as spender.
Capping the maximum token amount approved.
✅ Proposed Enhancement
Extend the calls structure with an optional args field to add argument-level conditions:
🎯 Example Use Case
Let’s say a user wants to allow a bot to perform trades on their behalf using the Li.Fi aggregator.
The user grants permission to call approve(address,uint256) on ERC-20 tokens, but only:
If spender == LiFiAggregatorAddress
And amount <= MAX_APPROVAL_LIMIT
The bot then:
Gets ERC-20 approval with a safe cap
Executes the trade through LiFi
🛡️ Benefits
Enables fine-grained, secure delegation.
Reduces trust surface for delegated key holders.
Prevents misuse of generic approve() calls.
Facilitates safer bot-driven DeFi automation.
The above is just an implementation idea to illustrate the point.
Beta Was this translation helpful? Give feedback.
All reactions