What You’ll Accomplish
By the end of this guide, you’ll have:- ✅ Installed the avnu SDK
- ✅ Fetched the best swap quote
- ✅ Executed a token swap on Starknet
Prerequisites
Node.js 22+ installed
Node.js 22+ installed
Download from nodejs.org
Step 1: Install the SDK
Step 2: Initialize Your Account
Everyexecute* method takes a starknet.js account. In a script or backend, build it from a private key:
@starknet-start/react, …) exposes the wallet-standard object and the connected address — note that hook-based libraries no longer return a ready-made account object, only these two:
WalletAccountV6.connect / connectSilent are thin wrappers that fetch the address from the wallet and call it (use connectSilent when you don’t already have the address — no prompt if the dapp is authorized). It subscribes to wallet events, so call account.unsubscribeChange() when you drop or replace the instance.
Step 3: Fetch Swap Quotes
Optional Parameters:
size: Number of quotes to return (default: 1)excludeSources: Array of source names to excludeintegratorFees: Your integration fees in bpsintegratorFeeRecipient: Address to receive feesintegratorName: Your platform nameonlyDirect: if you want only direct routes
Step 4: Execute the Swap
Default Behavior:
executeApprove: true- Automatically approves token spending if neededslippage- Required parameter for price protection- Reverts if price moves beyond slippage tolerance
Complete Example
Next Steps
Paymaster
Sponsor gas or multi-token gas payments
API Reference
Complete REST API docs
DCA Orders
Add automated recurring buys
Resources
API Reference
REST API documentation
SDK
TypeScript/JavaScript SDK
Support
Telegram community