wallet_grantPermissions
Grant granular permissions to a spender address for delegated transaction execution with spending limits and call restrictions.
Authentication Required: No
Request
import { parseEther } from 'viem';
await jaw.provider.request({
method: 'wallet_grantPermissions',
params: [
{
expiry: 1735689600, // Unix timestamp
spender: '0x5678...', // Who gets permissions
permissions: {
calls: [
{
target: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
functionSignature: 'transfer(address,uint256)',
},
],
spends: [
{
token: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
allowance: parseEther('0.1').toString(), // 0.1 ETH
unit: 'day',
},
],
},
note: 'Pays your 0.1 ETH daily subscription', // Optional - shown to the user, not signed
// chainId: '0x1', // Optional - defaults to connected chain
},
],
});Parameters
| Name | Type | Required | Description |
|---|---|---|---|
expiry | number | Yes | Expiration timestamp (seconds) |
spender | 0x${string} | Yes | Address receiving permissions |
permissions | object | Yes | Permission details |
address | 0x${string} | No | Account address to grant permissions on |
chainId | 0x${string} | No | Target chain ID (defaults to connected chain) |
note | string | No | What the permission is for (see below) |
capabilities | object | No | Additional capabilities (see below) |
Note
note says what the permission is for, in your app's words, so the user and an agent can tell later why it exists. The grant and revoke screens show it, and wallet_getPermissions returns it.
- Plain text on one line, at most 200 characters. Spaces around it are trimmed, and an empty note counts as none.
- A note with a newline, a tab, a control character, or a character that doesn't show on screen (zero-width, bidi, variation and other default-ignorable characters) is refused with
-32602. A single emoji selector is fine, so notes with emoji work. - It is not signed and not part of the permission hash. It is stored next to the permission, set once when it is granted, and never changed.
Capabilities
| Name | Type | Description |
|---|---|---|
capabilities.paymasterService | object | Paymaster service for gas sponsorship |
capabilities.paymasterService.url | string | Paymaster service URL (ERC-7677 compliant) |
capabilities.paymasterService.context | object | Optional context (e.g., { sponsorshipPolicyId: '...' }) |
Permission Details
calls
Array of call permissions. Each permission:
| Name | Type | Required | Description |
|---|---|---|---|
target | 0x${string} | Yes | Contract address |
functionSignature | string | No* | Function signature (e.g., "transfer(address,uint256)") |
selector | 0x${string} | No* | 4-byte function selector (0x...) |
checker | 0x${string} | No | Contract that must approve each matching call |
*Either functionSignature or selector is required.
A checker is a contract the permission manager calls with canExecute before every call this rule matches, so it can check the call's arguments as well as the function. It is part of the permission hash and is shown on the grant screen. Leave it out for no checker. The response always includes it, as the zero address when none was set, so the permission can be rebuilt from the response alone.
spends (Optional*)
Array of spend limits. Each limit:
| Name | Type | Required | Description |
|---|---|---|---|
token | 0x${string} | Yes | Token address (0xEeee... for native token) |
allowance | string | Yes | Spending allowance in wei (decimal or hex string) |
unit | string | Yes | Time unit for allowance reset |
multiplier | number | No | Multiplier for the time unit (default: 1) |
Valid Units:
minute- Resets every minutehour- Resets every hourday- Resets every dayweek- Resets every weekmonth- Resets every monthyear- Resets every yearforever- Never resets (one-time allowance)
*Spend Limits are required if moving funds.
Response
Returns permission grant result with generated permission ID.
{
"account": "0x1234567890123456789012345678901234567890",
"spender": "0x5678901234567890123456789012345678901234",
"start": 1704067200,
"end": 1735689600,
"salt": "0x1a2b3c...",
"calls": [
{
"target": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"selector": "0xa9059cbb",
"checker": "0x0000000000000000000000000000000000000000"
}
],
"spends": [
{
"token": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"allowance": "0x16345785d8a0000",
"unit": "day",
"multiplier": 1
}
],
"permissionId": "0xabc123...",
"chainId": "0x1",
"note": "Pays your 0.1 ETH daily subscription"
}note is the note as stored, and is left out when the request had none.
Behavior
- Opens popup for user approval
- Approves permission
- Returns permission ID for future revocation
Errors
| Code | Description |
|---|---|
| 4001 | User rejected the request |
| 4100 | Unauthorized (not authenticated) |
| -32602 | Invalid params |
Example
import { parseUnits } from 'viem';
// Allow DeFi protocol to swap USDC with daily limit
const permission = await jaw.provider.request({
method: 'wallet_grantPermissions',
params: [
{
expiry: Math.floor(Date.now() / 1000) + 365 * 24 * 60 * 60, // 1 year
spender: dexRouterAddress,
permissions: {
calls: [
{
target: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
functionSignature: 'approve(address,uint256)',
},
{
target: dexRouterAddress,
functionSignature: 'swap(address,address,uint256,uint256)',
},
],
spends: [
{
token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
allowance: parseUnits('1000', 6).toString(), // 1000 USDC per day
unit: 'day',
},
],
},
// chainId: '0x1', // Optional - defaults to connected chain
},
],
});Related Methods
- wallet_revokePermissions - Revoke permissions
- wallet_getPermissions - Query permissions