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

Exposes functions to interact with Assets in Horizon.

You can:

  • List all assets.
  • List assets by asset_code.
  • List assets by asset_issuer.

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

Summary

Functions

Lists all assets or by one of these filters: asset_code or asset_issuer.

Lists assets matching the given asset code.

Lists assets matching the given asset issuer.

Types

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

Functions

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

Lists all assets or by one of these filters: asset_code or asset_issuer.

Options

  • asset_code: The code of the asset you would like to filter by.
  • asset_issuer: The issuer's Account ID for the asset you would like to filter by.
  • 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> Assets.all(limit: 20, order: :desc)
{:ok, %Collection{records: [%Asset{}, ...]}}

# list by asset_code
iex> Assets.all(asset_code: "TEST")
{:ok, %Collection{records: [%Asset{}, ...]}}

# list by asset_issuer
iex> Assets.all(asset_issuer: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%Asset{}, ...]}}
Link to this function

list_by_asset_code(asset_code, options \\ [])

View Source
@spec list_by_asset_code(asset_code :: asset_code(), options :: options()) ::
  response()

Lists assets matching the given asset code.

Parameters:

  • asset_code: The code of the asset you would like to filter by.

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> Assets.list_by_asset_code("TEST")
{:ok, %Collection{records: [%Asset{asset_code: "TEST"}, ...]}}
Link to this function

list_by_asset_issuer(asset_issuer, options \\ [])

View Source
@spec list_by_asset_issuer(asset_issuer :: asset_issuer(), options :: options()) ::
  response()

Lists assets matching the given asset issuer.

Parameters:

  • asset_issuer: The issuer's Account ID for the asset you would like to filter by.

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> Assets.list_by_asset_issuer("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%Asset{asset_issuer: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD"}, ...]}}