# wallet\_grantPermissions

Grants permissions for an Application to perform actions on behalf of the account. Based on [ERC-7715](https://github.com/ethereum/ERCs/blob/23fa3603c6181849f61d219f75e8a16d6624ac60/ERCS/erc-7715.md).

## Request

```ts
type Request = {
  method: 'wallet_grantPermissions',
  params: [{
    /** Expiry as a duration in seconds from now. */
    expiry: number

    /** Signer to grant permissions to. */
    signer?: {
      type: 'key' | 'account' | 'keys' | 'wallet',
      data: {
        id: `0x${string}`
      }
    }

    /** Permissions to grant. */
    permissions: {
      /** Permission type. */
      type: 'contract-call' | 'erc20-token-transfer' | 'erc721-token-transfer' | 'erc1155-token-transfer' | 'native-token-transfer',
      /** Permission data (varies by type). */
      data: {
        /** Contract address. */
        address?: `0x${string}`,
        /** Allowed function calls. */
        calls?: {
          /** Function signature or 4-byte signature. */
          signature?: string
        }[],
      },
      /** Optional policies. */
      policies?: any[],
    }[],
  }]
}
```

## Response

```ts
type Response = {
  expiry: number,
  /** Factory address for the account. */
  factory?: `0x${string}`,
  /** Factory data. */
  factoryData?: `0x${string}`,
  /** Granted permissions. */
  grantedPermissions: {
    type: string,
    data: Record<string, any>,
    policies?: any[],
  }[],
  /** Context to pass to wallet_sendCalls or wallet_revokePermissions. */
  permissionsContext: `0x${string}`,
  /** Signer data. */
  signerData?: {
    userOpBuilder?: `0x${string}`,
    submitToAddress?: `0x${string}`,
  },
}
```

## Example

:::warning
To make these instructions concrete, we have created a sample global wallet called **Rapidfire ID**. To interact with it, you can find its SDK in the NPM package directory: [@rapidfire/id](https://www.npmjs.com/package/@rapidfire/id).

You can check out the GitHub [repository for Rapidfire Wallet](https://github.com/openfort-xyz/ecosystem-sample) to learn how to create your own wallet.
:::

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.

:::info
Once permissions have been granted, they will be automatically applied to any calls made by the Application
via [`wallet_sendCalls`](/docs/products/cross-app-wallet/rpc/wallet_sendCalls) or [`eth_sendTransaction`](/docs/products/cross-app-wallet/rpc/eth_sendTransaction).
:::

```ts
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: 7 * 24 * 60 * 60, // 1 week (duration in seconds)
    signer: {
      type: 'key',
      data: { id: '0x...' }, // Public key or address of the signer
    },
    permissions: [
      {
        type: 'contract-call',
        data: {
          address: token,
          calls: [{ signature: 'transfer(address,uint256)' }],
        },
        policies: [],
      },
    ],
  }],
})
```
