浏览代码

add new helper docs (#393)

* add new helper docs

* comments

* Update src/pages/umi/rpc.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
MarkSackerberg 2 月之前
父节点
当前提交
71eb35dc50
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 2 1
      src/pages/umi/helpers.md
  2. 15 0
      src/pages/umi/rpc.md

+ 2 - 1
src/pages/umi/helpers.md

@@ -25,10 +25,11 @@ type Amount<
 };
 ```
 
-Umi also provides specific versions of this `Amount` type for specific cases like SOLs and USDs.
+Umi also provides specific versions of this `Amount` type for specific cases like SOLs, micro SOLs, and USDs.
 
 ```ts
 type SolAmount = Amount<'SOL', 9>;
+type MicroSolAmount = Amount<'uSOL', 15>;
 type UsdAmount = Amount<'USD', 2>;
 type PercentAmount<D extends AmountDecimals> = Amount<'%', D>;
 ```

+ 15 - 0
src/pages/umi/rpc.md

@@ -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.
 
+## 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
 
 The following methods can be used to fetch accounts or check for their existence: