Skip to content

getLedgerEntries: add meaningful coding examples #469

Closed

Description

@tomerweller

The getLedgerEntries method is pretty powerful, you can retrieve any piece of state from the ledger: accounts, trustlines, offers, data, liquidity pools, contract wasms, contract instances, contract storage, yada yada.

However, there are two challenges associated with that:

  1. building the relevant xdr key for the type of ledger entry you're looking for
  2. parsing the xdr result

However, our coding examples use pre-built keys and don't parse the results. I think that modifying our JS and Python examples in this page to include these can help unlock human potential

### Tasks
- [x] Add a full list of keys and description for each key
- [x] Add examples for how to use the keys to retrieve accounts and balances
- [x] Add examples for how to use the keys to retrieve trustlines
- [x] Add examples for how to use the keys to retrieve contract wasms
- [x] Add examples for how to use the keys to retreive contract state / storage
- [x] Add examples for how to use the keys to retrieve contract instances

Activity

  1. leighmcculloch commented on Jan 25, 2024

    @leighmcculloch
    Member

    A couple thoughts:

    Laboratory – I think building ledger keys would be a perfect feature to add to the Laboratory. In classic stellar days building txs was really the only thing we needed to build, and Laboratory supports that. But with Soroban, building other types is necessary. We could invest UI that auto-generated to build any XDR type also.

    Soroban CLI – The stellar-xdr CLI is also now embedded into the soroban-cli, which means it's possible to construct these ledger keys and decode the responses on the command line with the tool that folks already have installed. We should include examples. Here's an example of building an account ledger key:

    ❯ echo '{"account":{"account_id":"GBCPWDD43RTGBLBYQGELGIAV7QN4O5CHJDWYIQJQGAWLQAXNGNERPSY6"}}' | soroban lab xdr encode --type LedgerKey
    AAAAAAAAAABE+wx83GZgrDiBiLMgFfwbx3RHSO2EQTAwLLgC7TNJFw==
    
  2. kalepail commented on Jan 25, 2024

    @kalepail
    Contributor

    Plus one on adding LedgerKey encoding to the Laboratory!

  3. janewang commented on Jan 25, 2024

    @janewang
    Contributor

    Where could I find a full list of ledger keys and descriptions?

  4. added
    help wanted
    on Jan 26, 2024
  5. moved this from Backlog to To Do in Dev Docson Apr 25, 2024
  6. moved this from Backlog to To Do in Platform Scrumon May 8, 2024
  7. self-assigned this
    on Oct 25, 2024
  8. moved this from To Do to In Progress in Platform Scrumon Oct 25, 2024
  9. removed
    help wanted
    on Mar 7, 2025
  10. moved this from Needs Review to Done in Platform Scrumon Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions