Skip to content

Submit the transaction

The SDK submits the signed transaction along with the submission token, then waits for confirmation. The server validates the signature and broadcasts to Solana via priority lanes for fastest block inclusion.

After signing your transaction, you submit it along with the submissionToken from the build step. The server validates everything and broadcasts to Solana.

POST /v1/tx/submit
{
"submissionToken": "txn_173_abcd1234ef567890",
"signedTransaction": "BASE64_WIRE_SIGNED_TRANSACTION"
}

When you submit a transaction:

  1. Message validation: The server verifies that the signed transaction’s message bytes match the originally-built transaction. This prevents tampering.
  2. Priority submission: The transaction is broadcast to Solana with priority fee optimization for fast inclusion.
  3. Confirmation waiting: The server waits for the transaction to reach “confirmed” status on-chain.
  4. Result parsing: Trade amounts and other details are extracted from the confirmed transaction.
  • signature: The transaction signature - use this to view on Solscan or other block explorers
  • status: Should be "confirmed"
  • tradeResult: Actual on-chain input/output amounts (may be null if parsing wasn’t available in time)
  • estimates: Fallback if tradeResult is null

For complete API reference, see: POST /v1/tx/submit.

import axios from 'axios';
const API_KEY = 'api_your_key_here';
const API_BASE_URL = 'https://api.darkfibre.dev/v1';
const api = axios.create({
baseURL: API_BASE_URL,
headers: { 'Authorization': `Bearer ${API_KEY}` },
timeout: 30000,
});
async function submitTransaction(
submissionToken: string,
signedTransaction: string
) {
const response = await api.post('/tx/submit', {
submissionToken,
signedTransaction,
});
const { signature, status, tradeResult, priorityCost } = response.data.data;
console.log('Transaction signature:', signature);
console.log('Status:', status);
console.log('Solscan:', `https://solscan.io/tx/${signature}`);
if (tradeResult) {
console.log('Input amount:', tradeResult.inputAmount);
console.log('Output amount:', tradeResult.outputAmount);
}
return response.data.data;
}
// Example usage (after building and signing)
const submissionToken = 'txn_173_abcd1234ef567890';
const signedTransaction = 'BASE64_WIRE_SIGNED_TRANSACTION';
submitTransaction(submissionToken, signedTransaction)
.catch(console.error);