nansen-trade

Original🇺🇸 English
Translated

Execute DEX swaps on Solana, Ethereum, Base, or BSC. Use when buying or selling a token, getting a swap quote, or executing a trade.

8installs
Added on

NPX Install

npx skill4agent add nansen-ai/nansen-cli nansen-trade

Tags

Translated version includes tags in frontmatter

Trade

Two-step flow: quote then execute. Trades are irreversible once on-chain.
Prerequisite: You need a wallet first. Run
nansen wallet create
before trading.

Quote

bash
nansen trade quote \
  --chain solana \
  --from SOL \
  --to USDC \
  --amount 1000000000
Symbols resolve automatically:
SOL
,
ETH
,
BNB
,
USDC
,
USDT
,
WETH
,
WBNB
. Raw addresses also work.

Execute

bash
nansen trade execute --quote <quote-id>

Agent pattern

bash
# Pipe quote ID directly into execute
QUOTE_ID=$(nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000 2>&1 | grep "Quote ID:" | awk '{print $NF}')
nansen trade execute --quote "$QUOTE_ID"

Common Token Addresses

TokenChainAddress
SOLSolana
So11111111111111111111111111111111111111112
USDCSolana
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
ETHBase
0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
USDCBase
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Amounts are in base units

TokenDecimals1 token =
SOL9
1000000000
ETH18
1000000000000000000
USDC6
1000000

Flags

FlagPurpose
--chain
solana
,
ethereum
,
base
, or
bsc
--from
Source token (symbol or address)
--to
Destination token (symbol or address)
--amount
Amount in base units (integer)
--wallet
Wallet name (default: default wallet)
--slippage
Slippage tolerance as decimal (e.g. 0.03)
--quote
Quote ID for execute
--no-simulate
Skip pre-broadcast simulation

Notes

  • Quotes expire after ~1 hour. If execute fails, get a fresh quote.
  • A wallet is required even for quotes (the API builds sender-specific transactions).
  • ERC-20 swaps may require an approval step — execute handles this automatically.