simulateTransaction
All the specifications for simulateTransaction RPC Method on Solana
Simulate sending a transaction.
Parameters required for this RPC call
Transaction, as an encoded string.
The amount of lamports to airdrop
configuration object: This contains the following parameters. All optional.
encoding: Encoding used for the transaction data. Values:
base58(slow, DEPRECATED), orbase64.commitment: Commitment level to simulate the transaction at. See Configuring State Commitment. Default
finalized.replaceRecentBlockhash: If
truethe transaction recent blockhash will be replaced with the most recent blockhash (conflicts withsigVerify)sigVerify: If
truethe transaction signatures will be verified (conflicts withreplaceRecentBlockhash)innerInstructions: If
truethe response will include inner instructions. These inner instructions will bejsonParsedwhere possible, otherwisejson.accounts: If
truethe response will include inner instructions. These inner instructions will bejsonParsedwhere possible, otherwisejson.minContextSlot: Set the minimum slot at which to perform preflight transaction checks.
curl https://rpc.shyft.to?api_key=YOUR-API-KEY -s -X \
POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "simulateTransaction",
"params": [
"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEEjNmKiZGiOtSZ+g0//wH5kEQo3+UzictY+KlLV8hjXcs44M/Xnr+1SlZsqS6cFMQc46yj9PIsxqkycxJmXT+veJjIvefX4nhY9rY+B5qreeqTHu4mG6Xtxr5udn4MN8PnBt324e51j94YQl285GzN2rYa/E2DuQ0n/r35KNihi/zamQ6EeyeeVDvPVgUO2W3Lgt9hT+CfyqHvIa11egFPCgEDAwIBAAkDZAAAAAAAAAA=",
{
"commitment": "confirmed",
"encoding": "base64",
"replaceRecentBlockhash": true
}
]
}
'import {
Connection,
VersionedTransaction,
clusterApiUrl,
type SimulateTransactionConfig,
} from "@solana/web3.js";
const connection = new Connection("https://rpc.shyft.to?api_key=YOUR-API-KEY", "confirmed");
const base64Tx =
"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEEjNmKiZGiOtSZ+g0//wH5kEQo3+UzictY+KlLV8hjXcs44M/Xnr+1SlZsqS6cFMQc46yj9PIsxqkycxJmXT+veJjIvefX4nhY9rY+B5qreeqTHu4mG6Xtxr5udn4MN8PnBt324e51j94YQl285GzN2rYa/E2DuQ0n/r35KNihi/zamQ6EeyeeVDvPVgUO2W3Lgt9hT+CfyqHvIa11egFPCgEDAwIBAAkDZAAAAAAAAAA=";
let tx = VersionedTransaction.deserialize(Buffer.from(base64Tx, "base64"));
let simulateTxConfig: SimulateTransactionConfig = {
commitment: "finalized",
replaceRecentBlockhash: true,
sigVerify: false,
minContextSlot: undefined,
innerInstructions: undefined,
accounts: undefined,
};
let simulateResult = await connection.simulateTransaction(tx, simulateTxConfig);
console.log(simulateResult);Last updated
Was this helpful?