Transaction APIs

Developer friendly transaction APIs.

Parse Transaction Signature

This endpoint returns the parsed transaction details for a given txn signature.

GET /transaction/parsed

Query Params:

  • network: Solana blockchain environment (testnet/devnet/mainnet-beta)

  • txn_signature: Transaction signature

var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR_API_KEY>");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/transaction/parsed?network=mainnet-beta&txn_signature=3teBNmcLtXHWKFNWhkF8n4vJpyverF5njLK7xwyafydubNfUT8R9zZyEA8VkiUUAethwVavTJbPKCvhcfj8vN4AP", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Transaction History

Fetches a list of parsed transactions for an on-chain account. The response returns the transactions with the latest transactions first. The response can have results of a maximum of 100 transactions in 1 single API call.

GET /transaction/history

Query Params:

  • network: Solana blockchain environment (testnet/devnet/mainnet-beta)

  • account: account address

  • tx_num: (optional) How many transactions (maximum 100 transactions at a time) do you want to fetch

  • before_tx_signature: (optional) Tx signature before which X number of transactions will be fetched, in reverse order going back in time

  • until_tx_signature: (optional) Tx signature until which X number of transactions will be fetched, in reverse order going back in time

  • enable_raw: (optional) boolean to send raw data along with parsed information. Send 'true' from raw data

  • enable_events: (optional) boolean to send parsed anchor events along with parsed information.

  • commitment: (optional) confirmed (default) or finalized.

var myHeaders = new Headers();
myHeaders.append("x-api-key", "<API-KEY>");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch(
  "https://api.shyft.to/sol/v1/transaction/history?network=mainnet-beta&tx_num=2&account=Apeng15Pm8EjpAcaAXpNUxZjS2jMmGqikfs281Fz9hNj&enable_raw=true",
  requestOptions
)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Parse Multiple Transaction Signatures

Fetch parsed bulk transactions in a single call.

POST /transaction/parse_selected

Body params:

  • network: Solana blockchain environment (testnet/devnet/mainnet-beta)

  • transaction_signatures: array of strings) Selected transaction signatures (minimum 1 and maximum 100 transactions could be fetched)

  • enable_raw: (optional) boolean to send raw data along with parsed information. Send 'true' from raw data

  • enable_events: (optional) boolean to send parsed anchor events along with parsed information.

  • commitment: (optional) confirmed (default) or finalized.

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "YOUR_API_KEY");

var raw = JSON.stringify({
  "network": "mainnet-beta",
  "transaction_signatures": [
    "67BJFsmeLhpPWLonvXyi46dh4UszCHZCWecUznfAdGX2KGEJxxGCoTiKAixMgZsBJBGTUQsDNHf697BQLceRdfd9",
    "4NcmYNHKAdTFnm8y78wQoKMmGCedhTVFrWeHdEGYaThY4AYQ96fbeADY48B7XSgDz6RCZUDqnNPVWay34M18yXmg"
  ],
  "enable_raw": false,
  "enable_events": true
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/transaction/parse_selected", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Send Transaction

This API endpoint lets you submit your signed transaction into the Solana blockchain, via Shyft's dedicated RPC node, which reduces the risk of transaction drop to near 0.

API Working:

This endpoint can be used to submit transactions to blockchain using Shyft dedicated RPC nodes.

import { clusterApiUrl, Keypair, Transaction } from '@solana/web3.js';

async createSignedSerializedTxn(encodedTransaction: string, fromPrivateKey: string) : string {
  try {    
    const connection = new Connection(clusterApiUrl("devnet"), 'confirmed');
    const feePayer = Keypair.fromSecretKey(decode(fromPrivateKey));
    const recoveredTransaction = Transaction.from(Buffer.from(encodedTransaction, 'base64'));
   recoveredTransaction.partialSign(feePayer);

    // This is the way that signed transactions can be serialized in base64 format. Needed to make a successful API call.
    const txnToSendBackToShyft = recoveredTransaction.serialize().toString('base64');
    return txnToSendBackToShyft;
  } catch (error) {
    console.log(error);    
  }
}

NOTE: Above code snippet uses private keys for signing a txn, but a txn can be signed using wallet adapters as well. Please refer to this function for signing using wallet adapter (https://github.com/Shyft-to/community-projects/blob/f2552c5e809a517ac9820dda0008d06f1d9e0013/demo-hh/src/shyft.js#L23)

POST /transaction/send_txn

Body params:

  • network: string [mainnet-beta, devnet]

  • encoded_transaction: string - Base64 encoded and signed transaction string.

var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR_API_KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "network": "devnet",
  "encoded_transaction": "AVmMGj3kZrTdbQ+nFT55d59kaNkGvakYRJJ1ZFlyoSkIZSGNmjM2nAd+5YPj1kJh7uVCS+4kpZoy1X8f/k5dSAIBAAIFoml4osSZRwXqi2onReASLw930fViKFqc8clj9mwcrHlnmECCqlsIMcbFpqlapSWdgN1oYDA1x0VtmheYQvu7gc4uKRKiVfHE4b4WyDLcyJDaRxpH/74SupaQfQnHam2RBUpTWpkpIQZNJOhxYNo4fHw1td28kruB5B+oQEEFRI0G3fbh12Whk9nL4UbO63msHLSF7V9bN5E6jPWFfv8AqXwrKau0iGDsINwwNq2yz3B2rQ48PACETYKxI6KT9uTnAgQDAQIACg4A5AtUAgAAAAkDAQAXU2h5ZnQgbWFrZXMgbGlmZSBlYXNpZXI="
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/transaction/send_txn", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Send Multiple Transactions

This API endpoint lets you send bulk transactions to Solana blockchain, via Shyft's dedicated RPC node, which reduces the risk of transaction drop to near 0.

POST /transaction/send_many_txns

Body params:

  • network: string - [mainnet-beta, devnet]

  • encoded_transactions: string - Array of base64 encoded and signed transaction strings (maximum 100).

  • commitment (optional): processed, confirmed, finalized. API returns after the desired commitment level is reached for all txs or they error out.

The response times may increase with commitment levels. System waits for the transactions to reach the required commitment level.

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "YOUR_API_KEY");

var raw = JSON.stringify({
  "network": "devnet",
  "encoded_transactions": [
    "ARfcRDj2D2q6Zib4/r9bBcDvONvJ9/lM+4834g2065NGTvQ5kEmIWepO1hTDV5oq6JYye75FJdIHBgk8TQrGcQwBAAEDGMqfUcVHHu2+lyU5gx9wU2rGxk2NoSXtodMSdev+DxVALAeVfwkorAqlrAeN8dOn8Jeu6H4u3ofHzGz4FntQPwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/RWzWr+bM4lKfgjl47HKiqsxT/Jwcg1qYDkOI9MxN5wBAgIAAQwCAAAAQEIPAAAAAAA=",
    "AT3owiHF0oxDqa0Mhqisawdq2sf0mb58TVe/REYwnFZOU1nB5uK9Fu9m/8z1ojVhHrZqdwvp22PXgzpvD0gKpwEBAAEDGMqfUcVHHu2+lyU5gx9wU2rGxk2NoSXtodMSdev+DxUsLagmF5c4a6vJhMr74YTUznxniMs9+z4QYlMJ1x2b+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoEdavLhXjxh1GQUyHcxHwCsR71IQrPe3nJ88rb7cqJUBAgIAAQ"
  ],
  "commitment": "finalized"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/transaction/send_many_txns", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Last updated