Function grantPermission

  • Adds multiple sessions to the SmartSessionValidator module of a given smart account.

    This function prepares and sends a user operation to create multiple sessions for the specified modular smart account. Each session can have its own policies and permissions.

    Type Parameters

    • TModularSmartAccount extends undefined | ModularSmartAccount

      Type of the modular smart account, extending ModularSmartAccount or undefined.

    Parameters

    Returns Promise<GrantPermissionResponse>

    A promise that resolves to an object containing the user operation hash and an array of permission IDs.

    Throws

    If the account is not found.

    Throws

    If there's an error getting the enable sessions action.

    Example

    import { grantPermission } from '@biconomy/sdk'

    const result = await grantPermission(nexusClient, {
    sessionRequestedInfo: [
    {
    sessionKeyData: '0x...',
    actionPoliciesInfo: [
    {
    contractAddress: '0x...',
    functionSelector: '0x...',
    rules: [...],
    valueLimit: 1000000000000000000n
    }
    ],
    sessionValidUntil: 1234567890
    }
    ]
    });
    console.log(result.userOpHash); // '0x...'
    console.log(result.permissionIds); // ['0x...', '0x...']

    Remarks

    • Ensure that the client has sufficient gas to cover the transaction.
    • The number of sessions created is determined by the length of the sessionRequestedInfo array.
    • Each session's policies and permissions are determined by the actionPoliciesInfo provided.