> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# 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',
      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
        }[],
      },
      /** Policies. Pass an empty array for none. */
      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[],
  }[],
  /** ID of the session registered for the signer. */
  permissionsContext: `0x${string}`,
  /** Signer data. */
  signerData?: {
    userOpBuilder?: `0x${string}`,
    submitToAddress?: `0x${string}`,
  },
}
```

## Example

:::warning
To make these instructions concrete, we have created a sample cross-app 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.

:::info
Granting permissions registers `signer` as a session key on the user's account. It does not change how the wallet signs: [`wallet_sendCalls`](https://www.openfort.io/docs/products/cross-app-wallet/rpc/wallet_sendCalls) and [`eth_sendTransaction`](https://www.openfort.io/docs/products/cross-app-wallet/rpc/eth_sendTransaction) are still signed by the user's wallet signer. To act with the permission, the Application creates the transaction through the Openfort API and signs its hash with the session key's private key. See [Use session keys](https://www.openfort.io/docs/products/embedded-wallet/javascript/smart-wallet/advanced/session-keys).
:::

```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: [],
      },
    ],
  }],
})
```
