# Authentication Source: https://docs.chainworks.co/authentication How token-based authentication works on the Chainworks API over both Socket.IO and HTTP, including required credentials. The Chainworks API uses token-based authentication. The same token works on both transports; only where you put it differs. * **Socket.IO** sends the token once in the connection handshake (`auth: { token }`). * **HTTP** sends the token on every request in the `Authorization` header, as the raw token with no `Bearer` prefix. ## Authentication Flow 1. Obtain your API credentials (API URL and Auth Token) 2. Provide the token: in the Socket.IO handshake, or in the HTTP `Authorization` header 3. The server validates your token 4. If valid, you can start making API requests ## Connecting with Credentials The token is validated once during the handshake. ```typescript TypeScript theme={null} import { io } from "socket.io-client"; const socket = io(CHAINWORKS_API_URL, { transports: ["websocket"], auth: { token: CHAINWORKS_API_AUTH_TOKEN, }, }); ``` ```python Python theme={null} import socketio sio = socketio.Client() sio.connect( CHAINWORKS_API_URL, transports=["websocket"], auth={"token": CHAINWORKS_API_AUTH_TOKEN} ) ``` The token is validated on every request via the `Authorization` header (raw token, no `Bearer` prefix). Requests use `Content-Type: application/json`. ```typescript TypeScript theme={null} const res = await fetch(`${CHAINWORKS_API_URL}/svm/token/meta`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "..." }), }); ``` ```python Python theme={null} import requests res = requests.post( f"{CHAINWORKS_API_URL}/svm/token/meta", headers={"Authorization": CHAINWORKS_API_AUTH_TOKEN}, json={"chain": "sol", "token": "..."}, ) ``` ## Environment Variables We recommend storing your credentials in environment variables: ```bash .env theme={null} CHAINWORKS_API_URL=https://api.chainworks.co CHAINWORKS_API_AUTH_TOKEN=your-secret-token ``` ```typescript theme={null} const socket = io(process.env.CHAINWORKS_API_URL!, { transports: ["websocket"], auth: { token: process.env.CHAINWORKS_API_AUTH_TOKEN!, }, }); ``` ```typescript theme={null} const res = await fetch(`${process.env.CHAINWORKS_API_URL}/svm/token/meta`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: process.env.CHAINWORKS_API_AUTH_TOKEN!, }, body: JSON.stringify({ chain: "sol", token: "..." }), }); ``` ## Connection Events (Socket.IO) These lifecycle events apply to the Socket.IO transport. HTTP is stateless and has no connection events, so handle errors per request from the response instead. Handle connection lifecycle events to ensure robust operation: ```typescript theme={null} socket.on("connect", () => { console.log("Connected successfully"); // Start making API requests }); socket.on("connect_error", (error) => { console.error("Connection error:", error.message); // Handle authentication failures if (error.message.includes("unauthorized")) { console.error("Invalid API token"); } }); socket.on("disconnect", (reason) => { console.log("Disconnected:", reason); // Handle reconnection if needed }); ``` ## Reconnection (Socket.IO) Socket.IO automatically handles reconnection. You can configure the behavior: ```typescript theme={null} const socket = io(CHAINWORKS_API_URL, { transports: ["websocket"], auth: { token: CHAINWORKS_API_AUTH_TOKEN, }, reconnection: true, reconnectionAttempts: 5, reconnectionDelay: 1000, reconnectionDelayMax: 5000, }); ``` ## Security Best Practices 1. **Never expose tokens in client-side code** - Use server-side proxies for browser applications 2. **Rotate tokens regularly** - Contact us to regenerate compromised tokens 3. **Use environment variables** - Never hardcode tokens in source code 4. **Monitor usage** - Track API calls to detect unauthorized access ## Rate Limits API rate limits depend on your subscription tier. Contact us for details about rate limits and quotas. ## Next Steps * [Quick Start](/quickstart) - Get started with your first request * [EVM Endpoints](/evm/overview) - Explore Ethereum, Base, and BSC endpoints * [SVM Endpoints](/svm/overview) - Explore Solana endpoints # Error Handling Source: https://docs.chainworks.co/errors Error codes, shapes, and recovery strategies for Chainworks API responses over Socket.IO and HTTP. The Chainworks API uses consistent error responses across all endpoints. *** ## Error Response Format When a request fails, you receive an error response: ```json theme={null} { "success": false, "error": { "code": "ERROR_CODE", "message": "Human-readable error description" }, "partialResult": { // Optional: helpful data even when the request fails } } ``` The `partialResult` field may contain useful information even when the request fails, such as partial token data or pool information. ### Both transports share this envelope The success and error envelope is identical on Socket.IO and HTTP. A successful response always has `success: true` and a `result` field; responses may also include optional `rateLimit` and `serverTimings` objects. Over Socket.IO, the response arrives on the event you emitted. Over HTTP, the same JSON is returned in the response body, and the HTTP status code reflects the outcome: | HTTP Status | Meaning | | ----------- | ------------------------------------------------------------ | | `200` | Success (`success: true`) | | `400` | Client error such as invalid input or authentication failure | | `402` | Monthly credit allowance exhausted | | `500` | Internal server error | Even on a `400` or `500`, the body still follows the error envelope above, so you can read `error.code` and `error.message` the same way on both transports. *** ## Common Error Codes ### Connection Errors | Code | Description | Solution | | -------------------- | ----------------------------- | --------------------------- | | `UNAUTHORIZED` | Invalid or expired auth token | Check your API credentials | | `CONNECTION_TIMEOUT` | Server didn't respond in time | Retry the request | | `RATE_LIMITED` | Too many requests | Implement backoff and retry | ### Account Errors | Code | Description | Solution | | ----------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------- | | `CREDIT_LIMIT_EXCEEDED` | Monthly credit allowance and overage are exhausted | Wait for the UTC month to roll over, or change plan. See [Pricing](/pricing) | `CREDIT_LIMIT_EXCEEDED` arrives with HTTP `402` and is not retryable - the same request keeps failing until the month rolls over or the plan changes. Free routes such as `/svm/price/unsubscribe`, `/svm/wallet-tracker/untrack`, and `/evm/autosnipe/remove` keep working while an account is over its limit, so standing work can always be wound down. ### Request Errors | Code | Description | Solution | | ------------------- | ------------------------------------------------------------ | -------------------------------------------- | | `INVALID_CHAIN` | Unsupported chain identifier | Use `eth`, `base`, `bsc`, or `sol` | | `INVALID_TOKEN` | Token address not found | Verify the token contract address | | `NOT_A_TOKEN` | Address is not a valid token mint or does not exist on chain | Verify the mint address for the target chain | | `INVALID_WALLET` | Invalid wallet address format | Check the address format | | `INVALID_AMOUNT` | Amount is zero or negative | Provide a valid positive amount | | `MISSING_PARAMETER` | Required parameter not provided | Include all required parameters | ### Trading Errors | Code | Description | Solution | | ------------------------ | ------------------------------------ | ------------------------------------- | | `INSUFFICIENT_LIQUIDITY` | Not enough liquidity for trade | Reduce trade size or try later | | `PRICE_IMPACT_TOO_HIGH` | Trade would cause excessive slippage | Reduce trade size | | `TOKEN_NOT_TRADEABLE` | Token trading is restricted | Check token contract for restrictions | | `NO_ROUTE_FOUND` | No DEX route available | Token may not have liquidity | ### Transaction Errors | Code | Description | Solution | | ------------------------------- | ------------------------------ | ----------------------------- | | `INSUFFICIENT_BALANCE` | Wallet lacks funds | Add funds to wallet | | `APPROVAL_REQUIRED` | Token approval needed | Call approve endpoint first | | `TRANSACTION_SIMULATION_FAILED` | Transaction would revert | Check parameters and balances | | `NONCE_TOO_LOW` | Transaction nonce already used | Use a higher nonce | *** ## Handling Errors ### TypeScript ```typescript theme={null} socket.on("/evm/buy/quote", (response) => { if (response.success) { console.log("Quote:", response.result); } else { const { code, message } = response.error; switch (code) { case "INSUFFICIENT_LIQUIDITY": console.log("Not enough liquidity. Try a smaller amount."); break; case "INVALID_TOKEN": console.log("Token not found. Check the address."); break; default: console.error(`Error ${code}: ${message}`); } // partialResult may contain useful info if (response.partialResult) { console.log("Partial data:", response.partialResult); } } }); ``` ### Python ```python theme={null} @sio.on("/evm/buy/quote") def on_quote(response): if response.get("success"): print("Quote:", response["result"]) else: error = response["error"] code = error["code"] message = error["message"] if code == "INSUFFICIENT_LIQUIDITY": print("Not enough liquidity. Try a smaller amount.") elif code == "INVALID_TOKEN": print("Token not found. Check the address.") else: print(f"Error {code}: {message}") if "partialResult" in response: print("Partial data:", response["partialResult"]) ``` *** ## Retry Strategy For transient errors, implement exponential backoff: ```typescript theme={null} async function requestWithRetry(path: string, params: object, maxRetries = 3): Promise { for (let attempt = 0; attempt < maxRetries; attempt++) { try { const response = await makeRequest(path, params); if (response.success) { return response.result; } // Don't retry certain errors const noRetry = [ "INVALID_TOKEN", "INVALID_WALLET", "UNAUTHORIZED", "CREDIT_LIMIT_EXCEEDED", ]; if (noRetry.includes(response.error.code)) { throw new Error(response.error.message); } // Exponential backoff const delay = Math.pow(2, attempt) * 1000; await new Promise((resolve) => setTimeout(resolve, delay)); } catch (error) { if (attempt === maxRetries - 1) { throw error; } } } } ``` *** ## Debugging Tips 1. **Check the console** - Log full responses to see error details 2. **Use the playground** - Test requests interactively at [/playground](https://chainworks.co/playground) 3. **Validate addresses** - Ensure addresses are correct for the target chain 4. **Check token contract** - Some tokens have transfer restrictions 5. **Monitor connection** - Ensure WebSocket connection is stable *** ## Getting Help If you encounter persistent errors: 1. Note the error code and message 2. Capture the full request parameters 3. Contact us at [info@chainworks.co](mailto:info@chainworks.co) # EVM AutoSnipe Source: https://docs.chainworks.co/evm/autosnipe Configure AutoSnipe to automatically execute EVM buys the moment liquidity is added. Monitor unlaunched EVM tokens and receive real-time signals when they become buyable. AutoSnipe watches the mempool and new blocks for liquidity events, simulates buyability, and pushes a signal to your Socket.IO connection the moment a token launches. > **Socket.IO only:** AutoSnipe signals are delivered as server-emitted events on your Socket.IO connection. You must be connected via Socket.IO to receive them. *** ## Register Watch Register a watch on a token to be notified when it becomes buyable. **Endpoint:** `/evm/autosnipe/register` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ----------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Chain identifier: `eth`, `base`, or `bsc` | | `token` | string | Yes | Token contract address to watch | | `ttlMs` | number | No | Watch duration in milliseconds. Min: 3,600,000 (1h), max: 172,800,000 (2d), default: 86,400,000 (24h) | **Example:** ```typescript theme={null} socket.emit("/evm/autosnipe/register", { chain: "eth", token: "0x1234567890abcdef1234567890abcdef12345678", ttlMs: 86400000, // 24 hours }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/autosnipe/register", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x1234567890abcdef1234567890abcdef12345678", ttlMs: 86400000, // 24 hours }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "eth", "token": "0x1234567890abcdef1234567890abcdef12345678", "owner": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd", "expiresAt": 1711065600 } } ``` Registration will be rejected if: * The address is not a contract * The token is already launched and buyable * The token or its owner is on the ignored addresses list (stablecoins, WETH, known MEV bots, etc.) *** ## Remove Watch Remove an active AutoSnipe watch. **Endpoint:** `/evm/autosnipe/remove` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ---------------------- | | `chain` | string | Yes | Chain identifier | | `token` | string | Yes | Token contract address | **Example:** ```typescript theme={null} socket.emit("/evm/autosnipe/remove", { chain: "eth", token: "0x1234567890abcdef1234567890abcdef12345678", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/autosnipe/remove", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x1234567890abcdef1234567890abcdef12345678", }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "eth", "token": "0x1234567890abcdef1234567890abcdef12345678" } } ``` *** ## List Watches List all active AutoSnipe watches on a chain. **Endpoint:** `/evm/autosnipe/list` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ---------------- | | `chain` | string | Yes | Chain identifier | **Example:** ```typescript theme={null} socket.emit("/evm/autosnipe/list", { chain: "eth", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/autosnipe/list", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", }), }); ``` **Response:** ```json theme={null} { "success": true, "result": [ { "chain": "eth", "partnerId": "your-partner-id", "token": "0x1234567890abcdef1234567890abcdef12345678", "owner": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd", "expiresAt": 1711065600, "registeredAt": 1710979200 } ] } ``` *** ## AutoSnipe Signal Event When a watched token becomes buyable, you receive an `autoSnipeSignal` event on your Socket.IO connection. Watches are automatically removed after a signal fires. ```typescript theme={null} socket.on("autoSnipeSignal", (data) => { console.log(data); }); ``` **Event payload:** ```json theme={null} { "chain": "eth", "token": "0x1234567890abcdef1234567890abcdef12345678", "type": "block0", "blockNumber": "19500000", "taxes": { "buyTaxBps": 500, "sellTaxBps": 500 }, "limits": { "buyLowerLimit": null, "buyUpperLimit": "1000000000000000000", "sellLowerLimit": null, "sellUpperLimit": null }, "triggeringTx": "0x02f8...", "timestamp": 1710979200 } ``` | Field | Type | Description | | ----------------------- | -------------- | ---------------------------------------------------------------------------------- | | `chain` | string | Chain where the token launched | | `token` | string | Token contract address | | `type` | string | `block0` (detected in mempool before mining) or `block1` (detected in mined block) | | `blockNumber` | string | Block number at detection time | | `taxes.buyTaxBps` | number \| null | Buy tax in basis points (null if unknown) | | `taxes.sellTaxBps` | number \| null | Sell tax in basis points (null if unknown) | | `limits.buyLowerLimit` | string \| null | Minimum buy amount in wei (null if none) | | `limits.buyUpperLimit` | string \| null | Maximum buy amount in wei (null if none) | | `limits.sellLowerLimit` | string \| null | Minimum sell amount in wei (null if none) | | `limits.sellUpperLimit` | string \| null | Maximum sell amount in wei (null if none) | | `triggeringTx` | string \| null | RLP-serialized transaction that triggered the launch (block0 only) | | `timestamp` | number | Unix timestamp in seconds | ### Signal Types * **`block0`** - The token was detected as buyable from a pending mempool transaction *before* it was mined. This gives you the earliest possible signal. The `triggeringTx` field contains the serialized liquidity-adding transaction. * **`block1`** - The token was detected as buyable in the first block after the liquidity transaction was mined. This is a fallback for cases where mempool detection was not possible. # EVM Liquidity Pools Source: https://docs.chainworks.co/evm/liquidity-pools List Uniswap V4 and PancakeSwap V4 liquidity pools for a token on EVM chains. List the Uniswap V4 and PancakeSwap V4 liquidity pools that hold a given token. Both endpoints take the same parameters and return the same shape. *** ## Uniswap V4 Pools Find Uniswap V4 pools for a token. **Endpoint:** `/evm/uniswap-v4/liquidity-pools` | Parameter | Type | Required | Description | | --------------- | --------- | -------- | -------------------------------------------------------------- | | `chain` | string | Yes | Chain identifier: `eth`, `base`, or `bsc` | | `token` | string | Yes | Token contract address | | `maxPools` | number | No | Maximum number of pools to return | | `backingTokens` | string\[] | No | Restrict results to pools paired against these token addresses | **Example:** ```typescript theme={null} socket.emit("/evm/uniswap-v4/liquidity-pools", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/uniswap-v4/liquidity-pools", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE }), }); ``` **Response:** `result` is an array of pools, or `null` when none are found. ```json theme={null} { "success": true, "result": [ { "poolId": "0x9a8...c41", "tick": -198432, "tickSpacing": "60", "sqrtPriceX96": "1023456789012345678901234", "fee": 3000, "currency0": "0x0000000000000000000000000000000000000000", "currency1": "0x6982508145454Ce325dDbE47a25d4ec3d2311933", "hooks": "0x0000000000000000000000000000000000000000", "blockNumber": "19500000" } ] } ``` | Field | Type | Description | | -------------- | -------------- | ----------------------------------------------------------------- | | `poolId` | string | Pool identifier | | `tick` | number | Current tick | | `tickSpacing` | string | Tick spacing of the pool | | `sqrtPriceX96` | string | Current price as a Q64.96 square root | | `fee` | number | Pool fee tier | | `currency0` | string | First currency address (the zero address denotes native currency) | | `currency1` | string | Second currency address | | `hooks` | string | Hooks contract address (the zero address denotes no hooks) | | `blockNumber` | string | Block number the data was read at | | `parameters` | string \| null | Encoded pool parameters. May be absent | | `protocolFee` | number \| null | Protocol fee. May be absent | | `positions` | object\[] | Liquidity positions for the pool. May be absent | *** ## PancakeSwap V4 Pools Find PancakeSwap V4 pools for a token. Same parameters and response shape as Uniswap V4 Pools. **Endpoint:** `/evm/pcs-v4/liquidity-pools` **Example:** ```typescript theme={null} socket.emit("/evm/pcs-v4/liquidity-pools", { chain: "bsc", token: "0xTokenAddress", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/pcs-v4/liquidity-pools", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "bsc", token: "0xTokenAddress", }), }); ``` # EVM Endpoints Source: https://docs.chainworks.co/evm/overview EVM API endpoints (beta) for Ethereum, Base, and BNB Chain including quotes, transactions, wallet, and AutoSnipe. Complete API reference for EVM-compatible chains including Ethereum, Base, and BNB Chain. *** ## Supported Chains | Chain | Identifier | Native Token | | --------- | ---------- | ------------ | | Ethereum | `eth` | ETH | | Base | `base` | ETH | | BNB Chain | `bsc` | BNB | *** ## Endpoints * **[Quotes](/evm/quotes)** - Get price quotes for token swaps * **[Transactions](/evm/transactions)** - Build unsigned transactions for swaps * **[Transfers](/evm/transfers)** - Transfer native currency and tokens * **[Wallet](/evm/wallet)** - Query wallet balances * **[Token Info](/evm/token-info)** - Get token metadata and reports * **[Send Transaction](/evm/send-transaction)** - Broadcast signed transactions * **[AutoSnipe](/evm/autosnipe)** - Real-time token launch detection signals # EVM Quotes Source: https://docs.chainworks.co/evm/quotes Fetch buy and sell quotes for token swaps on Ethereum, Base, and BNB Chain. Get price quotes for token swaps without executing transactions. *** ## Get Buy Quote Get a price quote for buying tokens with native currency. **Endpoint:** `/evm/buy/quote` | Parameter | Type | Required | Description | | ----------- | ------ | ----------- | -------------------------------------------------------- | | `chain` | string | Yes | Chain identifier: `eth`, `base`, or `bsc` | | `token` | string | Yes | Token contract address | | `swapMode` | string | Yes | `ExactIn` (specify input) or `ExactOut` (specify output) | | `amountIn` | string | Conditional | Amount of native currency in wei. Required for `ExactIn` | | `amountOut` | string | Conditional | Amount of tokens to receive. Required for `ExactOut` | | `wallet` | string | Yes | Wallet address for the quote | **Example:** ```typescript theme={null} socket.emit("/evm/buy/quote", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", // 1 ETH wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/buy/quote", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", // 1 ETH wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "eth", "isBuy": true, "token": "0x6982508145454Ce325dDbE47a25d4ec3d2311933", "swapMode": "ExactIn", "price": 0.00000234, "priceImpact": 0.0012, "amountIn": "1000000000000000000", "expectedAmountOut": "427350427350427350427350" } } ``` *** ## Get Sell Quote Get a price quote for selling tokens for native currency. **Endpoint:** `/evm/sell/quote` | Parameter | Type | Required | Description | | ---------- | ------ | ----------- | ------------------------------------------------ | | `chain` | string | Yes | Chain identifier | | `token` | string | Yes | Token contract address | | `swapMode` | string | Yes | `ExactIn` or `ExactOut` | | `amountIn` | string | Conditional | Amount of tokens to sell. Required for `ExactIn` | | `wallet` | string | Yes | Wallet address | # EVM Send Transaction Source: https://docs.chainworks.co/evm/send-transaction Submit signed EVM transactions through the Chainworks API for on-chain execution. Broadcast signed transactions to the network. **Endpoint:** `/evm/send-transaction` > ⚠️ **Warning:** This endpoint sends real transactions to the blockchain. | Parameter | Type | Required | Description | | -------------------- | --------- | -------- | --------------------------------------- | | `chain` | string | Yes | Chain identifier | | `signedTransactions` | string\[] | Yes | Array of signed transaction hex strings | | `simulateBeforeSend` | boolean | No | Simulate before sending (default: true) | # EVM Token Information Source: https://docs.chainworks.co/evm/token-info Inspect ERC-20 token metadata, liquidity, taxes, and holder limits on EVM chains. ## Get Token Metadata **Endpoint:** `/evm/token/meta` Returns name, symbol, decimals, and total supply. *** ## Get Token Report **Endpoint:** `/evm/token/report` Returns comprehensive token analysis: * Basic metadata (name, symbol, decimals) * Liquidity information * Buy/sell taxes * Transfer limits * Market cap and volume # EVM Transactions Source: https://docs.chainworks.co/evm/transactions Build EVM swap transactions across Ethereum, Base, and BNB Chain. Build unsigned transactions for token swaps. *** ## Get Buy Transaction Build an unsigned transaction for buying tokens. **Endpoint:** `/evm/buy/transaction` | Parameter | Type | Required | Description | | -------------- | ------ | -------- | ------------------------------------------------------ | | `chain` | string | Yes | Chain identifier | | `token` | string | Yes | Token contract address | | `swapMode` | string | Yes | `ExactIn` or `ExactOut` | | `amountIn` | string | Yes | Amount of native currency in wei | | `wallet` | string | Yes | Wallet address | | `slippageBps` | number | No | Slippage tolerance in basis points (default: 100 = 1%) | | `feeBps` | number | No | Fee in basis points (0-175) | | `feeRecipient` | string | No | Wallet to receive fees | | `sendRoute` | string | No | `Public`, `Private`, or `Both` for MEV protection | **Example:** ```typescript theme={null} socket.emit("/evm/buy/transaction", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", slippageBps: 100, sendRoute: "Private", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", slippageBps: 100, sendRoute: "Private", }), }); ``` *** ## Get Sell Transaction **Endpoint:** `/evm/sell/transaction` Same parameters as buy transaction. *** ## Get Approve Transaction Build a transaction to approve token spending. **Endpoint:** `/evm/approve/transaction` | Parameter | Type | Required | Description | | --------- | ------ | -------- | --------------------------- | | `chain` | string | Yes | Chain identifier | | `token` | string | Yes | Token contract address | | `wallet` | string | Yes | Wallet granting approval | | `spender` | string | Yes | Contract address to approve | # EVM Transfers Source: https://docs.chainworks.co/evm/transfers Construct native and ERC-20 token transfer transactions on EVM chains. Build transactions for native and token transfers. *** ## Native Transfer Transfer ETH/BNB to another address. **Endpoint:** `/evm/transfer/transaction` | Parameter | Type | Required | Description | | ----------- | ------ | -------- | ----------------- | | `chain` | string | Yes | Chain identifier | | `recipient` | string | Yes | Recipient address | | `amount` | string | Yes | Amount in wei | | `wallet` | string | Yes | Sender address | *** ## Token Transfer Transfer ERC-20 tokens. **Endpoint:** `/evm/transfer/token/transaction` | Parameter | Type | Required | Description | | ----------- | ------ | -------- | ------------------------ | | `chain` | string | Yes | Chain identifier | | `token` | string | Yes | Token contract address | | `recipient` | string | Yes | Recipient address | | `amount` | string | Yes | Amount in token decimals | | `wallet` | string | Yes | Sender address | # EVM Wallet Source: https://docs.chainworks.co/evm/wallet Retrieve EVM wallet balances and token holdings for Ethereum, Base, and BNB Chain. Query wallet balances. *** ## Get Native Balance **Endpoint:** `/evm/wallet/balance` ```typescript theme={null} socket.emit("/evm/wallet/balance", { chain: "eth", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/wallet/balance", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }), }); ``` *** ## Get Token Balance **Endpoint:** `/evm/wallet/balance/token` ```typescript theme={null} socket.emit("/evm/wallet/balance/token", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/evm/wallet/balance/token", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", wallet: "0x10a64c6d7f12c47b7c66c5b4e20e72bc1fcd5d9e", }), }); ``` # Frequently Asked Questions Source: https://docs.chainworks.co/faq Answers to common questions about the Chainworks API: supported chains, authentication, transport, the playground, and machine-readable docs. Common questions about the Chainworks API. If you don't find what you need here, reach out and we'll help. Chainworks is a unified DeFi API for building applications, available over both Socket.IO and HTTP. One integration gives you trading, quotes, wallet data, and token info across Solana, Ethereum, Base, and BNB Chain. Solana is the primary supported chain. Ethereum, Base, and BNB Chain are supported in beta. All chains share the same API surface so you can write one integration. Authentication is token-based. You pass your API URL and auth token to the Socket.IO client on connect; see [Authentication](/authentication) for the exact handshake. The API is available over two transports: Socket.IO for a persistent, low-latency connection with real-time push, and HTTP for stateless request and response. Every event path is also an HTTP endpoint, and the request body and response shape are identical across both, so you can pick whichever fits your stack. See [Quick Start](/quickstart) for both. Yes. The [Playground](https://chainworks.co/playground) is an interactive tester where you can pick an endpoint, fill in parameters, connect with your credentials, and inspect the live response. Every docs page has a `.md` twin (for example, `/quickstart.md`), and `/llms-full.txt` contains all documentation concatenated for LLM ingestion. `/llms.txt` is a compact index. # Chainworks API Source: https://docs.chainworks.co/index Overview of the Chainworks unified DeFi API, available over Socket.IO and HTTP, across Solana, Ethereum, Base, and BNB Chain. Welcome to the Chainworks API documentation. Build powerful DeFi applications with our unified API, available over both Socket.IO and HTTP. *** ## What is Chainworks? Chainworks provides a **unified DeFi API** that enables developers and institutions to easily access trading, token analysis, and other DeFi functionality across multiple blockchains. The same operations are available over two transports: * **Socket.IO** for a persistent, low-latency connection with real-time push (for example live price updates). * **HTTP** for simple, stateless request and response calls. Every event path is also an HTTP endpoint. The request body and response shape are identical across transports, so you can pick whichever fits your stack. See [Quick Start](/quickstart) and [Authentication](/authentication) for both. *** ## Supported Chains | Chain | Identifier | Type | Native Token | | --------- | ---------- | ---- | ------------ | | Ethereum | `eth` | EVM | ETH | | Base | `base` | EVM | ETH | | BNB Chain | `bsc` | EVM | BNB | | Solana | `sol` | SVM | SOL | *** ## Core Features ### Token Trading Execute swaps across multiple DEXes with optimal routing. Get quotes, build transactions, and send them with MEV protection. ### Price Quotes Real-time price quotes with slippage calculation, price impact analysis, and liquidity information. ### Token Reports Comprehensive token analysis including: * Liquidity depth * Buy/sell taxes * Transfer limits * Holder restrictions * Market data ### Multi-Chain Transfers Build and send native currency and token transfers across all supported chains. *** ## Quick Example ```typescript theme={null} import { io } from "socket.io-client"; const socket = io(CHAINWORKS_API_URL, { transports: ["websocket"], auth: { token: CHAINWORKS_API_AUTH_TOKEN }, }); socket.on("connect", () => { console.log("Connected to Chainworks API"); // Get a buy quote socket.emit("/evm/buy/quote", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", wallet: "0xYourWallet", }); }); socket.on("/evm/buy/quote", (response) => { if (response.success) { console.log("Price:", response.result.price); } }); ``` ```typescript theme={null} // Get a buy quote const res = await fetch(`${CHAINWORKS_API_URL}/evm/buy/quote`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", swapMode: "ExactIn", amountIn: "1000000000000000000", wallet: "0xYourWallet", }), }); const response = await res.json(); if (response.success) { console.log("Price:", response.result.price); } ``` *** ## Next Steps * **[Quick Start](/quickstart)** - Set up your environment and make your first request * **[Authentication](/authentication)** - Learn how to connect with your credentials * **[EVM Endpoints](/evm/overview)** - Explore Ethereum, Base, and BSC APIs * **[SVM Endpoints](/svm/overview)** - Explore Solana APIs * **[FAQ](/faq)** - Answers to common questions * **[Playground](https://chainworks.co/playground)** - Test the API interactively # Credits and Pricing Source: https://docs.chainworks.co/pricing What each Chainworks API endpoint costs in credits, and how connections, channels, and standing work are billed. Usage is metered in **credits**. Every priced call, every second a push socket is held open, and every byte delivered on a channel draws from your plan's monthly credit allowance. A call costs the same whichever transport it arrives on. Socket.IO, HTTP, and batch all address a route by the same path, so they are billed identically. *** ## Request Costs Requests are charged per call, at one of four rates. | Rate | Credits per call | Typical work | | -------- | ---------------- | ------------------------------------------------------------- | | Free | 0 | Control-plane calls: subscribe, unsubscribe, list | | Standard | 1 | One cheap read: metadata, balances, a single record | | Elevated | 5 | A write, a multi-service hop, or pool discovery | | Heavy | 10 | A quote plus transaction simulation, or a multi-record return | Free calls are still recorded, and they are still blocked once an account is out of credits. *** ## SVM (Solana) Endpoints | Endpoint | Credits | | --------------------------------------- | ------- | | `/svm/buy/quote` | 5 | | `/svm/sell/quote` | 5 | | `/svm/buy/transaction` | 10 | | `/svm/sell/transaction` | 10 | | `/svm/transfer/transaction` | 5 | | `/svm/transfer/token/transaction` | 5 | | `/svm/transfer/multi/transaction` | 5 | | `/svm/transfer/multi/token/transaction` | 5 | | `/svm/send-transaction` | 5 | | `/svm/compile-transaction` | 5 | | `/svm/nonce-account/create/transaction` | 5 | | `/svm/token/meta` | 1 | | `/svm/token/report` | 1 | | `/svm/wallet/balance` | 1 | | `/svm/wallet/balance/token` | 1 | | `/svm/price/subscribe` | 0 | | `/svm/price/unsubscribe` | 0 | | `/svm/price/active_subscriptions` | 0 | | `/svm/wallet-tracker/track` | 0 | | `/svm/wallet-tracker/untrack` | 0 | | `/svm/wallet-tracker/list` | 0 | Subscribing and tracking are free calls. The cost of a price subscription is the bytes its `priceUpdate` events deliver; the cost of a tracked wallet is the standing charge below. *** ## EVM Endpoints | Endpoint | Credits | | --------------------------------- | ------- | | `/evm/buy/quote` | 1 | | `/evm/sell/quote` | 1 | | `/evm/buy/transaction` | 5 | | `/evm/sell/transaction` | 5 | | `/evm/approve/transaction` | 5 | | `/evm/transfer/transaction` | 5 | | `/evm/transfer/token/transaction` | 5 | | `/evm/send-transaction` | 5 | | `/evm/token/meta` | 1 | | `/evm/token/report` | 1 | | `/evm/wallet/balance` | 1 | | `/evm/wallet/balance/token` | 1 | | `/evm/v2/liquidity-pools` | 5 | | `/evm/v3/liquidity-pools` | 5 | | `/evm/uniswap-v4/liquidity-pools` | 5 | | `/evm/pcs-v4/liquidity-pools` | 5 | | `/evm/liquidity-pools/by-id` | 1 | | `/evm/autosnipe/register` | 0 | | `/evm/autosnipe/remove` | 0 | | `/evm/autosnipe/list` | 0 | Registering and removing an auto-snipe watch are free. The watch itself is billed per minute as standing work, and its signals are billed on the bytes they deliver. *** ## TVM Endpoints | Endpoint | Credits | | ---------------------- | ------- | | `/tvm/liquidity-pools` | 5 | *** ## Transaction Logs | Endpoint | Credits | | ------------------- | ------- | | `/transaction/log` | 1 | | `/transaction/logs` | 10 | *** ## Connection Costs Holding a push socket open costs **1 credit per connected minute**, charged once per connection no matter how many channels it subscribes to. Two sockets open at the same time cost twice as much, because that is two connections alive. | Meter | Rate | | --------------- | ------------------- | | Push connection | 1 credit per minute | *** ## Channel Costs Delivered events are charged on bytes, at **1 credit per 3.5 MB** (about 286 credits per GB). Time is not charged again here - that is the connection meter's job - so a socket subscribed to several channels is not billed for its duration more than once. | Channel | Rate | | ------------------------- | ----------------------------- | | `priceUpdate` | 1 credit per 3.5 MB delivered | | `trackedWalletActivity` | 1 credit per 3.5 MB delivered | | `transactionStatusUpdate` | 1 credit per 3.5 MB delivered | | `autoSnipeSignal` | 1 credit per 3.5 MB delivered | *** ## Standing Work Some features cost while they exist, not when they are called. These are billed by how long each item is registered, the way instance-hours are billed. | Meter | Rate | | ---------------- | ------------------------------- | | Tracked wallet | 2 credits per wallet per minute | | Auto-snipe watch | 2 credits per watch per minute | Fifty tracked wallets held for one minute costs 100 credits, not 2. These charges continue until the wallet is untracked or the watch is removed or expires, and they are not attributed to any one API key - revoking a key does not stop them. Standing work accrues whether or not you call the API. A tracked wallet left registered for a month costs 86,400 credits. *** ## Running Out of Credits When an account passes its monthly allowance plus its overage grace, priced routes are rejected with `CREDIT_LIMIT_EXCEEDED` and HTTP `402`. Free routes such as unsubscribe, untrack, and auto-snipe remove keep working, so you can always wind standing work down. Retrying does not help. The block clears when the calendar month rolls over in UTC, or when the plan changes. See [Error Handling](/errors) for the response shape. # Quick Start Source: https://docs.chainworks.co/quickstart Install the Socket.IO client, connect to the Chainworks API, and make your first request in TypeScript or Python. Get up and running with the Chainworks API in just a few minutes. ## Prerequisites * Node.js 18+ or Python 3.8+ * Chainworks API credentials (API URL and Auth Token) * Basic understanding of either Socket.IO or HTTP requests ## Choosing a Transport The Chainworks API exposes the same operations over two transports: * **Socket.IO** keeps a persistent, bidirectional connection with low latency and real-time push (for example live price updates). Pick this for streaming or high-frequency trading. * **HTTP** is stateless request and response. Pick this for simple integrations or when you cannot hold an open connection. The request body and response shape are identical across transports, so the examples below show both. Use the toggle to switch. ## Installation The Socket.IO transport needs a client library. The HTTP transport works with any HTTP client (the built-in `fetch` in JavaScript, or `requests` in Python), so it needs no SDK. ```bash TypeScript / JavaScript theme={null} npm install socket.io-client ``` ```bash Python theme={null} pip install python-socketio ``` No installation required. Use the built-in `fetch` (Node.js 18+ / browsers) or `requests` in Python: ```bash theme={null} pip install requests ``` ## Connecting to the API Socket.IO opens a persistent connection and authenticates once during the handshake. ```typescript TypeScript theme={null} import { io } from "socket.io-client"; const CHAINWORKS_API_URL = "https://api.chainworks.co"; const CHAINWORKS_API_AUTH_TOKEN = "your-auth-token"; const socket = io(CHAINWORKS_API_URL, { transports: ["websocket"], auth: { token: CHAINWORKS_API_AUTH_TOKEN, }, }); socket.on("connect", () => { console.log("Connected to Chainworks API"); }); socket.on("connect_error", (error) => { console.error("Connection failed:", error.message); }); socket.on("disconnect", (reason) => { console.log("Disconnected:", reason); }); ``` ```python Python theme={null} import socketio CHAINWORKS_API_URL = "https://api.chainworks.co" CHAINWORKS_API_AUTH_TOKEN = "your-auth-token" sio = socketio.Client() @sio.event def connect(): print("Connected to Chainworks API") @sio.event def connect_error(data): print(f"Connection failed: {data}") @sio.event def disconnect(): print("Disconnected") sio.connect( CHAINWORKS_API_URL, transports=["websocket"], auth={"token": CHAINWORKS_API_AUTH_TOKEN} ) ``` HTTP has no connection step. Each request is sent to the base URL and carries the auth token in the `Authorization` header (no `Bearer` prefix). ```typescript TypeScript theme={null} const CHAINWORKS_API_URL = "https://api.chainworks.co"; const CHAINWORKS_API_AUTH_TOKEN = "your-auth-token"; ``` ```python Python theme={null} CHAINWORKS_API_URL = "https://api.chainworks.co" CHAINWORKS_API_AUTH_TOKEN = "your-auth-token" ``` ## Your First Request Let's get a buy quote for a token on Ethereum: ```typescript TypeScript theme={null} // Request a buy quote socket.emit("/evm/buy/quote", { chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE swapMode: "ExactIn", amountIn: "1000000000000000000", // 1 ETH in wei wallet: "0xYourWalletAddress", }); // Listen for the response socket.on("/evm/buy/quote", (response) => { if (response.success) { console.log("Price:", response.result.price); console.log("Expected output:", response.result.expectedAmountOut); console.log("Price impact:", response.result.priceImpact); } else { console.error("Error:", response.error.message); } }); ``` ```python Python theme={null} @sio.on("/evm/buy/quote") def on_quote(response): if response.get("success"): result = response["result"] print(f"Price: {result['price']}") print(f"Expected output: {result['expectedAmountOut']}") print(f"Price impact: {result['priceImpact']}") else: print(f"Error: {response['error']['message']}") sio.emit("/evm/buy/quote", { "chain": "eth", "token": "0x6982508145454Ce325dDbE47a25d4ec3d2311933", "swapMode": "ExactIn", "amountIn": "1000000000000000000", "wallet": "0xYourWalletAddress" }) ``` ```typescript TypeScript theme={null} const res = await fetch(`${CHAINWORKS_API_URL}/evm/buy/quote`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "eth", token: "0x6982508145454Ce325dDbE47a25d4ec3d2311933", // PEPE swapMode: "ExactIn", amountIn: "1000000000000000000", // 1 ETH in wei wallet: "0xYourWalletAddress", }), }); const response = await res.json(); if (response.success) { console.log("Price:", response.result.price); console.log("Expected output:", response.result.expectedAmountOut); console.log("Price impact:", response.result.priceImpact); } else { console.error("Error:", response.error.message); } ``` ```python Python theme={null} import requests res = requests.post( f"{CHAINWORKS_API_URL}/evm/buy/quote", headers={"Authorization": CHAINWORKS_API_AUTH_TOKEN}, json={ "chain": "eth", "token": "0x6982508145454Ce325dDbE47a25d4ec3d2311933", "swapMode": "ExactIn", "amountIn": "1000000000000000000", "wallet": "0xYourWalletAddress", }, ) response = res.json() if response.get("success"): result = response["result"] print(f"Price: {result['price']}") print(f"Expected output: {result['expectedAmountOut']}") print(f"Price impact: {result['priceImpact']}") else: print(f"Error: {response['error']['message']}") ``` ## Response Format Both transports return the same response shape: ### Success Response ```json theme={null} { "success": true, "result": { // Response data specific to the endpoint } } ``` ### Error Response ```json theme={null} { "success": false, "error": { "code": "ERROR_CODE", "message": "Human-readable error description" }, "partialResult": { // Optional helpful data even when request fails } } ``` ## Next Steps * [Authentication](/authentication) - Learn about token authentication * [EVM Endpoints](/evm/overview) - Explore Ethereum, Base, and BSC endpoints * [SVM Endpoints](/svm/overview) - Explore Solana endpoints * [Playground](https://chainworks.co/playground) - Test the API interactively # SVM Transaction Fees & Send Routes Source: https://docs.chainworks.co/svm/fees-and-routes Inspect route options and fee breakdowns for Solana swaps before submitting them. ## Fee Parameters Solana transactions support two types of fees: ### Priority Fees (`prioFees`) Priority fees are paid to validators to prioritize your transaction in the block. | Property | Type | Default | Description | | ---------- | ------ | ------- | ------------------------------------------ | | `prioFees` | string | `"0"` | Amount in lamports to pay as priority fees | **Example:** ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", prioFees: "100000", // 0.0001 SOL in lamports }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", prioFees: "100000", // 0.0001 SOL in lamports }), }); ``` **Notes:** * Higher priority fees increase the likelihood of faster inclusion * Paid regardless of transaction success or failure * Optional - defaults to `"0"` if not specified ### Bribe Fees (`bribeFees`) Bribe fees (also called MEV tips) are paid to MEV protection providers (e.g., Jito) to include your transaction in their bundles. | Property | Type | Minimum | Description | | ----------- | ------ | ----------- | ------------------------------------------- | | `bribeFees` | string | `"1000000"` | Amount in lamports to pay as bribe/tip fees | **Example:** ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Antimev", prioFees: "100000", bribeFees: "1000000", // 0.001 SOL (minimum) }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Antimev", prioFees: "100000", bribeFees: "1000000", // 0.001 SOL (minimum) }), }); ``` **Notes:** * Required for `PublicWithNonce`, `Antimev`, and `AntimevWithNonce` routes * Minimum value is **1,000,000 lamports** (0.001 SOL) * Provides MEV protection by routing through specialized providers * Only paid if the transaction lands successfully (for revert-protected routes) ## Send Routes The `sendRoute` parameter determines how your transaction is submitted to the network. | Route | Default | Requires bribeFees | Requires nonceAccount | Description | | ------------------ | ------- | ------------------ | --------------------- | --------------------------------------------- | | `Public` | ✅ Yes | ❌ No | ❌ No | Standard RPC submission only | | `PublicWithNonce` | ❌ No | ✅ Yes | ✅ Yes | RPC + all MEV providers with tip | | `Antimev` | ❌ No | ✅ Yes | ❌ No | Revert-protected MEV providers only | | `AntimevWithNonce` | ❌ No | ✅ Yes | ✅ Yes | All MEV providers (revert-protected + others) | The routes that require a `nonceAccount` need a durable nonce account you own. Build one with [Create Nonce Account Transaction](/svm/transactions#create-nonce-account-transaction), sign it, and submit it before using its address here. ### `Public` (Default) The simplest route - sends your transaction through the standard public RPC only. ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Public", prioFees: "100000", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Public", prioFees: "100000", }), }); ``` ### `PublicWithNonce` Sends through both public RPC and all MEV providers with a tip. ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "PublicWithNonce", prioFees: "100000", bribeFees: "1000000", nonceAccount: "YourNonceAccountPublicKey", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "PublicWithNonce", prioFees: "100000", bribeFees: "1000000", nonceAccount: "YourNonceAccountPublicKey", }), }); ``` ### `Antimev` Sends exclusively through revert-protected MEV providers (e.g., Jito bundles). ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Antimev", prioFees: "100000", bribeFees: "1000000", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "Antimev", prioFees: "100000", bribeFees: "1000000", }), }); ``` **Best for:** High-value swaps where you want MEV protection and bribe fees only paid on success. ### `AntimevWithNonce` Sends through all MEV providers (both revert-protected and non-revert-protected). ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "AntimevWithNonce", prioFees: "100000", bribeFees: "1000000", nonceAccount: "YourNonceAccountPublicKey", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", sendRoute: "AntimevWithNonce", prioFees: "100000", bribeFees: "1000000", nonceAccount: "YourNonceAccountPublicKey", }), }); ``` **Best for:** Maximizing MEV protection coverage across all providers. # SVM Endpoints Source: https://docs.chainworks.co/svm/overview Solana API endpoints for quotes, transactions, transfers, wallet data, token info, fees, and price subscriptions. Complete API reference for Solana (SVM). *** ## Supported Chains | Chain | Identifier | Native Token | | ------ | ---------- | ------------ | | Solana | `sol` | SOL | *** ## Supported DEXes The API automatically routes through the best available DEX: | DEX | Type | Description | | ----------------------------------- | ------------- | ------------------------------- | | RaydiumV4 | AMM | Classic Raydium pools | | RaydiumCLMM | CLMM | Concentrated liquidity | | RaydiumCPMM | CPMM | Constant product | | RaydiumLaunchLab | Launchpad | New token launches | | PumpFun | Bonding Curve | Meme token launches | | PumpSwap | AMM | PumpFun graduated tokens | | MeteoraDLMM | DLMM | Dynamic liquidity | | Meteora DYN | AMM | Dynamic fee AMM pools | | Meteora DYN2 | AMM | Enhanced dynamic pools | | Meteora Dynamic Bonding Curve (DBC) | Bonding Curve | Meteora token launches | | Whirlpool | CLMM | Orca concentrated liquidity | | MetaplexGenesis | Bonding Curve | Metaplex bonding curve launches | | Humi | Bonding Curve | Bonding curve virtual pools | | FluxBeam | AMM | FluxBeam pools | *** ## Endpoints * **[Quotes](/svm/quotes)** - Get buy/sell price quotes * **[Transactions](/svm/transactions)** - Build unsigned swap transactions * **[Transfers](/svm/transfers)** - SOL, token, and multi-transfers * **[Wallet](/svm/wallet)** - Query SOL and token balances * **[Token Info](/svm/token-info)** - Token metadata and reports * **[Fees & Routes](/svm/fees-and-routes)** - Priority fees, bribe fees, and send routes * **[Send Transaction](/svm/send-transaction)** - Broadcast signed transactions * **[Price Subscriptions](/svm/price-subscriptions)** - Real-time token price update streams # SVM Price Subscriptions Source: https://docs.chainworks.co/svm/price-subscriptions Subscribe to real-time Solana token price updates over the WebSocket connection. Subscribe to real-time price updates for Solana tokens. When a subscribed token's price changes, you receive a `priceUpdate` event on your Socket.IO connection with the latest price from the highest-liquidity pool. > **Live updates are Socket.IO only.** You can manage subscriptions (subscribe, unsubscribe, list active) over either transport, but `priceUpdate` and `subscriptionExpiring` events are pushed only over a Socket.IO connection. Over HTTP, the subscribe/unsubscribe/active endpoints just register and query subscriptions; they do not deliver price updates. To receive live prices you must be connected via Socket.IO. *** ## Subscription Limits Maximum active subscriptions per tier: | Tier | Max Subscriptions | | ---------- | ----------------- | | Free | 0 | | Basic | 10 | | Premium | 100 | | Enterprise | 1,000 | *** ## Subscribe Subscribe to price updates for one or more tokens. **Endpoint:** `/svm/price/subscribe` | Parameter | Type | Required | Description | | --------- | --------- | -------- | -------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `tokens` | string\[] | Yes | Array of token mint addresses (min 1) | | `ttlMs` | number | No | Subscription duration in milliseconds. Max: 604,800,000 (7d), default: 21,600,000 (6h) | **Example:** ```typescript theme={null} socket.emit("/svm/price/subscribe", { chain: "sol", tokens: [ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "So11111111111111111111111111111111111111112", ], ttlMs: 21600000, // 6 hours }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/price/subscribe", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", tokens: [ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "So11111111111111111111111111111111111111112", ], ttlMs: 21600000, // 6 hours }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "subscribed": [ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "So11111111111111111111111111111111111111112" ] } } ``` Re-subscribing to an already-subscribed token refreshes its TTL without counting against the subscription limit. *** ## Unsubscribe Unsubscribe from price updates for one or more tokens. **Endpoint:** `/svm/price/unsubscribe` | Parameter | Type | Required | Description | | --------- | --------- | -------- | -------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `tokens` | string\[] | Yes | Array of token mint addresses to unsubscribe | **Example:** ```typescript theme={null} socket.emit("/svm/price/unsubscribe", { chain: "sol", tokens: ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"], }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/price/unsubscribe", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", tokens: ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"], }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "unsubscribed": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"] } } ``` *** ## Active Subscriptions List all active (non-expired) price subscriptions. **Endpoint:** `/svm/price/active_subscriptions` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ------------ | | `chain` | string | Yes | Always `sol` | **Example:** ```typescript theme={null} socket.emit("/svm/price/active_subscriptions", { chain: "sol", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/price/active_subscriptions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "tokens": [ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "So11111111111111111111111111111111111111112" ] } } ``` *** ## Price Update Event When a subscribed token's price changes, you receive a `priceUpdate` event. Updates are sourced from the highest-liquidity pool for the token and deduplicated so you only receive meaningful price changes. ```typescript theme={null} socket.on("priceUpdate", (data) => { console.log(data); }); ``` **Event payload:** ```json theme={null} { "chain": "sol", "token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "pool": { "type": "RaydiumV4", "lp": "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2", "backingToken": "So11111111111111111111111111111111111111112", "rawPrice": 0.000034, "priceUsd": 0.0051, "tokenReserve": "1000000000000", "backingReserve": "34000000" }, "slotNumber": 285000000, "timestamp": 1710979200 } ``` | Field | Type | Description | | --------------------- | ------ | ------------------------------------------------------ | | `chain` | string | Always `sol` | | `token` | string | Token mint address | | `pool.type` | string | DEX type (e.g. `RaydiumV4`, `PumpSwap`, `MeteoraDLMM`) | | `pool.lp` | string | Liquidity pool address | | `pool.backingToken` | string | Backing token mint (e.g. SOL or USDC) | | `pool.rawPrice` | number | Raw price ratio (token lamports / backing lamports) | | `pool.priceUsd` | number | Price of 1 full token in USD | | `pool.tokenReserve` | string | Token reserve amount in the pool | | `pool.backingReserve` | string | Backing token reserve amount in the pool | | `slotNumber` | number | Solana slot number of the update | | `timestamp` | number | Unix timestamp in seconds | *** ## Subscription Expiring Event You receive a `subscriptionExpiring` event shortly before a subscription expires, and again when it actually expires. Use this to re-subscribe if needed. ```typescript theme={null} socket.on("subscriptionExpiring", (data) => { console.log(data); }); ``` **Event payload:** ```json theme={null} { "chain": "sol", "token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "expiresAt": 1711065600, "expired": false } ``` | Field | Type | Description | | ----------- | ------- | ------------------------------------------------------- | | `chain` | string | Always `sol` | | `token` | string | Token mint address | | `expiresAt` | number | Unix timestamp (seconds) when the subscription expires | | `expired` | boolean | `false` when expiring soon, `true` when already expired | # SVM Quotes Source: https://docs.chainworks.co/svm/quotes Fetch buy and sell quotes for Solana token swaps without executing a transaction. Get price quotes for token swaps without executing transactions. ## Get Buy Quote Get a price quote for buying tokens with SOL. **Endpoint:** `/svm/buy/quote` | Parameter | Type | Required | Description | | ----------- | ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | | `swapMode` | string | Yes | `ExactIn` or `ExactOut` | | `amountIn` | string | Conditional | Amount of SOL in lamports. Required for `ExactIn` | | `amountOut` | string | Conditional | Amount of tokens. Required for `ExactOut` | | `wallet` | string | Yes | Wallet public key | | `pool` | string | No | When supplied, this parameter restricts quoting to the specified pool, subject to liquidity and compatibility requirements. | **Example:** ```typescript theme={null} socket.emit("/svm/buy/quote", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK swapMode: "ExactIn", amountIn: "1000000000", // 1 SOL in lamports wallet: "YourSolanaWalletPublicKey", pool: "PoolAddress", // Optional: specific pool address }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/quote", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK swapMode: "ExactIn", amountIn: "1000000000", // 1 SOL in lamports wallet: "YourSolanaWalletPublicKey", pool: "PoolAddress", // Optional: specific pool address }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "sol", "isBuy": true, "token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", "swapMode": "ExactIn", "dex": "RaydiumV4", "price": 0.00000156, "priceImpact": 0.0008, "amountIn": "1000000000", "expectedAmountOut": "641025641025641" } } ``` ## Get Sell Quote Get a price quote for selling tokens for SOL. **Endpoint:** `/svm/sell/quote` | Parameter | Type | Required | Description | | ---------- | ------ | ----------- | --------------------------------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | | `swapMode` | string | Yes | `ExactIn` or `ExactOut` | | `amountIn` | string | Conditional | Amount of tokens. Required for `ExactIn` | | `wallet` | string | Yes | Wallet public key | | `pool` | string | No | When supplied, this parameter restricts quoting to the specified pool, subject to liquidity and compatibility requirements. | # SVM Send Transaction Source: https://docs.chainworks.co/svm/send-transaction Submit signed Solana transactions through the Chainworks API for on-chain execution. Broadcast signed transactions to Solana. **Endpoint:** `/svm/send-transaction` > ⚠️ **Warning:** This endpoint sends real transactions to the blockchain. | Parameter | Type | Required | Description | | -------------------- | --------- | -------- | ------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `signedTransactions` | string\[] | Yes | Array of base64-encoded signed transactions | | `simulateBeforeSend` | boolean | No | Simulate before sending (default: true) | # SVM Token Information Source: https://docs.chainworks.co/svm/token-info Fetch token metadata, Token-2022 extensions, liquidity, and market data for Solana tokens. Look up on-chain token metadata and a fuller market report for Solana tokens. ## Get Token Metadata Returns name, symbol, decimals, total supply, and Token-2022 extension data when present. **Endpoint:** `/svm/token/meta` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ------------------ | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | **Example:** ```typescript theme={null} socket.emit("/svm/token/meta", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/token/meta", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "sol", "token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", "name": "Bonk", "symbol": "Bonk", "decimals": 5, "totalSupply": "88416809930247420", "slot": 318472901, "tokenType": "Token" } } ``` | Field | Type | Description | | -------------- | ------ | ----------------------------------------------------------------------------------------------- | | `chain` | string | Always `sol` | | `token` | string | Token mint address | | `name` | string | Token name. Empty string if no metadata is found | | `symbol` | string | Token ticker symbol. Empty string if no metadata is found | | `decimals` | number | Token decimals | | `totalSupply` | string | Total supply in raw units (decimals not applied) | | `slot` | number | Slot the metadata was read at | | `tokenType` | string | `Token` (SPL Token) or `Token2022` (Token-2022 program) | | `transferFee` | object | Token-2022 transfer fee extension. Present only on `Token2022` mints that enable it. See below | | `transferHook` | object | Token-2022 transfer hook extension. Present only on `Token2022` mints that enable it. See below | ### Token-2022 `transferFee` Present only when `tokenType` is `Token2022` and the mint has the transfer fee extension enabled. The object reports the currently effective fee schedule. ```json theme={null} { "transferFee": { "feeBps": 100, "maximumFee": "5000000000" } } ``` | Field | Type | Description | | ------------ | ------ | ------------------------------------------------------------------ | | `feeBps` | number | Transfer fee in basis points (100 = 1%, max 10000 = 100%) | | `maximumFee` | string | Maximum fee per transfer in raw token units (decimals not applied) | ### Token-2022 `transferHook` Present only when `tokenType` is `Token2022` and the mint has an active transfer hook. ```json theme={null} { "transferHook": { "authority": "HookAuthorityPublicKey", "programId": "HookProgramPublicKey", "extraAccountMetas": [ { "pubkey": "ExtraAccountPublicKey", "isSigner": false, "isWritable": true } ] } } ``` | Field | Type | Description | | -------------------------------- | --------- | --------------------------------------------------------------------- | | `authority` | string | Authority allowed to update the hook program | | `programId` | string | Transfer hook program address | | `extraAccountMetas` | object\[] | Extra accounts the hook program requires on a transfer. May be absent | | `extraAccountMetas[].pubkey` | string | Account address | | `extraAccountMetas[].isSigner` | boolean | Whether the account signs | | `extraAccountMetas[].isWritable` | boolean | Whether the account is writable | The request is rejected with `NOT_A_TOKEN` if the address is not found on chain or is not a valid token mint. *** ## Get Token Report Returns the token metadata plus market data and the token's liquidity pools. **Endpoint:** `/svm/token/report` | Parameter | Type | Required | Description | | --------- | ------ | -------- | ------------------ | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | **Example:** ```typescript theme={null} socket.emit("/svm/token/report", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/token/report", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK }), }); ``` **Response:** ```json theme={null} { "success": true, "result": { "chain": "sol", "token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", "name": "Bonk", "symbol": "Bonk", "decimals": 5, "totalSupply": "88416809930247420", "slot": 318472901, "tokenType": "Token", "marketCapUSD": 1284000000, "priceUSD": 0.00001452, "liquidity": { "deepestPool": { "type": "RaydiumV4", "lp": "8Qs4S2D7uQ4D9onb5N4hM9YtPGFCgvqB5jHPNSjxFM9k", "token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", "backingToken": "So11111111111111111111111111111111111111112", "rawPrice": 0.00000156, "tokenReserve": "412000000000000", "backingReserve": "642720000000", "isTokenBase": true }, "otherPools": [] } } } ``` The report carries every [Get Token Metadata](#get-token-metadata) field (including `transferFee` and `transferHook` on Token-2022 mints), plus: | Field | Type | Description | | ----------------------- | -------------- | ------------------------------------------------------------------------- | | `marketCapUSD` | number \| null | Estimated market cap in USD. `null` when no priced pool is available | | `priceUSD` | number \| null | Estimated price per token in USD. `null` when no priced pool is available | | `liquidity` | object \| null | Liquidity pools for the token. `null` when no pools are found | | `liquidity.deepestPool` | object | The pool with the most liquidity. See pool fields below | | `liquidity.otherPools` | object\[] | Remaining pools, deepest first. May be empty | ### Pool object Each pool in `deepestPool` and `otherPools` has these base fields: | Field | Type | Description | | ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `type` | string | DEX type. One of the [supported DEXes](/svm/overview) (`RaydiumV4`, `RaydiumCLMM`, `RaydiumCPMM`, `RaydiumLaunchLab`, `PumpFun`, `PumpSwap`, `MeteoraDLMM`, `MeteoraDYN`, `MeteoraDYN2`, `MeteoraDBC`, `Whirlpool`, `MetaplexGenesis`, `Humi`, `FluxBeam`) | | `lp` | string | Pool (liquidity pair) address | | `token` | string | The token mint this report is for | | `backingToken` | string | The paired backing token mint (for example wrapped SOL) | | `rawPrice` | number | Price of the token in raw backing-token units (decimals not applied) | | `tokenReserve` | string | Token reserve held by the pool, in raw units | | `backingReserve` | string | Backing-token reserve held by the pool, in raw units | | `isTokenBase` | boolean | Whether the token is the base side of the pair | Bonding-curve pools carry extra fields: | Field | Type | Description | | ------------------ | ------- | ----------------------------------------------------------------------------------------------------------- | | `bondingProgress` | number | Bonding curve progress. Present on `PumpFun`, `MetaplexGenesis`, `MeteoraDBC`, and `RaydiumLaunchLab` pools | | `completedBonding` | boolean | Whether the curve has completed bonding. Present on the same pool types as `bondingProgress` | | `configAddress` | string | Launchpad config address. Present on `MeteoraDBC` and `RaydiumLaunchLab` pools only | The request is rejected with `NOT_A_TOKEN` if the address is not found on chain or is not a valid token mint. When the token exists but liquidity or pricing cannot be resolved, the failure response may include a `partialResult` carrying the fields that were available. # SVM Transactions Source: https://docs.chainworks.co/svm/transactions Build and inspect Solana swap transactions through the Chainworks API. Build unsigned transactions for token swaps. ## Get Buy Transaction Build an unsigned transaction for buying tokens. **Endpoint:** `/svm/buy/transaction` | Parameter | Type | Required | Description | | -------------- | ------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | | `swapMode` | string | Yes | `ExactIn` or `ExactOut` | | `amountIn` | string | Yes | Amount of SOL in lamports | | `wallet` | string | Yes | Wallet public key | | `slippageBps` | number | No | Slippage tolerance (default: 100 = 1%) | | `feeBps` | number | No | Fee in basis points (0-175) | | `feeRecipient` | string | No | Wallet to receive fees | | `sendRoute` | string | No | `Public`, `PublicWithNonce`, `Antimev`, or `AntimevWithNonce` | | `prioFees` | string | No | Priority fees (see below) | | `bribeFees` | string | Based on sendRoute | bribe fees (see below) | | `nonceAccount` | string | Based on sendRoute | Nonce account for transaction exclusivity | | `pool` | string | No | When supplied, this parameter restricts quoting to the specified pool, subject to liquidity and compatibility requirements. | **Example:** ```typescript theme={null} socket.emit("/svm/buy/transaction", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", slippageBps: 100, prioFees: "100000", pool: "PoolAddress", // Optional: specific pool address }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/buy/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", swapMode: "ExactIn", amountIn: "1000000000", wallet: "YourSolanaWalletPublicKey", slippageBps: 100, prioFees: "100000", pool: "PoolAddress", // Optional: specific pool address }), }); ``` ## Get Sell Transaction **Endpoint:** `/svm/sell/transaction` Same parameters as buy transaction. ## Create Nonce Account Transaction Build an unsigned transaction that creates a durable nonce account. A nonce account is required by the `PublicWithNonce` and `AntimevWithNonce` send routes (see [Fees & Routes](/svm/fees-and-routes)). Sign the returned transaction and submit it with [Send Transaction](/svm/send-transaction), then pass the new account address as the `nonceAccount` on future requests. **Endpoint:** `/svm/nonce-account/create/transaction` | Parameter | Type | Required | Description | | -------------- | ------ | ------------------ | --------------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `wallet` | string | Yes | Public key that will own and fund the nonce account | | `sendRoute` | string | No | `Public`, `PublicWithNonce`, `Antimev`, or `AntimevWithNonce` (see [Fees & Routes](/svm/fees-and-routes)) | | `prioFees` | string | No | Priority fees in lamports | | `bribeFees` | string | Based on sendRoute | Bribe fees in lamports | | `nonceAccount` | string | Based on sendRoute | Existing nonce account, when the chosen route requires one | **Example:** ```typescript theme={null} socket.emit("/svm/nonce-account/create/transaction", { chain: "sol", wallet: "YourSolanaWalletPublicKey", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/nonce-account/create/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", wallet: "YourSolanaWalletPublicKey", }), }); ``` # SVM Transfers Source: https://docs.chainworks.co/svm/transfers Construct SOL and SPL token transfer transactions on Solana with Chainworks. Build transactions for SOL and token transfers. ## SOL Transfer Transfer SOL to another address. **Endpoint:** `/svm/transfer/transaction` | Parameter | Type | Required | Description | | -------------- | ------ | ------------------ | ------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `recipient` | string | Yes | Recipient public key | | `amount` | string | Yes | Amount in lamports | | `wallet` | string | Yes | Sender public key | | `sendRoute` | string | No | `Public`, `PublicWithNonce`, `Antimev`, or `AntimevWithNonce` | | `prioFees` | string | No | Priority fees (see below) | | `bribeFees` | string | Based on sendRoute | bribe fees (see below) | | `nonceAccount` | string | Based on sendRoute | Nonce account for transaction exclusivity | ## Token Transfer Transfer SPL tokens. **Endpoint:** `/svm/transfer/token/transaction` | Parameter | Type | Required | Description | | --------------------------------------- | ------- | ------------------ | ------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `token` | string | Yes | Token mint address | | `recipient` | string | Yes | Recipient public key | | `amount` | string | Yes | Amount in token decimals | | `wallet` | string | Yes | Sender public key | | `ensureRecipientAssociatedTokenAccount` | boolean | No | Create ATA if needed (default: true) | | `sendRoute` | string | No | `Public`, `PublicWithNonce`, `Antimev`, or `AntimevWithNonce` | | `prioFees` | string | No | Priority fees (see below) | | `bribeFees` | string | Based on sendRoute | bribe fees (see below) | | `nonceAccount` | string | Based on sendRoute | Nonce account for transaction exclusivity | ## Multi-Transfer Send SOL to multiple recipients in one transaction. **Endpoint:** `/svm/transfer/multi/transaction` ```typescript theme={null} socket.emit("/svm/transfer/multi/transaction", { chain: "sol", wallet: "YourSolanaWalletPublicKey", recipients: [ { address: "Recipient1PublicKey", amount: "100000000" }, { address: "Recipient2PublicKey", amount: "200000000" }, ], }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/transfer/multi/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", wallet: "YourSolanaWalletPublicKey", recipients: [ { address: "Recipient1PublicKey", amount: "100000000" }, { address: "Recipient2PublicKey", amount: "200000000" }, ], }), }); ``` ## Multi-Token Transfer Send an SPL token to multiple recipients in one transaction. **Endpoint:** `/svm/transfer/multi/token/transaction` | Parameter | Type | Required | Description | | ---------------------------------------------- | --------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | | `chain` | string | Yes | Always `sol` | | `wallet` | string | Yes | Sender public key | | `token` | string | Yes | Token mint address to transfer | | `recipients` | object\[] | Yes | Recipients to send to (see below) | | `defaultEnsureRecipientAssociatedTokenAccount` | boolean | No | Default for creating a recipient's associated token account when missing (default: false). Creating an account may incur \~0.002 SOL rent | | `sendRoute` | string | No | `Public`, `PublicWithNonce`, `Antimev`, or `AntimevWithNonce` | | `prioFees` | string | No | Priority fees in lamports | | `bribeFees` | string | Based on sendRoute | Bribe fees in lamports | | `nonceAccount` | string | Based on sendRoute | Nonce account for transaction exclusivity | Each entry in `recipients`: | Field | Type | Required | Description | | ------------------------------ | ------- | ----------- | ------------------------------------------------------------------------------------------------------------- | | `wallet` | string | Conditional | Recipient wallet address. Required unless `associatedTokenAccount` is given | | `associatedTokenAccount` | string | Conditional | Recipient associated token account. Defaults to the wallet's default account; required if `wallet` is omitted | | `amount` | string | Yes | Amount in raw token units (min 1) | | `ensureAssociatedTokenAccount` | boolean | No | Create the recipient account if missing. Defaults to `defaultEnsureRecipientAssociatedTokenAccount` | **Example:** ```typescript theme={null} socket.emit("/svm/transfer/multi/token/transaction", { chain: "sol", wallet: "YourSolanaWalletPublicKey", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK recipients: [ { wallet: "Recipient1PublicKey", amount: "100000000" }, { wallet: "Recipient2PublicKey", amount: "200000000" }, ], }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/transfer/multi/token/transaction", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", wallet: "YourSolanaWalletPublicKey", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK recipients: [ { wallet: "Recipient1PublicKey", amount: "100000000" }, { wallet: "Recipient2PublicKey", amount: "200000000" }, ], }), }); ``` # SVM Wallet Source: https://docs.chainworks.co/svm/wallet Retrieve Solana wallet balances and holdings across native SOL and SPL tokens. Query wallet balances. ## Get SOL Balance **Endpoint:** `/svm/wallet/balance` ```typescript theme={null} socket.emit("/svm/wallet/balance", { chain: "sol", wallet: "YourSolanaWalletPublicKey", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/wallet/balance", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", wallet: "YourSolanaWalletPublicKey", }), }); ``` ## Get Token Balance **Endpoint:** `/svm/wallet/balance/token` ```typescript theme={null} socket.emit("/svm/wallet/balance/token", { chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", wallet: "YourSolanaWalletPublicKey", }); ``` ```typescript theme={null} await fetch("https://api.chainworks.co/svm/wallet/balance/token", { method: "POST", headers: { "Content-Type": "application/json", Authorization: CHAINWORKS_API_AUTH_TOKEN, }, body: JSON.stringify({ chain: "sol", token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", wallet: "YourSolanaWalletPublicKey", }), }); ```