rift_swap
Swaps one token for another on a single chain through a smart wallet, offering gasless or paid-gas execution; use bridging for cross-chain transfers.
Instructions
Swap one token for another on a single chain via the user's smart wallet. SAME-CHAIN ONLY — for cross-chain use rift_bridge_execute. REAL TX — confirm with user.
DEPRECATED upstream: the backend swap endpoint may be unavailable; if it fails, tell the user to swap in the Rift app. When it works it returns an APPROVAL REQUIRED link for the user (passkey); check with rift_get_approval, never call again to retry.
Use 'flow: gasless' (recommended) for sponsored gas via UserOperation; use 'normal' to pay gas yourself. For known tokens (USDC, USDT, WETH, etc.) the chain's defaults are used; pass token_to_sell_address / token_to_buy_address only for arbitrary ERC-20s. For native ETH legs set isEth (selling ETH) or isBuyingEth (buying ETH).
'value' is the amount of token_to_sell, in human units (e.g. '10' for 10 USDC). To target a specific output, pass amountOut instead.
Requires login.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"chain": "<chain>",
"token_to_sell": "<token_to_sell>",
"token_to_buy": "<token_to_buy>",
"value": "<value>"
},
"name": "rift_swap"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flow | No | gasless = no gas fee for user (recommended). normal = user pays gas in native token. | gasless |
| chain | Yes | Chain to swap on: BASE, POLYGON, ARBITRUM, ETHEREUM, OPTIMISM, etc | |
| isEth | No | True if selling native ETH (not WETH) | |
| value | Yes | Amount of token_to_sell in human units (e.g. '10' for 10 USDC) | |
| amountOut | No | Optional: target output amount (exact-out swap). Don't combine with normal value-based usage unless you know the upstream supports it. | |
| isBuyingEth | No | True if buying native ETH (not WETH) | |
| token_to_buy | Yes | Token symbol you're buying: WETH, USDC, etc. | |
| token_to_sell | Yes | Token symbol you're selling: USDC, USDT, WETH, etc. | |
| token_to_buy_address | No | ERC-20 contract address — only needed for arbitrary tokens not in the SDK's known list | |
| token_to_sell_address | No | ERC-20 contract address — only needed for arbitrary tokens not in the SDK's known list |