|
@@ -57,6 +57,21 @@ const transaction = await umi.rpc.getTransaction(signature);
|
|
|
|
|
|
|
|
Since transactions are an important component of Solana clients, we discuss them in more detail on the [Sending transactions](/umi/transactions) documentation page.
|
|
Since transactions are an important component of Solana clients, we discuss them in more detail on the [Sending transactions](/umi/transactions) documentation page.
|
|
|
|
|
|
|
|
|
|
+## Simulating transactions
|
|
|
|
|
+
|
|
|
|
|
+You can simulate transactions before sending them to test their behavior and estimate compute units. Umi provides enhanced simulation options:
|
|
|
|
|
+
|
|
|
|
|
+```ts
|
|
|
|
|
+// Basic transaction simulation
|
|
|
|
|
+const simulationResult = await umi.rpc.simulateTransaction(myTransaction);
|
|
|
|
|
+
|
|
|
|
|
+// Simulate with a replacement blockhash for more flexibility
|
|
|
|
|
+const simulationResult = await umi.rpc.simulateTransaction(myTransaction, {
|
|
|
|
|
+ replaceRecentBlockhash: true
|
|
|
|
|
+});
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+When using `replaceRecentBlockhash: true`, the simulator replaces the transaction’s recent blockhash with the latest one from the RPC for the simulation request only. It does not modify your original transaction or extend its on-chain validity. To actually extend validity, fetch a fresh blockhash and rebuild/re‑sign the transaction, or set the latest blockhash before sending. Using `replaceRecentBlockhash: true` during simulation is more convenient and can save an extra RPC call.
|
|
|
## Fetching accounts
|
|
## Fetching accounts
|
|
|
|
|
|
|
|
The following methods can be used to fetch accounts or check for their existence:
|
|
The following methods can be used to fetch accounts or check for their existence:
|