View Source Stellar.Horizon.Accounts (Elixir Stellar SDK v0.17.1)

Exposes functions to interact with Accounts in Horizon.

You can:

  • Retrieve an account.
  • Fetch an account next sequence number.
  • List all accounts.
  • List an account's effects.
  • List an account's offers.
  • List an account's trades.
  • List an account's transactions.
  • List an account's operations.
  • List an account's payments.
  • List an account's data.

Horizon API reference: https://developers.stellar.org/api/resources/accounts/

Summary

Functions

Lists all accounts or by one of these three filters: signer, asset, or sponsor.

Retrieves a single data for a given account.

Fetches the ledger's sequence number for the given account.

Lists the effects of a specific account.

Lists all offers a given account has currently open.

Lists successful operations for a given account.

Lists successful payments for a given account.

Lists all trades for a given account.

Lists successful transactions for a given account.

Retrieves information of a specific account.

Types

@type account_id() :: String.t()
@type options() :: Keyword.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}

Functions

@spec all(options :: options()) :: response()

Lists all accounts or by one of these three filters: signer, asset, or sponsor.

Options

  • signer: Account ID of the signer.
  • asset: An issued asset represented as “Code:IssuerAccountID”.
  • sponsor: Account ID of the sponsor.
  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (descending).
  • limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.

Examples

iex> Accounts.all(limit: 2, order: :asc)
{:ok, %Collection{records: [%Account{}, ...]}}

# list by sponsor
iex> Accounts.all(sponsor: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%Account{}, ...]}}

# list by signer
iex> Accounts.all(signer: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", order: :desc)
{:ok, %Collection{records: [%Account{}, ...]}}

# list by canonical asset address
iex> Accounts.all(asset: "TEST:GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Account{}, ...]}}
@spec data(account_id :: account_id(), key :: String.t()) :: response()

Retrieves a single data for a given account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.
  • key: The key name for this data.

Examples

iex> Accounts.data("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", "config.memo_required")
{:ok, %Account.Data{}}
Link to this function

fetch_next_sequence_number(account_id)

View Source
@spec fetch_next_sequence_number(account_id :: account_id()) :: response()

Fetches the ledger's sequence number for the given account.

Parameters:

  • account_id: The account’s public key encoded in a base32 string representation.

Examples

iex> Accounts.fetch_next_sequence_number("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, 17218523889687}
Link to this function

list_effects(account_id, options \\ [])

View Source
@spec list_effects(account_id :: account_id(), options :: options()) :: response()

Lists the effects of a specific account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (descending).
  • limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.

Examples

iex> Accounts.list_effects("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Effect{}, ...]}}
Link to this function

list_offers(account_id, options \\ [])

View Source
@spec list_offers(account_id :: account_id(), options :: options()) :: response()

Lists all offers a given account has currently open.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (descending).
  • limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.

Examples

iex> Accounts.list_offers("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Offer{}, ...]}}
Link to this function

list_operations(account_id, options \\ [])

View Source
@spec list_operations(account_id :: account_id(), options :: options()) :: response()

Lists successful operations for a given account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (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 to transactions to include the transactions which created each of the operations in the response.

Examples

iex> Accounts.list_transactions("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Operation{}, ...]}}

# join transactions
iex> Accounts.list_transactions("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", join: "transactions")
{:ok, %Collection{records: [%Operation{transaction: %Transaction{}}, ...]}}
Link to this function

list_payments(account_id, options \\ [])

View Source
@spec list_payments(account_id :: account_id(), options :: options()) :: response()

Lists successful payments for a given account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (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 to transactions to include the transactions which created each of the operations in the response.

Examples

iex> Accounts.list_payments("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Operation{body: %Payment{}}, ...]}}

# include failed
iex> Accounts.list_payments("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", include_failed: true)
{:ok, %Collection{records: [%Operation{body: %Payment{}}, ...]}}
Link to this function

list_trades(account_id, options \\ [])

View Source
@spec list_trades(account_id :: account_id(), options :: options()) :: response()

Lists all trades for a given account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (descending).
  • limit: The maximum number of records returned. The limit can range from 1 to 200. Defaults to 10.

Examples

iex> Accounts.list_trades("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Trade{}, ...]}}
Link to this function

list_transactions(account_id, options \\ [])

View Source
@spec list_transactions(account_id :: account_id(), options :: options()) ::
  response()

Lists successful transactions for a given account.

Parameters

  • account_id: The account’s public key encoded in a base32 string representation.

Options

  • cursor: A number that points to a specific location in a collection of responses and is pulled from the paging_token value of a record.
  • order: A designation of the order in which records should appear. Options include asc (ascending) or desc (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> Accounts.list_transactions("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%Transaction{}, ...]}}
@spec retrieve(account_id :: account_id()) :: response()

Retrieves information of a specific account.

Parameters:

  • account_id: The account’s public key encoded in a base32 string representation.

Examples

iex> Accounts.retrieve("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Account{}}