prepareTokenPaymasterUserOp
This method prepares a user operation with token paymaster configuration, including ERC20 token approval. It handles:
- Checking current token allowance of Smart Account
- Creating an approval transaction for the token paymaster if needed
- Preparing the user operation with the approval and user transactions
Usage
example.ts
import { nexusClient } from "./nexusClient"
const userOp = await nexusClient.prepareTokenPaymasterUserOp({
calls: [
{
to: recipientAddress,
value: 1n,
data: "0x"
}
],
feeTokenAddress: "0x...", // ERC20 token address
customApprovalAmount: usdcFeeAmount // optional
})Parameters
calls{ to: Address, data: Hex, value: bigint }[]: Array of transactions to be executedfeeTokenAddressAddress: Token address used for paying for the gascustomApprovalAmountbigint(optional): Custom approval amount for the token paymaster. If not provided, max uint256 will be used
Response
Promise<Omit<UserOperation<"0.7">, "signature">>: Returns a prepared user operation without signature (will be signed by the Smart Account when sent)
Error Handling
The method will throw an error if:
- Client account is not properly configured
- Paymaster context is not properly configured