wallet_grantPermissions
Grants permissions for an Application to perform actions on behalf of the account. Based on ERC-7715.
Request
type Request = {
method: 'wallet_grantPermissions',
params: [{
/**
* Address of the account to grant permissions on.
* Defaults to the current account.
*/
address?: `0x${string}`
/** Chain ID to grant permissions on. */
chainId?: `0x${string}`
/** Expiry of the permissions. */
expiry: number
/** Key to grant permissions to. Defaults to a wallet-managed key. */
key?: {
/**
* Public key.
* Accepts an address for `address` & `secp256k1` types.
*/
publicKey?: `0x${string}`,
/** Key type. */
type?: 'address' | 'p256' | 'secp256k1' | 'webauthn-p256',
}
/** Permissions to grant. */
permissions: {
/** Call permissions. */
calls: {
/** Function signature or 4-byte signature. */
signature?: string
/** Authorized target address. */
to?: `0x${string}`
}[],
},
}]
}
Response
type Response = {
address: `0x${string}`,
chainId: `0x${string}`,
expiry: number,
id: `0x${string}`,
key: {
publicKey: `0x${string}`,
type: 'address' | 'p256' | 'secp256k1' | 'webauthn-p256',
},
permissions: {
calls: {
signature?: string,
to?: `0x${string}`,
}[],
},
}
Example
The example below demonstrates granting permissions for an Application to perform transfer
calls on the EXP ERC20 contract,
with a spending limit of up to 50 EXP
per day.
import RapidfireID from '@rapidfire/id'
import { parseEther, toHex } from 'viem'
const rapidfire = new RapidfireID()
const provider = rapidfire.getEthereumProvider()
const token = '0x706aa5c8e5cc2c67da21ee220718f6f6b154e75c'
const permissions = await provider.request({
method: 'wallet_grantPermissions',
params: [{
expiry: Math.floor(Date.now() / 1000) + 7 * 24 * 60 * 60, // 1 week
permissions: {
calls: [{
signature: 'transfer(address,uint256)',
to: token
}],
},
}],
})