Skip to main content

Get Instructions

POST /api/v1/instructions returns raw Solana instructions instead of a complete transaction. Use this when you need to combine swap instructions with other logic in a single transaction.

When to use this instead of /swap

  • You need to create token accounts before the swap.
  • You want to add a memo instruction for tracking.
  • You need to close accounts after the swap.
  • You’re building a multi-action transaction (e.g., swap + stake in one tx).
  • You want full control over compute budget and priority fees.
If you just need a simple swap, use POST /swap instead.

Request

The request body is identical to /swap except there is no skipSimulation field (no transaction is built, so there’s nothing to simulate).
userWallet
string
required
User’s wallet address (signer).
inputMint
string
required
Input token mint address.
outputMint
string
required
Output token mint address.
amount
string
required
Amount in smallest token units.
swapMode
string
required
ExactIn or ExactOut.
slippageBps
integer
default:"50"
Slippage tolerance in basis points.

Example

curl -X POST "https://api.argyros.xyz/api/v1/instructions" \
  -H "Content-Type: application/json" \
  -d '{
    "userWallet": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000",
    "swapMode": "ExactIn",
    "slippageBps": 50
  }'

Response

{
  "success": true,
  "data": {
    "amountIn": "1000000000",
    "amountOut": "145320000",
    "otherAmountThreshold": "144593400",
    "feeAmount": "100005",
    "route": [
      "So11111111111111111111111111111111111111112",
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    ],
    "hopCount": 1,
    "pools": ["HJPjoWUrhoZzkNfRpHuieeFk9WcZWjwy6PBjZ81ngndJ"],
    "instructions": [
      {
        "programId": "vnt1u7PzorND5JjweFWmDawKe2hLWoTwHU6QKz6XX98",
        "data": "AQAAAA...",
        "accounts": [
          { "publicKey": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM", "isSigner": true, "isWritable": true },
          { "publicKey": "HJPjoWUrhoZzkNfRpHuieeFk9WcZWjwy6PBjZ81ngndJ", "isSigner": false, "isWritable": true }
        ]
      }
    ],
    "addressLookupTableAddresses": [
      "AddressLookupTab1e1111111111111111111111111"
    ]
  }
}

Response fields

amountIn
string
Input amount in smallest units.
amountOut
string
Estimated output amount.
otherAmountThreshold
string
Slippage-adjusted threshold. ExactIn: minimum output. ExactOut: maximum input.
feeAmount
string
Aggregator fee in output token units.
route
string[]
Token path from input to output.
hopCount
integer
Number of swap hops.
pools
string[]
Pool addresses used.
instructions
RawInstruction[]
Ordered list of instructions to include in the transaction.
addressLookupTableAddresses
string[]
Address Lookup Table (ALT) addresses. Include these when building a v0 transaction to reduce transaction size.

Building a transaction from instructions

TypeScript
import {
  Connection,
  TransactionMessage,
  VersionedTransaction,
  PublicKey,
  AddressLookupTableAccount,
} from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");

// 1. Fetch address lookup tables
const altAccounts: AddressLookupTableAccount[] = [];
for (const altAddress of data.addressLookupTableAddresses) {
  const altAccount = await connection.getAddressLookupTable(new PublicKey(altAddress));
  if (altAccount.value) altAccounts.push(altAccount.value);
}

// 2. Convert raw instructions to TransactionInstruction
const instructions = data.instructions.map((ix) => ({
  programId: new PublicKey(ix.programId),
  keys: ix.accounts.map((acc) => ({
    pubkey: new PublicKey(acc.publicKey),
    isSigner: acc.isSigner,
    isWritable: acc.isWritable,
  })),
  data: Buffer.from(ix.data, "base64"),
}));

// 3. Build v0 transaction
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();

const messageV0 = new TransactionMessage({
  payerKey: wallet.publicKey,
  recentBlockhash: blockhash,
  instructions,
}).compileToV0Message(altAccounts);

const transaction = new VersionedTransaction(messageV0);
transaction.sign([wallet]);

// 4. Submit
const signature = await connection.sendRawTransaction(transaction.serialize());
await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight });
Always include the addressLookupTableAddresses when building a v0 transaction. Without them, the transaction may exceed the size limit for multi-hop routes.