sendTokenPaymasterUserOp
This method combines the preparation and sending of a user operation that uses token paymaster for gas payment. It handles the entire flow of:
- Preparing the user operation with token paymaster configuration
- Adding token approval if needed
- Signing and sending the operation
Usage
example.ts
import { createSmartAccountClient } from "./nexusClient"
const hash = await nexusClient.sendTokenPaymasterUserOp({
calls: [
{
to: recipientAddress,
value: 1n,
data: "0x"
}
],
feeTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC address
})Parameters
calls{ to: Address, data: Hex, value: bigint }[]: Array of transactions to be executedfeeTokenAddressAddress: The ERC20 token address to be used for paying gas feescustomApprovalAmountbigint(optional): Custom approval amount for the token paymastermaxFeePerGasbigint(optional): Maximum fee per gas unitmaxPriorityFeePerGasbigint(optional): Maximum priority fee per gas unit
Response
Promise<Hash>: Returns the transaction hash of the submitted user operation
Error Handling
The method will throw an error if:
- The client account is not properly configured
- The paymaster context is missing or invalid
- Token approval fails
- User operation submission fails
Related Methods
- prepareTokenPaymasterUserOp - If you need more control over the preparation step
- sendTransaction - For sending transactions without token paymaster