Requirements
Before you begin, ensure you have the following:- A frontend framework with wallet connection (React, Next.js, etc.)
- wagmi and viem for wallet interactions
- User wallet connected to Monad mainnet (chain ID
143)
1. Configure Authentication
We first need to get credentials to access the Kuru Flow API. Kuru Flow uses JWT tokens for API authentication.lib/kuru-flow.ts
2. Get a Swap Quote
The/api/quote endpoint calculates the best swap path and returns transaction data.
The following parameters are supported:
*Either
autoSlippage: true OR slippageTolerance must be provided.
We can write a small function to interact with the quote API:
lib/kuru-flow.ts
Response Structure
lib/kuru-flow.ts
The
calldata field does NOT include the 0x prefix. You must add it before sending the transaction.3. Check Token Allowance (ERC20 Only)
Before executing a swap with ERC20 tokens, we should verify that the router has permission to spend the user’s tokens.components/SwapCard.tsx
4. Approve Token Spending (ERC20 Only)
If allowance is insufficient for an ERC20 token, we should request approval before swapping.components/SwapCard.tsx
5. Execute the Swap
To submit the swap, we should use the transaction data from the quote response:components/SwapCard.tsx
Token Addresses and Decimals (Mainnet)
Referral Fee System
Kuru features a referral system. As the referrer, we can earn fees on every swap by including your referrer details in quote requests.lib/kuru-flow.ts
Error Handling
Along the way, we might run into errors. Here is how to interpret them:Common Mistakes
- Missing 0x prefix - Add
0xprefix to calldata before sending - Invalid referrer address - Must be a valid Ethereum address
- Skipping approval for ERC20 - ERC20 tokens require approval before swap (native MON does not)
- Wrong decimals - USDC has 6 decimals, MON has 18
- Zero value for native MON swaps - When swapping native MON, the transaction
valuemust be set to the swap amount
Next Steps
- Try the Live Demo to see Kuru Flow in action
- Clone the Example Repository for a complete working implementation
- Read the Kuru Flow Overview for more details
- See Monad Network Information for RPC endpoints and chain configuration

