Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
API: Update simulateTransaction RPC method to include fee support
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio authored May 22, 2023
1 parent a58290d commit b50faf3
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions api/methods/simulateTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 8
---

Submit a trial contract invocation to get back return values, expected ledger footprint, and expected costs.
Submit a trial contract invocation to get back return values, expected transaction data, expected costs and recommended minimum transaction fee due to resource usage.

## Parameters

Expand All @@ -11,14 +11,15 @@ Submit a trial contract invocation to get back return values, expected ledger fo
## Returns

- `<object>`
- `cost`: `<object>` - Information about the fees expected, instructions used, etc.
- `minResourceFee`: `<string>` - Stringified-number of the recommended minimum resource fee to add when submitting the transaction. This fee is to be added on top of the [Stellar network fee](https://developers.stellar.org/docs/encyclopedia/fees-surge-pricing-fee-strategies#network-fees-on-stellar).
- `cost`: `<object>` - Information about instructions used, etc.
- `cpuInsns`: `<string>` - Stringified-number of the total cpu instructions consumed by this transaction
- `memBytes`: `<string>` - Stringified-number of the total memory bytes allocated by this transaction
- `results`: `<object[]>` - If error is present then results will not be in the response. There will be one results object for each operation in the transaction.
- `xdr`: `<xdr.ScVal>` - (optional) Only present on success. xdr-encoded return value of the contract call operation.
- `footprint`: `<xdr.LedgerFootprint>` - The contract data ledger keys which were accessed when simulating this operation. (serialized in a base64 string)
- `auth`: `<xdr.ContractAuth[]>` - Per-address authorizations recorded when simulating this operation. (an array of serialized base64 strings)
- `events`: `<xdr.DiagnosticEvent[]>` - Events emitted during the contract invocation. (an array of serialized base64 strings)
- `results`: `<object[]>` - If error is present then results will not be in the response. There will be one results object for each Host Function invocation in the transaction.
- `xdr`: `<xdr.ScVal>` - (optional) Only present on success. xdr-encoded return value of the Host Function call.
- `auth`: `<xdr.ContractAuth[]>` - Per-address authorizations recorded when simulating this Host Function call. (an array of serialized base64 strings)
- `transactionData`: `<xdr.SorobanTransactionData>` - The Soroban Transaction Data used when simulating this operation. (serialized in a base64 string).
- `events`: `<xdr.DiagnosticEvent[]>` - Events emitted during the all the contract invocation(s). (an array of serialized base64 strings)
- `latestLedger`: `<string>` - Stringified-number of the current latest ledger observed by the node when this response was generated.
- `error`: `<string>` - (optional) only present if the transaction failed. This field will include more details from `stellar-core` about why the invoke host function call failed.

Expand All @@ -31,10 +32,10 @@ The example transaction below invokes the `increment` function from the [`increm
```json
{
"jsonrpc": "2.0",
"id": 8675309,
"id": 1102,
"method": "simulateTransaction",
"params": {
"transaction": "AAAAAgAAAAAdq+kGxmBG/ikQNdYHQ2fBAG+8Av/xp1ZfPZ9Xt42ragAAJxAAAAAAAAAAAgAAAAEAAAAAAAAAAAAAAABjzuFcAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAACAAAABAAAAAEAAAAGAAAAIBv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAlpbmNyZW1lbnQAAAAAAAAAAAAAAAAAAAAAAAAA"
"transaction": "AAAAAgAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1gAAAGQAAAAAAAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAHN2/eiOTNYcwPspSheGs/HQYfXy8cpXRl+qkyIRuUbWAAAAGAAAAAIAAAAAAAAABAAAAA0AAAAg4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAAPAAAABGF1dGgAAAATAAAAAAAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9wAAAA8AAAAFd29ybGQAAAAAAAAAAAAAAAAAAAQAAAANAAAAIOGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAADwAAAARhdXRoAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAAAAAAA"
}
}
```
Expand All @@ -44,20 +45,33 @@ The example transaction below invokes the `increment` function from the [`increm
```json
{
"jsonrpc": "2.0",
"id": 8675309,
"id": 1102,
"result": {
"transactionData": "AAAAAwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAG4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAAUAAAAB8zDhJ3ZTMHmdBjlVh/7d1HDdo+QI1ZXGmeRzBwVAoVXAAAAAQAAAAbhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6ZrzssgAAABUAAAAAAAAAAGL8HQvQkbK2HA3WVjRrKmjX00fG8sLI7m0ERwJW/AX3ACb/vgAAFcQAAAC0AAABrAAAAAAAAABUAAAAAA==",
"events": [
"AAAAAQAAAAAAAAAB4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAABAAAAAAAAAAEAAAAOAAAABGF1dGgAAAAPAAAABXdvcmxkAAAA",
"AAAAAQAAAAAAAAAB4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAABAAAAAAAAAAEAAAAOAAAABGF1dGgAAAAPAAAABXdvcmxkAAAA"
],
"minResourceFee": "79488",
"results": [
{
"xdr": "AAAAAQAAAAY=",
"footprint": "AAAAAgAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAMAAAADAAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZfAAAAAQAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAUAAAAHQ09VTlRFUgA=",
"auth": "... TODO: Generate a plausible xdr.ContractAuth ..."
"auth": [
"AAAAAQAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAAAAAAAOGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAABGF1dGgAAAACAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAA="
],
"xdr": "AAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8Bfc="
},
{
"auth": [
"AAAAAQAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAAAAAAAeGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAABGF1dGgAAAACAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAA="
],
"xdr": "AAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8Bfc="
}
],
"cost": {
"cpuInsns": "163642",
"memBytes": "1506"
"cpuInsns": "2222468",
"memBytes": "2204681"
},
"latestLedger": "230473"
"latestLedger": "23456"
}
}
```
Expand Down

0 comments on commit b50faf3

Please sign in to comment.