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:
| Parameter | Required | Description |
|---|---|---|
userAddress | Yes | User’s wallet address |
tokenIn | Yes | Token address (0x0 for native MON) |
tokenOut | Yes | Token address (0x0 for native MON) |
amount | Yes | Amount in smallest token units |
autoSlippage | No* | Set to true for automatic slippage calculation |
slippageTolerance | No* | Manual slippage in basis points (1-10000) |
referrerAddress | No | Your address to receive referral fees |
referrerFeeBps | No | Referral fee in basis points (0-10000) |
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)
| Token | Address | Decimals | Notes |
|---|---|---|---|
| MON (native) | 0x0000000000000000000000000000000000000000 | 18 | No approval needed |
| USDC | 0x754704Bc059F8C67012fEd69BC8A327a5aafb603 | 6 | Requires approval |
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
| Swap Output | Fee Amount |
|---|---|
| 100 USDC | 0.5 USDC |
| 500 USDC | 2.5 USDC |
| 1000 USDC | 5 USDC |
Error Handling
Along the way, we might run into errors. Here is how to interpret them:| Status Code | Meaning |
|---|---|
| 400 | Bad request - check parameters |
| 401 | Unauthorized - invalid or expired token |
| 429 | Rate limited - wait before retrying |
| 500 | Server error - retry later |
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

