# grantPermissions

Grants specific permissions to a session key or account, allowing controlled execution of actions such as contract calls. Permissions are time-limited and require an expiration timestamp.

### contract-call

```typescript
const COUNTER_CONTRACT_ADDRESS = "0x4FbF9EE4B2AF774D4617eAb027ac2901a41a7b5F";

const grantParams = {
  chainId,
  signer: {
    type: "account",
    data: { address: sessionOwner.address },
  },
  permissions: [
    {
      type: "contract-call",
      data: {
        contractAddress: COUNTER_CONTRACT_ADDRESS,
        functionSelector: "function count()",
      },
      policies: [],
    },
  ],
  expiry: Math.floor(Date.now() / 1000) + 3600, // Expires in 1 hour
};

const response = await smartAccountClient.grantPermissions(grantParams);
```

### sudo

```typescript
const grantParams = {
  chainId,
  signer: {
    type: "account",
    data: { address: sessionOwner.address },
  },
  permissions: [
    {
      type: "sudo",
      policies: [],
    },
  ],
  expiry: Math.floor(Date.now() / 1000) + 3600, // Expires in 1 hour
};

const response = await smartAccountClient.grantPermissions(grantParams);
```

## Returns

A JSON object containing the granted permissions, their expiry, and the associated **UserOperation hash** for tracking.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cometh.io/advanced/capabilities/grantpermissions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
