# grantPermissions

> Overview of the grantPermissions function

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

```ts
function grantPermissions(client, params): Promise<GrantPermissionsResult>;
```

Defined in: [packages/wallet-apis/src/actions/grantPermissions.ts:82](https://github.com/alchemyplatform/aa-sdk/blob/v5.x.x/packages/wallet-apis/src/actions/grantPermissions.ts#L82)

Grants permissions to a smart account by creating a session.
This allows another key to perform operations on behalf of the account.

## Example

```ts
// Create a session key and grant root permissions
const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
const account = await client.requestAccount();

const permissions = await client.grantPermissions({
  account: account.address,
  expirySec: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
  key: {
    publicKey: await sessionKey.getAddress(),
    type: "secp256k1",
  },
  permissions: [{ type: "root" }],
});

// Use the permissions to prepare a call
const preparedCalls = await client.prepareCalls({
  calls: [{ to: zeroAddress, value: 0n }],
  from: account.address,
  capabilities: {
    paymaster: {
      policyId: "your-paymaster-policy-id",
    },
    permissions,
  },
});

// Sign with the session key
const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);

// Send the prepared call using the session key
const result = await client.sendPreparedCalls({
  ...signedCalls,
  capabilities: {
    permissions,
  },
});
```

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `client`
      </td>

      <td>
        `InnerWalletApiClient`
      </td>

      <td>
        The wallet API client to use for the request
      </td>
    </tr>

    <tr>
      <td>
        `params`
      </td>

      <td>
        [`GrantPermissionsParams`](../type-aliases/GrantPermissionsParams)
      </td>

      <td>
        The parameters for granting permissions
      </td>
    </tr>

  </tbody>
</table>

## Returns

`Promise`\<[`GrantPermissionsResult`](../type-aliases/GrantPermissionsResult)>

A Promise that resolves to the result containing a context identifier