Quickstart: swap in five minutes
The fastest integration is the REST quote endpoint: it does pool discovery, split simulation and calldata encoding for you, and returns a transaction you send as-is. ERC-20 inputs need a one-time approval of SwapRouter02; native ETH needs none.
Get a quote
bash
# 1) Get a quote + ready-to-send calldata curl "https://splitshot-dex-be.onrender.com/v1/quote?tokenIn=0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73&tokenOut=0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168&amountIn=1000000000000000&recipient=YOUR_ADDRESS&slippageBps=auto"
The response carries amountIn, amountOut, the split legs, autoSlippageBps (when slippageBps=auto) and a tx object with to and data.
Send the transaction
typescript
// 2) Send it (viem). The response's tx.to / tx.data are complete.
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
const chain = {
id: 4663, name: 'Robinhood Chain',
nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 },
rpcUrls: { default: { http: ['https://rpc.mainnet.chain.robinhood.com'] } },
}
const wallet = createWalletClient({ account: privateKeyToAccount(PK), chain, transport: http(chain.rpcUrls.default.http[0]) })
const q = await (await fetch(quoteUrl)).json()
const hash = await wallet.sendTransaction({ to: q.tx.to, data: q.tx.data, value: 0n })
// swapping native ETH in? value: BigInt(q.amountIn) — see Swap API