Getting started
Clone the Example Solver Repository
The AMM Solver example uses a simple constant-product AMM formula to price quotes
Configure your environment
Create your environment file from the provided example:Open
env/.env.local and fill your NEAR account credentials, the token pair you want to market-make, and your desired fee margin.Example .env file
Example .env file
Get a Message Bus API key
The default Message Bus WebSocket endpoint (Then open
wss://solver-relay-v2.chaindefuser.com/ws) requires an API key. To get one:- Sign up at partners.near-intents.org
- Request an API key through the partner portal
- Undergo KYC/KYB verification as part of the application process
env/.env.local:src/services/websocket-connection.service.ts and update the WebSocket connection headers at line 35 to use the environment variable:Deposit liquidity
Your solver can only fill swaps if it has token balances inside the Verifier contract (Replace
intents.near).You need to do two things: register your solver’s public key on the contract, and deposit tokens.Register your public key
YOUR_PUBLIC_KEY with the public key that corresponds to the private key in your .env.local file, and SOLVER_ACCOUNT_ID with your actual NEAR account ID.Deposit tokens
- near-intents.org - a web interface for swapping and depositing tokens
- The Passive Deposit/Withdrawal Service - deposit from any supported chain via API
usdt.tether-token.near and wrap.near deposited into the contract.Start the solver
Since the environment file is named On startup, the solver connects to the Message Bus WebSocket, subscribes to quote events, and begins polling the Verifier contract for current token balances every 15 seconds. Log output confirms the connection and initial reserves.
.env.local, set NODE_ENV=local so the app picks it up:Verify it is working
Check the health endpoint to confirm the solver is running:In the logs, look for:
- Connection confirmed - successful WebSocket connection to the Message Bus
- Quote requests - incoming swap requests being evaluated
- Quote responses - signed quotes being sent back for pairs your solver supports