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

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

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.

Last updated