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 | Yes | Slippage tolerance in basis points. Integer, 0-10000 (100 = 1%) |
feeBps | number | Yes | Fee in basis points (0-175) |
feeRecipient | string | Yes | 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. |
transactionVersion | string | No | Transaction message format: v0 or v1 (default: v0) |
maxAccounts | number | No | Target for the number of distinct accounts the swap instruction locks. Integer, min: 16, values above 64 are treated as 64. Check accountsCount for the result |
- Socket.IO
- HTTP
socket.emit(
"/svm/buy/transaction",
{
chain: "sol",
token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
swapMode: "ExactIn",
amountIn: "1000000000",
wallet: "YourSolanaWalletPublicKey",
slippageBps: 100,
feeBps: 0,
feeRecipient: "YourFeeRecipientPublicKey",
prioFees: "100000",
pool: "PoolAddress", // Optional: specific pool address
},
(response) => {
console.log(response);
}
);
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,
feeBps: 0,
feeRecipient: "YourFeeRecipientPublicKey",
prioFees: "100000",
pool: "PoolAddress", // Optional: specific pool address
}),
});
{
"success": true,
"result": {
"quote": {
"chain": "sol",
"swapMode": "ExactIn",
"isBuy": true,
"token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"amountIn": "0x3b9aca00",
"expectedAmountOut": "0x2470269a01069",
"price": 0.00000156,
"priceImpact": 0.0008,
"pool": {
"type": "RaydiumV4",
"lp": "8Qs4S2D7uQ4D9onb5N4hM9YtPGFCgvqB5jHPNSjxFM9k",
"token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"backingToken": "So11111111111111111111111111111111111111112",
"rawPrice": 0.00000156,
"tokenReserve": "0x176b639a5c000",
"backingReserve": "0x95a518e800",
"isTokenBase": true
},
"intermediatePools": [],
"baseToken": "So11111111111111111111111111111111111111112"
},
"instructions": [
{
"data": {
"encoded": "KgAAAADKmjsAAAAAmT+qbe9wAgBkAA==",
"encoding": "base64"
},
"keys": [
{
"isSigner": true,
"isWritable": true,
"address": "YourSolanaWalletPublicKey"
},
{
"isSigner": false,
"isWritable": true,
"address": "8Qs4S2D7uQ4D9onb5N4hM9YtPGFCgvqB5jHPNSjxFM9k"
}
],
"programAddress": "ChainWorksznk6gZyzGHUAxVUNuc79wznbf3DGnVxgyh"
}
],
"minContextSlot": 318472901,
"recommendedLookupTable": "4TXEpkXYwERpCjj5V37YqwRg13MzioiHvgaWvkofKipa",
"swapLookupTables": [],
"accountsCount": 18,
"transactions": [
{
"routes": [
{
"id": "Public",
"name": "Public",
"isPrivate": false,
"hasRevertProtection": false
}
],
"expectedSigners": ["YourSolanaWalletPublicKey"],
"rawTransactionMessage": {
"encoded": "gAEAAgQN1e8xet/Iym45ebDddH1pVjSfF1C7OiY+qZ1S7f5fFm4exOgy7bkFFgejJtH2zAr8wHALwBVznFWOtu4qJchrrdXqlpheUuQx0Qv8bv/t+hKt1s/PjrSj5JiCOzuI4IwDBkZv5SEXMv/srbpyw5vnvIzlu8X3EmssQ5s6QAAAAMxJDpKM0uOHO7ND/JXaMxecpg9Nv0bCw26RKZ1V1Oa5AwMABQJADQMAAwAJAyChBwAAAAAAAgIAARYqAAAAAMqaOwAAAACZP6pt73ACAGQAATNeWjdQteTL0AHxzA7t8kbZZoiJmzfMNCS8VmfnmKO7AwABAgMDBAU=",
"encoding": "base64"
},
"meta": {
"version": 0,
"cuLimit": "0x30d40",
"cuPrice": "0x7a120",
"prioFees": "0x186a0",
"blockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N"
}
}
],
"recentBlockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N"
}
}
keys array is shortened in this example. Integer amounts are hex-encoded strings.
| Field | Type | Description |
|---|---|---|
quote | object | Quote the transaction was built from |
instructions | object[] | Swap instructions in the transaction |
minContextSlot | number | Slot the quote was read at. Pass it to Send Transaction. May be absent |
recommendedLookupTable | string | Address lookup table the transaction uses. Absent when transactionVersion is v1 |
swapLookupTables | string[] | Address lookup tables of the pools in the route. Absent when transactionVersion is v1 |
accountsCount | number | Number of distinct accounts the swap instruction locks. Can exceed maxAccounts |
accountReductions | string[] | Account groups left out to fit maxAccounts: pumpFeeRecipients, meteoraReferral, extraTickArrays, extraBinArrays. Present only when maxAccounts is sent |
transactions | object[] | Unsigned transactions to sign |
transactions[].routes | object[] | Send routes the transaction can be submitted through |
transactions[].expectedSigners | string[] | Public keys that must sign the transaction, in signing order |
transactions[].rawTransactionMessage.encoded | string | Transaction message to sign, base64-encoded |
transactions[].meta.version | number | 0 for a v0 transaction, 1 for v1 |
recentBlockhash | string | Blockhash the transactions were built with |
Get Sell Transaction
Endpoint:/svm/sell/transaction
Same parameters as buy transaction. amountIn is the amount of tokens to sell, in raw units.
Example:
- Socket.IO
- HTTP
socket.emit(
"/svm/sell/transaction",
{
chain: "sol",
token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK
swapMode: "ExactIn",
amountIn: "100000000000", // 1,000,000 BONK
wallet: "YourSolanaWalletPublicKey",
slippageBps: 100,
feeBps: 0,
feeRecipient: "YourFeeRecipientPublicKey",
prioFees: "100000",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/svm/sell/transaction", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "sol",
token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", // BONK
swapMode: "ExactIn",
amountIn: "100000000000", // 1,000,000 BONK
wallet: "YourSolanaWalletPublicKey",
slippageBps: 100,
feeBps: 0,
feeRecipient: "YourFeeRecipientPublicKey",
prioFees: "100000",
}),
});
quote.isBuy set to false.
Create Nonce Account Transaction
Build an unsigned transaction that creates a durable nonce account. A nonce account is required by thePublicWithNonce and AntimevWithNonce send routes (see Fees & Routes). Sign the returned transaction and submit it with 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) |
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 |
transactionVersion | string | No | Transaction message format: v0 or v1 (default: v0) |
- Socket.IO
- HTTP
socket.emit(
"/svm/nonce-account/create/transaction",
{
chain: "sol",
wallet: "YourSolanaWalletPublicKey",
},
(response) => {
console.log(response);
}
);
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",
}),
});

