View Source Stellar.Horizon.Ledgers (Elixir Stellar SDK v0.22.0)
Exposes functions to interact with Ledgers in Horizon.
You can:
- Retrieve a ledger.
- List all ledgers.
- List a ledger's effects.
- List a ledger's transactions.
- List a ledger's operations.
Horizon API reference: https://developers.stellar.org/api/resources/ledgers/
Summary
Functions
Lists all ledgers.
Lists the effects of a specific ledger.
Lists successful operations in a specific ledger.
Lists successful payments in a specific ledger.
Lists successful transactions in a specific ledger.
Retrieves information of a specific ledger.
Types
@type params() :: Keyword.t()
@type resource() :: Stellar.Horizon.Ledger.t() | Stellar.Horizon.Collection.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}
@type sequence() :: non_neg_integer()
@type server() :: Stellar.Horizon.Server.t()
Functions
Lists all ledgers.
Parameters:
server
: The Horizon server to query.
Options
cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.
Examples
iex> Ledgers.all(Stellar.Horizon.Server.testnet(), limit: 10, order: :asc)
{:ok, %Collection{records: [%Ledger{}, ...]}}
Lists the effects of a specific ledger.
Parameters
server
: The Horizon server to query.sequence
: The sequence number of a specific ledger.
Options
cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.
Examples
iex> Ledgers.list_effects(Stellar.Horizon.Server.testnet(), 27147222, limit: 20)
{:ok, %Collection{records: [%Effect{}, ...]}}
Lists successful operations in a specific ledger.
Parameters
server
: The Horizon server to query.sequence
: The sequence number of a specific ledger.
Options
cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.include_failed
: Set to true to include failed operations in results.join
: Set totransactions
to include the transactions which created each of the operations in the response.
Examples
iex> Ledgers.list_operations(Stellar.Horizon.Server.testnet(), 27147222, limit: 20)
{:ok, %Collection{records: [%Operation{}, ...]}}
# join transactions
iex> Ledgers.list_operations(Stellar.Horizon.Server.testnet(), 27147222, join: "transactions")
{:ok, %Collection{records: [%Operation{transaction: %Transaction{}}, ...]}}
Lists successful payments in a specific ledger.
Parameters
server
: The Horizon server to query.sequence
: The sequence number of a specific ledger.
Options
cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.include_failed
: Set to true to include failed operations in results.join
: Set totransactions
to include the transactions which created each of the operations in the response.
Examples
iex> Ledgers.list_payments(Stellar.Horizon.Server.testnet(), 27147222, limit: 20)
{:ok, %Collection{records: [%Operation{body: %Payment{}}, ...]}}
# include failed
iex> Ledgers.list_payments(Stellar.Horizon.Server.testnet(), 27147222, include_failed: true)
{:ok, %Collection{records: [%Operation{body: %Payment{}}, ...]}}
@spec list_transactions( server :: server(), sequence :: sequence(), params :: params() ) :: response()
Lists successful transactions in a specific ledger.
Parameters
server
: The Horizon server to query.sequence
: The sequence number of a specific ledger.
Options
cursor
: A number that points to a specific location in a collection of responses and is pulled from thepaging_token
value of a record.order
: A designation of the order in which records should appear. Options includeasc
(ascending) ordesc
(descending).limit
: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.include_failed
: Set to true to include failed operations in results.
Examples
iex> Ledgers.list_transactions(Stellar.Horizon.Server.testnet(), 27147222, limit: 20)
{:ok, %Collection{records: [%Transaction{}, ...]}}
Retrieves information of a specific ledger.
Parameters:
server
: The Horizon server to query.sequence
: The sequence number of a specific ledger.
Examples
iex> Ledgers.retrieve(Stellar.Horizon.Server.testnet(), 27147222)
{:ok, %Ledger{}}