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

Proposed Soroban-RPC API revisions #289

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions api/methods/getAccount.mdx

This file was deleted.

38 changes: 0 additions & 38 deletions api/methods/getHealth.mdx

This file was deleted.

7 changes: 4 additions & 3 deletions api/methods/getLatestLedger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For finding out the current latest known ledger of this node. This is a subset o
## Returns

- `<object>`
- `id`: `<hash>` - hash of the latest ledger as a hex-encoded string
- `protocolVersion`: `<number>`
- `sequence`: `<number>`
- `id`: `<hash>` - Hash of the latest ledger as a hex-encoded string
- `protocolVersion`: `<number>` - Protocol version
- `sequence`: `<number>` - Sequence number of the latest ledger
- `closeTime`: `<iso8601-string>` - Timestamp that the latest ledger was completed
47 changes: 30 additions & 17 deletions api/methods/getLedgerEntry.mdx → api/methods/getLedgerEntries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ To fetch contract wasm byte-code, use the ContractCode ledger entry key.

## Parameters

- `key`: `<xdr.LedgerKey>` - The key of the ledger entry you wish to retrieve (serialized in a base64 string)
- `keys`: `[<xdr.LedgerKey>]` - Array of keys for ledger entries you wish to retrieve (each serialized in a base64 string)

## Return

- `<object>`
- `xdr`: `<xdr.LedgerEntryData>` - The current value of the given ledger entry (serialized in a base64 string)
- `lastModifiedLedgerSeq`: `<number>` - The ledger number of the last time this entry was updated (optional)
- `entries`: `<array>` - Array of ledger entry results. If a key was not found, it will be `null` in the array.
- `xdr`: `<xdr.LedgerEntryData>` - The current value of the given ledger entry (each serialized in a base64 string)
- `lastModifiedLedgerSeq`: `<number>` - The ledger number of the last time this entry was updated (optional)
- `latestLedger`: `<number>` - The current latest ledger observed by the node when this response was generated.

## Examples
Expand All @@ -25,9 +26,9 @@ To fetch contract wasm byte-code, use the ContractCode ledger entry key.
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLedgerEntry",
"method": "getLedgerEntries",
"params": {
"key": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAdDT1VOVEVSAA=="
"keys": ["AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAdDT1VOVEVSAA=="]
}
}
```
Expand All @@ -39,8 +40,12 @@ To fetch contract wasm byte-code, use the ContractCode ledger entry key.
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"xdr": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAdDT1VOVEVSAAAAAAEAAAAD",
"lastModifiedLedgerSeq": "164986",
"entries": [
{
"xdr": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAdDT1VOVEVSAAAAAAEAAAAD",
"lastModifiedLedgerSeq": "164986"
}
],
"latestLedger": "179436"
}
}
Expand Down Expand Up @@ -134,15 +139,15 @@ print(get_ledger_key_contract_code(
# OUTPUT: AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAAAwAAAAM=
```

We then take our output from this function, and use it as the `key` parameter in our call to the `getLedgerEntry` method.
We then take our output from this function, and use it as the `key` parameter in our call to the `getLedgerEntries` method.

```json
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLedgerEntry",
"method": "getLedgerEntries",
"params": {
"key": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAAAwAAAAM="
"keys": ["AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAAAwAAAAM="]
}
}
```
Expand All @@ -154,8 +159,12 @@ And the response we get contains the `LedgerEntryData` that can be used to find
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"xdr": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAAAwAAAAMAAAAEAAAAAQAAAAcAAAAA1CpZRz0BSN27PmqtsmBhv+AAJJwHgmrvJNPrHRAl9l8=",
"lastModifiedLedgerSeq": "164303",
"entries": [
{
"xdr": "AAAABhv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAAAwAAAAMAAAAEAAAAAQAAAAcAAAAA1CpZRz0BSN27PmqtsmBhv+AAJJwHgmrvJNPrHRAl9l8=",
"lastModifiedLedgerSeq": "164303"
}
],
"latestLedger": "246819"
}
}
Expand Down Expand Up @@ -191,9 +200,9 @@ Now, finally we have a `LedgerKey` that correspond to the WASM byte-code that ha
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "getLedgerEntry",
"method": "getLedgerEntries",
"params": {
"key": "AAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZf"
"keys": ["AAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZf"]
}
}
```
Expand All @@ -205,12 +214,16 @@ And the response we get contains (even more) `LedgerEntryData` that we can decod
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"xdr": "AAAABwAAAADUKllHPQFI3bs+aq2yYGG/4AAknAeCau8k0+sdECX2XwAAAakAYXNtAQAAAAEXBWABfgF+YAJ+fgF+YAABfmABfwBgAAACEwMBbAEwAAABbAExAAABbAFfAAEDBgUCAwQEBAUDAQAQBhkDfwFBgIDAAAt/AEGAgMAAC38AQYCAwAALBzUFBm1lbW9yeQIACWluY3JlbWVudAADAV8ABwpfX2RhdGFfZW5kAwELX19oZWFwX2Jhc2UDAgrAAQWhAQMBfwF+AX8jgICAgABBEGsiACSAgICAAAJAAkBC2YP9sqDNAxCAgICAAEIVUg0AAkBC2YP9sqDNAxCBgICAACIBQg+DQgFSDQAgAUIEiKchAgwCCyAAQQhqEISAgIAAAAtBACECCwJAIAJBAWoiAg0AEIWAgIAAAAtC2YP9sqDNAyACrUIEhkIBhCIBEIKAgIAAGiAAQRBqJICAgIAAIAELCQAQhoCAgAAACwkAEIaAgIAAAAsEAAAACwIACwAeEWNvbnRyYWN0ZW52bWV0YXYwAAAAAAAAAAAAAAAbAC8OY29udHJhY3RzcGVjdjAAAAAAAAAACWluY3JlbWVudAAAAAAAAAAAAAABAAAAAQAAAA==",
"lastModifiedLedgerSeq": "164302",
"entries": [
{
"xdr": "AAAABwAAAADUKllHPQFI3bs+aq2yYGG/4AAknAeCau8k0+sdECX2XwAAAakAYXNtAQAAAAEXBWABfgF+YAJ+fgF+YAABfmABfwBgAAACEwMBbAEwAAABbAExAAABbAFfAAEDBgUCAwQEBAUDAQAQBhkDfwFBgIDAAAt/AEGAgMAAC38AQYCAwAALBzUFBm1lbW9yeQIACWluY3JlbWVudAADAV8ABwpfX2RhdGFfZW5kAwELX19oZWFwX2Jhc2UDAgrAAQWhAQMBfwF+AX8jgICAgABBEGsiACSAgICAAAJAAkBC2YP9sqDNAxCAgICAAEIVUg0AAkBC2YP9sqDNAxCBgICAACIBQg+DQgFSDQAgAUIEiKchAgwCCyAAQQhqEISAgIAAAAtBACECCwJAIAJBAWoiAg0AEIWAgIAAAAtC2YP9sqDNAyACrUIEhkIBhCIBEIKAgIAAGiAAQRBqJICAgIAAIAELCQAQhoCAgAAACwkAEIaAgIAAAAsEAAAACwIACwAeEWNvbnRyYWN0ZW52bWV0YXYwAAAAAAAAAAAAAAAbAC8OY29udHJhY3RzcGVjdjAAAAAAAAAACWluY3JlbWVudAAAAAAAAAAAAAABAAAAAQAAAA==",
"lastModifiedLedgerSeq": "164302"
}
],
"latestLedger": "246883"
}
}
```

[`increment` example contract]: </docs/examples/storing-data>
["View XDR" page of the Stellar Laboratory]: <https://laboratory.stellar.org/#xdr-viewer?type=LedgerEntryData&network=futurenet>
["View XDR" page of the Stellar Laboratory]: <https://laboratory.stellar.org/#xdr-viewer?type=LedgerEntryData&network=futurenet>
21 changes: 21 additions & 0 deletions api/methods/getLedgers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
sidebar_position: 7
---

:::note
The `getLedgers` method is proposed but not yet implemented.
:::


Clients can request a list of ledgers. Soroban-RPC will support querying within a maximum 24 hours of recent ledgers.

## Parameters

- `startLedger`: `<string>` - Stringified ledger sequence number to fetch events after (inclusive).
- `endLedger`: `<string>` - Stringified ledger sequence number to fetch events before (inclusive). endLedger must be less than or equal to startLedger + 720 (about 1 hour of ledgers).
paulbellamy marked this conversation as resolved.
Show resolved Hide resolved

## Returns

- `<object>`
- `ledgers`: `<object[]>`
- TODO: Figure out the object returned here.
3 changes: 2 additions & 1 deletion api/methods/getNetwork.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 6
---

:::note
Expand All @@ -15,5 +15,6 @@ General info about the currently configured network.
## Returns

- `<object>`
- `friendbotUrl`: `<string>` (optional) - The URL of this network's "friendbot" faucet
- `passphrase`: `<string>` - Network passphrase configured
- `protocolVersion`: `<string>` - Protocol version of the latest ledger
4 changes: 3 additions & 1 deletion api/methods/getTransactionStatus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Clients will poll this to tell when the transaction has been completed.
- `code`: `<string>` - Short unique string representing the type of error
- `message`: `<string>` - Human friendly summary of the error
- `data`: `<object>` - (optional) More data related to the error if available
- `eta`: `<iso8601-string>` - (optional) A rough estimate of the soonest time this transaction could be included in a ledger. Only present if the transaction is "pending".

## Examples

Expand All @@ -59,7 +60,8 @@ Clients will poll this to tell when the transaction has been completed.
"id": 8675309,
"result": {
"id": "d70916f8b8aa55c13d5974a38e32a3efe440ef6870c0f0a07075d1c128d23698",
"status": "pending"
"status": "pending",
"eta": "2023-01-27T16:54:52Z"
}
}
```
Expand Down
26 changes: 0 additions & 26 deletions api/methods/requestAirdrop.mdx

This file was deleted.

6 changes: 4 additions & 2 deletions api/methods/sendTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This supports all transactions, not only smart contract-related transactions.
- `success`
- `error`
- `error`: `<object>` - (optional) If the transaction was rejected immediately, this will be an error object. See [`getTransactionStatus`](getTransactionStatus) for format.
- `eta`: `<iso8601-string>` - A rough estimate of the soonest time this transaction could be included in a ledger.

## Possible Errors

Expand Down Expand Up @@ -55,9 +56,10 @@ The following example request uses a transaction to invoke the `increment` metho
"result": {
"id": "d70916f8b8aa55c13d5974a38e32a3efe440ef6870c0f0a07075d1c128d23698",
"status": "pending",
"error": null
"error": null,
"eta": "2023-01-27T16:54:52Z"
}
}
```

[`increment` example contract]: </docs/examples/storing-data>
[`increment` example contract]: </docs/examples/storing-data>
8 changes: 5 additions & 3 deletions api/methods/simulateTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Submit a trial contract invocation to get back return values, expected ledger fo
- `cost`: `<object>` - Information about the fees expected, 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
- `footprint`: `<xdr.LedgerFootprint>` -Array of ledger keys expected to be written by this transaction. (serialized in base64)
- `footprints`: `<xdr.LedgerFootprint[]>` - Array of xdr.LedgerFootprints (one per operation) expected to be read/written by this transaction. (each serialized in base64)
- `results`: `<object[]>` - If error is present then results will not be in the response
- `xdr`: `<xdr.ScVal>` - (optional) Only present on success. xdr-encoded return value of the contract call
- `latestLedger`: `<string>` - Stringified-number of the current latest ledger observed by the node when this response was generated.
Expand Down Expand Up @@ -49,7 +49,9 @@ The example transaction below invokes the `increment` function from the [`increm
"xdr": "AAAAAQAAAAY="
}
],
"footprint": "AAAAAgAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAMAAAADAAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZfAAAAAQAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAUAAAAHQ09VTlRFUgA=",
"footprints": [
"AAAAAgAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAMAAAADAAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZfAAAAAQAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAUAAAAHQ09VTlRFUgA="
],
"cost": {
"cpuInsns": "163642",
"memBytes": "1506"
Expand All @@ -59,4 +61,4 @@ The example transaction below invokes the `increment` function from the [`increm
}
```

[`increment` example contract]: </docs/examples/storing-data>
[`increment` example contract]: </docs/examples/storing-data>