You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sdk-and-tools/rest-api/transactions.mdx
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,7 +347,16 @@ Example response for cross-shard transactions:
347
347
348
348
`https://gateway.multiversx.com/transaction/cost`
349
349
350
-
This endpoint allows one to estimate the cost of a transaction.
350
+
351
+
:::note
352
+
This endpoint estimates the **gas cost** of a transaction. Use this value to determine the appropriate `gasLimit` before sending a transaction.
353
+
354
+
In the background, this endpoint simulates the transaction in a read-only environment to estimate its gas cost. Any resulting smart contract results and events will also be returned.
355
+
:::
356
+
357
+
:::warning
358
+
As the transaction is executed in a simulated environment, `providing the correct nonce is mandatory`.
359
+
:::
351
360
352
361
<Tabs
353
362
defaultValue="Request"
@@ -364,10 +373,12 @@ Body Parameters
364
373
| value | <spanclass="text-danger">REQUIRED</span> |`string`| The Value to transfer, as a string representation of a Big Integer (can be "0"). |
365
374
| receiver | <spanclass="text-danger">REQUIRED</span> |`string`| The Address (bech32) of the Receiver. |
366
375
| sender | <spanclass="text-danger">REQUIRED</span> |`string`| The Address (bech32) of the Sender. |
367
-
| data | <spanclass="text-normal">OPTIONAL</span> |`string`| The base64 string representation of the Transaction's message (data). |
368
376
| chainID | <spanclass="text-danger">REQUIRED</span> |`string`| The Chain identifier. |
369
377
| version | <spanclass="text-danger">REQUIRED</span> |`number`| The Version of the Transaction (e.g. 1). |
370
-
| nonce | <spanclass="text-normal">OPTIONAL</span> |`number`| The Sender nonce. |
378
+
| nonce | <spanclass="text-danger">REQUIRED</span> |`number`| The Sender nonce. |
379
+
| options | <spanclass="text-normal">OPTIONAL</span> |`number`| The Options of the Transaction (e.g. 1). |
380
+
| data | <spanclass="text-normal">OPTIONAL</span> |`string`| The base64 string representation of the Transaction's message (data). |
381
+
371
382
372
383
</TabItem>
373
384
<TabItemvalue="Response">
@@ -390,7 +401,12 @@ The cost is estimated successfully.
390
401
</Tabs>
391
402
392
403
:::tip
393
-
This endpoint returns the cost on the transaction in **gas units**. The returned value can be used to fill in **gasLimit** field of the transaction.
404
+
- Use the returned `txGasUnits` value as the `gasLimit` in your actual transaction.
405
+
- Make sure to provide the correct `nonce` of transaction
406
+
:::
407
+
408
+
:::tip
409
+
`Best practice:` when sending the transaction, add ~10% extra gas to the estimated value to avoid underestimation and failure due to insufficient gas.
0 commit comments