Smart Transfer Action
This tool allows the agent to transfer native assets (like ETH or MATIC) or ERC-20 tokens (like USDC) to an address.
Under the hood, this action constructs an ERC-4337 UserOperation. The transaction is submitted to the 0xGasless Bundler and paid for by the Paymaster.
LLM Usage
Section titled “LLM Usage”When the user asks the agent to send tokens, the LLM will generate a call matching this schema.
Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
to | string | The recipient’s EVM address, or a supported ENS/BNS name. |
amount | string | The amount to send, in human-readable units (e.g., "1.5"). |
tokenAddress | string | Optional. The contract address of the ERC-20 token to send. If omitted, the native chain token is transferred. |
How it works
Section titled “How it works”- Resolution: If
tois a name likevitalik.eth, the action queries an RPC to resolve the address. - Decimals: Native transfers always assume 18 decimals. If
tokenAddressis provided, the action executes an on-chaindecimals()call to determine how to convert the human-readable string intowei. - Execution:
- Native: Encodes a transaction to the recipient with
value: amountInWeiand empty data. - ERC-20: Encodes a transaction to
tokenAddresswithvalue: 0and data:transfer(to, amountInWei).
- Native: Encodes a transaction to the recipient with
Direct Invocation
Section titled “Direct Invocation”If you don’t want to use an LLM, you can directly invoke the action from code using the AgentKit framework:
import { AgentKit, SmartTransferAction } from "@0xgasless/agent-sdk";
const agentKit = new AgentKit({ apiKey: "YOUR_API_KEY" });
const action = new SmartTransferAction();
const result = await action.invoke(agentKit, { to: "0xRecipientAddress", amount: "10.5", tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC});
console.log(result);// "Successfully transferred 10.5 USDC to 0xRecipientAddress. Transaction hash: 0x..."Supported Prompt Patterns
Section titled “Supported Prompt Patterns”The Prompt passed to the LLM handles edge cases explicitly. It tells the agent:
- “If the user asks to send ‘USDC’, you must look up the USDC token address and pass it in
tokenAddress. Do not send the string ‘USDC’.” - “Do not provide the amount scaled by decimals. Always provide the raw number.”
Limitations
Section titled “Limitations”- The agent cannot transfer tokens it does not have. Ensure the smart account is funded before asking the agent to act.
- The action waits for the
UserOperationto be mined into a block before returning a success string. This can take several seconds depending on network congestion.