ZeroEx Swap

# ZeroEx Swap Skill

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "ZeroEx Swap" with this command: npx skills add aviclaw/zeroex-swap

ZeroEx Swap Skill

⚠️ SECURITY WARNING: This skill involves real funds. Review all parameters before executing swaps.

Install

cd skills/zeroex-swap
npm install

Required Environment Variables

VariableDescriptionRequired
ZEROEX_API_KEYGet from https://dashboard.0x.org/Yes
PRIVATE_KEYWallet private key (hex, without 0x prefix)Yes
RPC_URLRPC endpoint for chain (optional, defaults provided)No

Declared required env vars: ZEROEX_API_KEY, PRIVATE_KEY

export ZEROEX_API_KEY="your-0x-api-key"
export PRIVATE_KEY="your-private-key-hex"
export RPC_URL="https://mainnet.base.org"  # optional

Usage

Get Price Quote

node quote.js --sell USDC --buy WETH --amount 1 --chain base

Execute Swap (sell → buy)

node swap.js --sell USDC --buy WETH --amount 1 --chain base

Execute Swap (buy example)

node swap.js --sell WETH --buy USDC --amount 0.01 --chain base

Trade History

getSwapTrades

curl -s "https://api.0x.org/trade-analytics/swap?chainId=8453&taker=0xYOUR_WALLET" \
  -H "0x-api-key: $ZEROEX_API_KEY" \
  -H "0x-version: v2"

getGaslessTrades

curl -s "https://api.0x.org/trade-analytics/gasless?chainId=8453&taker=0xYOUR_WALLET" \
  -H "0x-api-key: $ZEROEX_API_KEY" \
  -H "0x-version: v2"

Gasless Swap (Meta-transaction)

Flow:

  1. Get gasless quote
  2. Sign EIP-712 payload
  3. Submit meta-tx

1) Get gasless quote

curl -s "https://api.0x.org/gasless/quote?sellToken=USDC&buyToken=WETH&sellAmount=1000000&chainId=8453&taker=0xYOUR_WALLET" \
  -H "0x-api-key: $ZEROEX_API_KEY" \
  -H "0x-version: v2"

2) Sign EIP-712 (use viem)

// use viem to sign quote.trade.eip712
await client.signTypedData({
  domain: quote.trade.eip712.domain,
  types: quote.trade.eip712.types,
  message: quote.trade.eip712.message,
  primaryType: quote.trade.eip712.primaryType
});

3) Submit

curl -s -X POST "https://api.0x.org/gasless/submit" \
  -H "0x-api-key: $ZEROEX_API_KEY" \
  -H "0x-version: v2" \
  -H "Content-Type: application/json" \
  -d '{"trade": {"type":"settler_metatransaction","eip712": {"domain": {"name": "Settler", "chainId": 8453, "verifyingContract": "0x..."},"types": {...},"message": {...},"primaryType":"..."},"signature": {"v": 27, "r": "0x...", "s": "0x...", "signatureType": 2}}}'

Security Best Practices

  • Use a dedicated hot wallet
  • Set slippage protection
  • Approve exact amounts only
  • Use your own RPC via RPC_URL

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

Chainstream Defi

[FINANCIAL EXECUTION] Execute irreversible on-chain DeFi operations via CLI and MCP tools. Use when user wants to swap tokens, create tokens on launchpad, si...

Registry SourceRecently Updated
4590Profile unavailable
Web3

KYC.RIP Swap API

Exchange cryptocurrencies via kyc.rip aggregator API. Use when swapping, converting, or exchanging crypto assets. Supports 700+ coins, no KYC, best rates acr...

Registry SourceRecently Updated
2140Profile unavailable
Web3

Monolith — Crypto Wallet

Secure crypto wallet for AI agents. Hardware-isolated keys (Apple Secure Enclave), ERC-4337 smart wallet, on-chain spending caps, default-deny policy engine.

Registry SourceRecently Updated
7854Profile unavailable
Web3

vultisig-sdk

Use this skill when an agent needs to create crypto wallets, send transactions, swap tokens, check balances, or perform any on-chain operation across 36+ blockchains using threshold signatures (TSS). Vultisig SDK provides self-custodial MPC vaults — no seed phrases, no single point of failure. Fast Vaults (2-of-2 with VultiServer) enable fully autonomous agent operations without human approval.

Registry SourceRecently Updated
1.6K2Profile unavailable