Function usePermission

  • Executes actions using a smart session.

    This function allows for the execution of one or more actions within an enabled smart session. It can handle batch transactions if the session is configured for multiple actions.

    Type Parameters

    • TModularSmartAccount extends undefined | ModularSmartAccount

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

    Parameters

    Returns Promise<Hex>

    A promise that resolves to the hash of the sent user operation.

    Throws

    If no account is provided and the client doesn't have an associated account.

    Example

    const result = await usePermission(nexusClient, {
    calls: [
    {
    to: '0x1234...',
    data: '0xabcdef...'
    }
    ],
    maxFeePerGas: 1000000000n
    });
    console.log(`Transaction hash: ${result}`);

    Remarks

    • Ensure that the session is enabled and has the necessary permissions for the actions being executed.
    • For batch transactions, all actions must be permitted within the same session.
    • The function uses the sendUserOperation method, which is specific to account abstraction implementations.