simulateTransaction
Simulate sending a transaction

Parameters

  • <string> - Transaction, as an encoded string. The transaction must have a valid blockhash, but is not required to be signed.
  • <object> - (optional) Configuration object containing the following fields:
    • sigVerify: <bool> - if true the transaction signatures will be verified (default: false, conflicts with replaceRecentBlockhash)
    • commitment: <object> - (optional) Configures the commitment level of the blocks queried Accepts one of the following strings: ["finalized", "confirmed", "processed"] For more info, refer to this doc.
    • encoding: <string> - (optional) Encoding used for the transaction data. Either "base58" (slow, DEPRECATED), or "base64". (default: "base58").
    • replaceRecentBlockhash: <bool> - (optional) if true the transaction recent blockhash will be replaced with the most recent blockhash. (default: false, conflicts with sigVerify)
    • accounts: <object> - (optional) Accounts configuration object containing the following fields:
      • encoding: (optional) <string> - data encoding for each returned transaction
        Accepts one of the following strings: ["base64" (default), "base64+zstd" or "jsonParsed"] "jsonParsed" encoding attempts to use program-specific parsers to make the transaction.message.instructions list more human-readable; if a parser cannot be found, the instruction falls back to default JSON.
      • addresses: <array of base-58 encoded strings> - An array of accounts to return
    • minContextSlot: (optional) <number> - set the minimum slot that the request can be evaluated at.

Results

Tx Success
  • error: <object | string | null> - Error if transaction failed, null if transaction succeeded
  • logs: <array | null> - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure)
  • accounts: <array> | null> - array of accounts with the same length as the accounts.addresses array in the request
    • <null> - if the account doesn't exist or if err is not null
    • <object> - otherwise, a JSON object containing:
      • lamports: <u64>, number of lamports assigned to this account
      • owner: <base-58 encoded string>, Pubkey of the program this account has been assigned to
      • data: <[string, encoding]|object>, data associated with the account, either as encoded binary data or JSON format {<program>: <state>}, depending on encoding parameter
      • executable: <bool>, boolean indicating if the account contains a program (and is strictly read-only)
      • rentEpoch: <u64>, the epoch at which this account will next owe rent
  • unitsConsumed: <u64 | undefined>, The number of compute budget units consumed during the processing of this transaction

Example

Request

cURL
1
curl --location --request POST 'https://solana-mainnet.g.alchemy.com/v2/alch-demo/' \
2
--header 'Content-Type: application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oeUJaZHBQMiIsCiAgICB0cmFuc2Zlcl9hdXRob3JpdHk6ICJwTWludFRaNUNFa0hVaGdydXJQZ29pTW50b0xnRndic0tkYnFOclhzcmR5IiwKICAgIGFjdGl2aXR5OiAxLCAKICAgIHBheV9wZXJpb2Q6IDYwNDgwMC4wMDAwMDAsIAogICAgcGF5X3JhdGU6IDguMDAwMDAwLAogICAgdGltZXN0YW1wOiAxNjU1MTg0ODYwLAogICAgbXVsdGlwbGllcjogMS4wLAogICAgbWF4X3BheW91dDogMTYuMDAwMDAwKQ==",
8
{
9
"encoding": "base64",
10
"commitment": "recent",
11
"sigVerify": false,
12
"accounts": {
13
"addresses": [
14
"9zyLN5CQwxWrEPit1sFy5DZ5xMqJfNQTLiqBVSfvPvWY",
15
"GtFMtrW31RdCeSdW4ot3jNVuoLtFywJGGTiF1Q8Uopky",
16
"pMintTZ5CEkHUhgrurPgoiMntoLgFwbsKdbqNrXsrdy",
17
"3d8SpnZntmGKtvUmhuak7KSu6XT7AUMinuUDma5hmiBX",
18
"9P68kbvW9KzPHsZTFq4yQrRVkYsf5CQFg9hVhyBZdpP2",
19
"BB7pctPeVCQPjXMGdkDX9ADT995gXCVLyHJUygpJPN2x",
20
"pSTAkE7Z2guBmSheg6tHdHk3rT1wmF1Mfuf52tnWeAd",
21
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
22
]
23
}
24
}
25
],
26
"id": "ea57afc0-7db8-4aa3-8ddb-a28c6099153c"
27
}'
Copied!

Response

1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"context": {
5
"slot": 137569919
6
},
7
"value": {
8
"accounts": [
9
null,
10
null,
11
null,
12
null,
13
null,
14
null,
15
null,
16
null
17
],
18
"err": "BlockhashNotFound",
19
"logs": [],
20
"unitsConsumed": 0
21
}
22
},
23
"id": "ea57afc0-7db8-4aa3-8ddb-a28c6099153c"
24
}
Copied!