Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/data/apis/migrate-from-horizon-to-rpc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Horizon answers `404` when a resource does not exist. RPC answers `200` and leav
Match each returned entry back to its own key with the entry's `keyJson` field, or `key` in the default base64 format. Do not match on the position you sent it in.

[CAP-67]: https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md
[`AccountEntry`]: https://github.com/stellar/stellar-xdr/blob/v28.0/Stellar-ledger-entries.x#L190
[`AccountEntry`]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L190
[Horizon]: /docs/data/apis/horizon
[RPC]: /docs/data/apis/rpc
[Horizon's REST-like API]: /docs/data/apis/horizon/api-reference
Expand Down
4 changes: 2 additions & 2 deletions docs/data/apis/rpc/api-reference/methods/getEvents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ The unix timestamp (as a string) of the close time of the oldest ledger kept in
</ResponseField>
<ResponseField name="topic" type="string[]">

The [ScVal](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-contract.x#L214)s containing the topics this event was emitted with (as a base64 string).
The [ScVal](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-contract.x#L247)s containing the topics this event was emitted with (as a base64 string).

</ResponseField>
<ResponseField name="value" type="string">

The data emitted by the event (an [ScVal](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-contract.x#L214), serialized as a base64 string).
The data emitted by the event (an [ScVal](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-contract.x#L247), serialized as a base64 string).

</ResponseField>
<ResponseField name="txHash" type="string">
Expand Down
4 changes: 2 additions & 2 deletions docs/data/apis/rpc/api-reference/methods/getLatestLedger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ The timestamp at which the latest ledger was closed.

<ResponseField name="headerXdr" type="string">

The [LedgerHeader](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L74) structure for this ledger (base64-encoded string).
The [LedgerHeader](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L100) structure for this ledger (base64-encoded string).

</ResponseField>

<ResponseField name="metadataXdr" type="string">

The [LedgerCloseMeta](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L539) union for this ledger (base64-encoded string).
The [LedgerCloseMeta](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L695-L703) union for this ledger (base64-encoded string).

</ResponseField>

Expand Down
12 changes: 6 additions & 6 deletions docs/data/apis/rpc/api-reference/methods/getLedgerEntries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Array containing the keys of the ledger entries you wish to retrieve. (an array

An array of LedgerKeys. The maximum number of ledger keys accepted is 200.

The [LedgerKey](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger-entries.x#L600) union corresponding to an existing ledger entry you want to retrieve (base64-encoded string).
The [LedgerKey](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L588) union corresponding to an existing ledger entry you want to retrieve (base64-encoded string).

</ParamField>

Expand Down Expand Up @@ -56,12 +56,12 @@ Object containing information about an existing ledger entry.
<Expandable title="items">
<ResponseField name="key" type="string">

The [LedgerKey](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger-entries.x#L600) corresponding to the ledger entry (base64 string).
The [LedgerKey](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L588) corresponding to the ledger entry (base64 string).

</ResponseField>
<ResponseField name="xdr" type="string">

The key's current [LedgerEntryData](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger-entries.x#L564) value (base64 string).
The key's current [LedgerEntryData](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L552-L575) value (base64 string).

</ResponseField>
<ResponseField name="lastModifiedLedgerSeq" type="number">
Expand Down Expand Up @@ -384,13 +384,13 @@ print(json.dumps(res.json(), indent=4))

## Building ledger keys

The Stellar ledger is, on some level, essentially a key-value store. The keys are instances of [`LedgerKey`](https://github.com/stellar/stellar-xdr/blob/v25.0/Stellar-ledger-entries.x#L588) and the values are instances of [`LedgerEntry`](https://github.com/stellar/stellar-xdr/blob/v25.0/Stellar-ledger-entries.x#L548). An interesting product of the store's internal design is that the key is a _subset_ of the entry: we'll see more of this later.
The Stellar ledger is, on some level, essentially a key-value store. The keys are instances of [`LedgerKey`](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L588) and the values are instances of [`LedgerEntry`](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L548). An interesting product of the store's internal design is that the key is a _subset_ of the entry: we'll see more of this later.

The `getLedgerEntries` method returns the "values" (or "entries") for a given set of "keys". Ledger keys come in a lot of forms, and we'll go over the commonly used ones on this page alongside tutorials on how to build and use them.

## Types of `LedgerKey`s

The source of truth should always be the XDR defined in the protocol. `LedgerKey`s are a union type defined in [Stellar-ledger-entries.x](https://github.com/stellar/stellar-xdr/blob/v25.0/Stellar-ledger-entries.x#L588). There are 10 different forms a ledger key can take:
The source of truth should always be the XDR defined in the protocol. `LedgerKey`s are a union type defined in [Stellar-ledger-entries.x](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L588). There are 10 different forms a ledger key can take:

1. **Account:** holistically defines a Stellar account, including its balance, signers, etc. (see [Accounts](../../../../../learn/fundamentals/stellar-data-structures/accounts))
2. **Trustline:** defines a balance line to a non-native asset issued on the network (see [`changeTrustOp`](../../../../../learn/fundamentals/transactions/list-of-operations#change-trust))
Expand Down Expand Up @@ -807,7 +807,7 @@ Now, finally we have a `LedgerKey` that correspond to the Wasm byte-code that ha
}
```

Then you can inspect them accordingly. Each of the above entries follows the XDR for that `LedgerEntryData` structure precisely. For example, the `AccountEntry` is in [`Stellar-ledger-entries.x#L190`](https://github.com/stellar/stellar-xdr/blob/v25.0/Stellar-ledger-entries.x#L190) and you can read its `seqNum` field to get its current sequence number, as we've shown. In JavaScript, XDR fields are plain properties and unions expose `.type` and `.value`; the [v17 XDR migration guide](https://stellar.github.io/js-stellar-sdk/migration/xdr-migration/) shows these shapes.
Then you can inspect them accordingly. Each of the above entries follows the XDR for that `LedgerEntryData` structure precisely. For example, the `AccountEntry` is in [`Stellar-ledger-entries.x#L190`](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger-entries.x#L190) and you can read its `seqNum` field to get its current sequence number, as we've shown. In JavaScript, XDR fields are plain properties and unions expose `.type` and `.value`; the [v17 XDR migration guide](https://stellar.github.io/js-stellar-sdk/migration/xdr-migration/) shows these shapes.

## Viewing and understanding XDR

Expand Down
4 changes: 2 additions & 2 deletions docs/data/apis/rpc/api-reference/methods/getLedgers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ _(getLedgersResult)_
</ResponseField>
<ResponseField name="headerXdr" type="string">

The [LedgerHeaderHistoryEntry](https://github.com/stellar/stellar-xdr/blob/v26.0/Stellar-ledger.x#L277) structure for this ledger (base64-encoded string).
The [LedgerHeaderHistoryEntry](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L303) structure for this ledger (base64-encoded string).

</ResponseField>
<ResponseField name="metadataXdr" type="string">

The [LedgerCloseMeta](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L539) union for this ledger (base64-encoded string).
The [LedgerCloseMeta](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L695-L703) union for this ledger (base64-encoded string).

</ResponseField>

Expand Down
6 changes: 3 additions & 3 deletions docs/data/apis/rpc/api-reference/methods/getTransaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ _Note: Available only on RPC v23.x (currently testnet only)._
<Expandable title="properties">
<ResponseField name="transactionEventsXdr" type="string[]">

An array of base64-encoded [xdr.TransactionEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L503-L506). These include events such as fees being charged or refunded.
An array of base64-encoded [xdr.TransactionEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L529-L532). These include events such as fees being charged or refunded.

</ResponseField>
<ResponseField name="contractEventsXdr" type="string[][]">

A nested array of base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L371-L390). Each inner array represents the contract events emitted by a single operation within the transaction.
A nested array of base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L397-L416). Each inner array represents the contract events emitted by a single operation within the transaction.

Base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L371-L390) emitted by a single operation within the transaction.
Base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L397-L416) emitted by a single operation within the transaction.

</ResponseField>

Expand Down
12 changes: 6 additions & 6 deletions docs/data/apis/rpc/api-reference/methods/getTransactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ _(getTransactionsResult)_
</ResponseField>
<ResponseField name="envelopeXdr" type="string">

The [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-transaction.x#L1009) structure for this transaction (base64-encoded string).
The [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L1002) structure for this transaction (base64-encoded string).

</ResponseField>
<ResponseField name="resultXdr" type="string">

The [TransactionResult](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-transaction.x#L2088) structure for this transaction (base64-encoded string).
The [TransactionResult](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L2091) structure for this transaction (base64-encoded string).

</ResponseField>
<ResponseField name="resultMetaXdr" type="string">

The [TransactionMeta](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L446) union for this transaction (base64-encoded string).
The [TransactionMeta](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L560-L572) union for this transaction (base64-encoded string).

</ResponseField>
<ResponseField name="diagnosticEventsXdr" type="string[]">
Expand All @@ -105,14 +105,14 @@ _(getTransactionsResult)_
<Expandable title="properties">
<ResponseField name="transactionEventsXdr" type="string[]">

An array of base64-encoded [xdr.TransactionEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L503-L506). These include events such as fees being charged or refunded.
An array of base64-encoded [xdr.TransactionEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L529-L532). These include events such as fees being charged or refunded.

</ResponseField>
<ResponseField name="contractEventsXdr" type="string[][]">

A nested array of base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L371-L390). Each inner array represents the contract events emitted by a single operation within the transaction.
A nested array of base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L397-L416). Each inner array represents the contract events emitted by a single operation within the transaction.

Base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v23.0/Stellar-ledger.x#L371-L390) emitted by a single operation within the transaction.
Base64-encoded [xdr.ContractEvent](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L397-L416) emitted by a single operation within the transaction.

</ResponseField>
</Expandable>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/apis/rpc/api-reference/methods/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ description: "All you need to know about available RPC methods, parameters and r

Don't know which endpoint you need to get what you want? A lot of the returned fields are deeply-nested [XDR structures](/docs/learn/fundamentals/data-format/xdr#more-about-xdr), so it can be hard to figure out what kind of information is available in each of these. Here's a bit of a dive into what the "workhorse" endpoints provide, in decreasing order of granularity:

- [`getLedgers`](/docs/data/apis/rpc/api-reference/methods/getLedgers) operates at the block level, providing you with the full, complete details of what occurred during application of that ledger (known as "ledger metadata", defined in the protocol by the [`LedgerCloseMeta`](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L539) union, specifically the `V1` iteration). Each of the subsequent endpoints is just a microscope into a subset of the data available provided by this endpoint. Metadata includes things like:
- [`getLedgers`](/docs/data/apis/rpc/api-reference/methods/getLedgers) operates at the block level, providing you with the full, complete details of what occurred during application of that ledger (known as "ledger metadata", defined in the protocol by the [`LedgerCloseMeta`](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-ledger.x#L695-L703) union). Each of the subsequent endpoints is just a microscope into a subset of the data available provided by this endpoint. Metadata includes things like:
- Details for recreating the blockchain's state (see [Ledger Headers](/docs/learn/fundamentals/stellar-data-structures/ledgers#ledger-headers) for more).
- The consensus information that led to the block closing (see [Stellar Consensus Protocol](/docs/learn/fundamentals/stellar-consensus-protocol)).
- The set of transactions, their respective operations, and the results of applying those transactions in this block (see [Transactions](/docs/learn/fundamentals/transactions/operations-and-transactions)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please note that parameter structure within the request must contain named param

The signed transaction to broadcast for inclusion in a ledger.

A Stellar [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-transaction.x#L1009) (as a base64-encoded string)
A Stellar [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L1002) (as a base64-encoded string)

</ParamField>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Please note that parameter structure within the request must contain named param

In order for the RPC server to successfully simulate a Stellar transaction, the provided transaction must contain only a single operation of the type `invokeHostFunction`.

A Stellar [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-transaction.x#L1009) (as a base64-encoded string)
A Stellar [TransactionEnvelope](https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L1002) (as a base64-encoded string)

</ParamField>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ If any of the steps above fails, then the authorization is considered unsuccessf

Notice, that authentication happens just once per tree, as the whole tree needs to be signed.

[soroban-auth-entry]: https://github.com/stellar/stellar-xdr/blob/e372df9f677961aac04c5a4cc80a3667f310b29f/Stellar-transaction.x#L570
[signature payload preimage]: https://github.com/stellar/stellar-xdr/blob/e372df9f677961aac04c5a4cc80a3667f310b29f/Stellar-transaction.x#L703
[soroban-auth-entry]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L610
[signature payload preimage]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L745-L752

#### Matching Authorized Invocation Trees

Expand All @@ -184,4 +184,4 @@ During the matching process that happens for every `require_auth` host tries to

In case if the same contract function calls `require_auth` for the same `Address` multiple times (e.g. when multiple operations from the same user are being batched), every `require_auth` call still has to have a corresponding node in the `SorobanAuthorizedInvocation` tree. Due to that, there might be multiple valid trees that make all the authorization checks pass. There is nothing wrong about that - the address still must have authorized all the invocations. The only requirement for such cases to be handled correctly is to ensure that the `require_auth` calls for an `Address` happen before the corresponding sub-contract calls.

[invocation-xdr]: https://github.com/stellar/stellar-xdr/blob/e372df9f677961aac04c5a4cc80a3667f310b29f/Stellar-transaction.x#L537
[invocation-xdr]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L558
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ See [Send to and receive payments from Contract Accounts](../../../../build/guid

The XDR of `HostFunction` and `InvokeHostFunctionOp` below can be found [here][xdr].

[xdr]: https://github.com/stellar/stellar-xdr/blob/e372df9f677961aac04c5a4cc80a3667f310b29f/Stellar-transaction.x#L581
[xdr]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L623

```cpp
union HostFunction switch (HostFunctionType type)
Expand Down Expand Up @@ -659,7 +659,7 @@ case CONTRACT_ID_PREIMAGE_FROM_ASSET:

The contract ID is the SHA-256 hash of the XDR-encoded [`HashIDPreimage`] in its `ENVELOPE_TYPE_CONTRACT_ID` form:

[`hashidpreimage`]: https://github.com/stellar/stellar-xdr/blob/v27.0/Stellar-transaction.x#L721-L762
[`hashidpreimage`]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L721-L762

```cpp
union HashIDPreimage switch (EnvelopeType type)
Expand Down Expand Up @@ -764,7 +764,7 @@ struct SorobanAuthorizedContractFunction

Building `SorobanAuthorizedInvocation` trees may be simplified by using the recording auth mode in Soroban's `simulateTransaction` mechanism (see the [docs][simulate-transaction-doc] for more details).

[envelope-xdr]: https://github.com/stellar/stellar-xdr/blob/v27.0/Stellar-transaction.x#L747-L754
[envelope-xdr]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L745-L752
[simulate-transaction-doc]: transaction-simulation#authorization

#### Stellar Account Signatures {#stellar-account-signatures}
Expand Down Expand Up @@ -815,7 +815,7 @@ const signedEntries = await Promise.all(

Every Soroban transaction has to have a `SorobanTransactionData` transaction [extension] populated. This is needed to compute the [Soroban resource fee](../../../fundamentals/fees-resource-limits-metering).

[extension]: https://github.com/stellar/stellar-xdr/blob/v27.0/Stellar-transaction.x#L957-L964
[extension]: https://github.com/stellar/stellar-xdr/blob/v30.0/Stellar-transaction.x#L957-L964

The Soroban transaction data is defined as follows:

Expand Down
Loading