Type alias SmartAccountActions<TChain, TSmartAccount>

SmartAccountActions<TChain, TSmartAccount>: {
    debugUserOperation: ((params) => Promise<DebugUserOperationReturnType>);
    prepareTokenPaymasterUserOp: ((args) => Promise<Omit<UserOperation, "signature">>);
    prepareUserOperation: ((params) => Promise<ReturnType<typeof prepareUserOperationWithoutSignature>>);
    sendTokenPaymasterUserOp: ((args) => Promise<Hash>);
    sendTransaction: (<TChainOverride, accountOverride, calls>(args) => Promise<Hash>);
    signMessage: ((args) => ReturnType<typeof signMessage>);
    signTypedData: (<const TTypedData, TPrimaryType>(args) => ReturnType<typeof signTypedData>);
    waitForTransactionReceipt: ((params) => Promise<WaitForTransactionReceiptReturnType>);
    writeContract: (<const TAbi, TFunctionName, TArgs, TChainOverride>(args) => ReturnType<typeof writeContract>);
}

Type Parameters

  • TChain extends Chain | undefined = Chain | undefined
  • TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined

Type declaration

  • debugUserOperation: ((params) => Promise<DebugUserOperationReturnType>)

    Sends a user operation to the network and waits for the receipt.

    Returns

    The user operation receipt. DebugUserOperationReturnType

      • (params): Promise<DebugUserOperationReturnType>
      • Parameters

        • params: DebugUserOperationParameters

          DebugUserOperationParameters

        Returns Promise<DebugUserOperationReturnType>

  • prepareTokenPaymasterUserOp: ((args) => Promise<Omit<UserOperation, "signature">>)

    Prepares a user operation with token paymaster configuration, including ERC20 token approval

    This function handles:

    1. Checking current token allowance of Smart Account
    2. Creating an approval transaction for the token paymaster if needed
    3. Preparing the user operation with the approval and user transactions

    Returns

    A prepared user operation without signature (will be signed by the Smart Account when sent)

    Example

    const userOp = await prepareTokenPaymasterUserOp(nexusClient, {
    txs: [
    {
    to: recipientAddress,
    value: 1n,
    data: "0x"
    }
    ],
    feeTokenAddress: baseSepoliaUSDCAddress,
    customApprovalAmount: usdcFeeAmount
    })

    Throws

    Will throw an error if client account or paymaster context is not properly configured

      • (args): Promise<Omit<UserOperation, "signature">>
      • Parameters

        • args: PrepareTokenPaymasterUserOpParameters

        Returns Promise<Omit<UserOperation, "signature">>

  • prepareUserOperation: ((params) => Promise<ReturnType<typeof prepareUserOperationWithoutSignature>>)

    Prepares a user operation

    Returns

    The user operation. PrepareUserOperationReturnType

    Example

    const userOp = await prepareUserOperation({
    calls: [{to: '0x...', value: 1n, data: '0x...'}]
    })
      • (params): Promise<ReturnType<typeof prepareUserOperationWithoutSignature>>
      • Parameters

        • params: PrepareUserOperationParameters

          PrepareUserOperationParameters

        Returns Promise<ReturnType<typeof prepareUserOperationWithoutSignature>>

  • sendTokenPaymasterUserOp: ((args) => Promise<Hash>)

    Prepares and sends a user operation with token paymaster

    Example

    const hash = await sendTokenPaymasterUserOp(client, {
    calls: [{
    to: "0x...", // Contract address
    data: "0x...", // Encoded function data
    value: BigInt(0)
    }],
    feeTokenAddress: "0x...", // USDC/USDT/etc address
    customApprovalAmount: BigInt(1000) // Optional: specific approval amount
    })

    Returns

    A promise that resolves to the user operation hash Hash

      • (args): Promise<Hash>
      • Parameters

        • args: SendTokenPaymasterUserOpParameters

          The parameters for the token paymaster user operation

        Returns Promise<Hash>

  • sendTransaction: (<TChainOverride, accountOverride, calls>(args) => Promise<Hash>)

    Creates, signs, and sends a new transaction to the network using a smart account. This function also allows you to sponsor this transaction if the sender is a smart account.

    Returns

    The transaction hash as a hexadecimal string.

    Throws

    If the account is not found.

    Example

    import { sendTransaction } from '@biconomy/sdk'

    const hash = await nexusClient.sendTransaction({calls: [{to: '0x...', value: parseEther('0.1'), data: '0x...'}]})
    console.log(hash) // '0x...'
      • <TChainOverride, accountOverride, calls>(args): Promise<Hash>
      • Type Parameters

        • TChainOverride extends Chain | undefined = undefined
        • accountOverride extends SmartAccount | undefined = undefined
        • calls extends readonly unknown[] = readonly unknown[]

        Parameters

        • args: Parameters<typeof sendTransaction>[1]

          Parameters for sending the transaction or user operation.

        Returns Promise<Hash>

  • signMessage: ((args) => ReturnType<typeof signMessage>)

    Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)).

    With the calculated signature, you can:

    Returns

    The signed message. SignMessageReturnType

    Example

    import { createWalletClient, custom } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const signature = await client.signMessage({
    account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    message: 'hello world',
    })

    Example

    // Account Hoisting
    import { createWalletClient, http } from 'viem'
    import { privateKeyToAccount } from 'viem/accounts'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    account: privateKeyToAccount('0x…'),
    chain: mainnet,
    transport: http(),
    })
    const signature = await client.signMessage({
    message: 'hello world',
    })
      • (args): ReturnType<typeof signMessage>
      • Parameters

        • args: Parameters<typeof signMessage>[1]

          SignMessageParameters

        Returns ReturnType<typeof signMessage>

  • signTypedData: (<const TTypedData, TPrimaryType>(args) => ReturnType<typeof signTypedData>)

    Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)).

    Returns

    The signed data. SignTypedDataReturnType

    Example

    import { createWalletClient, custom } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const signature = await client.signTypedData({
    account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    },
    types: {
    Person: [
    { name: 'name', type: 'string' },
    { name: 'wallet', type: 'address' },
    ],
    Mail: [
    { name: 'from', type: 'Person' },
    { name: 'to', type: 'Person' },
    { name: 'contents', type: 'string' },
    ],
    },
    primaryType: 'Mail',
    message: {
    from: {
    name: 'Cow',
    wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
    name: 'Bob',
    wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
    },
    })

    Example

    // Account Hoisting
    import { createWalletClient, http } from 'viem'
    import { privateKeyToAccount } from 'viem/accounts'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    account: privateKeyToAccount('0x…'),
    chain: mainnet,
    transport: http(),
    })
    const signature = await client.signTypedData({
    domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    },
    types: {
    Person: [
    { name: 'name', type: 'string' },
    { name: 'wallet', type: 'address' },
    ],
    Mail: [
    { name: 'from', type: 'Person' },
    { name: 'to', type: 'Person' },
    { name: 'contents', type: 'string' },
    ],
    },
    primaryType: 'Mail',
    message: {
    from: {
    name: 'Cow',
    wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
    name: 'Bob',
    wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
    },
    })
      • <const TTypedData, TPrimaryType>(args): ReturnType<typeof signTypedData>
      • Type Parameters

        • const TTypedData extends TypedData | {
              [key: string]: unknown;
          }
        • TPrimaryType extends string

        Parameters

        • args: Parameters<typeof signTypedData>[1]

          SignTypedDataParameters

        Returns ReturnType<typeof signTypedData>

  • waitForTransactionReceipt: ((params) => Promise<WaitForTransactionReceiptReturnType>)
      • (params): Promise<WaitForTransactionReceiptReturnType>
      • Parameters

        • params: WaitForTransactionReceiptParameters

        Returns Promise<WaitForTransactionReceiptReturnType>

  • writeContract: (<const TAbi, TFunctionName, TArgs, TChainOverride>(args) => ReturnType<typeof writeContract>)

    Executes a write function on a contract. This function also allows you to sponsor this transaction if sender is a smartAccount

    A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state.

    Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data.

    Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it.

    Returns

    A Transaction Hash. WriteContractReturnType

    Example

    import { createWalletClient, custom, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const hash = await client.writeContract({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
    functionName: 'mint',
    args: [69420],
    })

    Example

    // With Validation
    import { createWalletClient, custom, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const { request } = await client.simulateContract({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
    functionName: 'mint',
    args: [69420],
    }
    const hash = await client.writeContract(request)