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);{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.3.3",
"slot": 393226680
},
"value": {
"accounts": null,
"err": null,
"innerInstructions": null,
"loadedAccountsDataSize": 413,
"logs": [
"Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb invoke [1]",
"Program log: Instruction: Transfer",
"Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb consumed 1714 of 200000 compute units",
"Program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb success"
],
"replacementBlockhash": {
"blockhash": "6oFLsE7kmgJx9PjR4R63VRNtpAVJ648gCTr3nq5Hihit",
"lastValidBlockHeight": 381186895
},
"returnData": null,
"unitsConsumed": 1714
}
},
"id": 1
}Last updated
Was this helpful?