View Source Stellar.Horizon.ClaimableBalances (Elixir Stellar SDK v0.21.0)

Exposes functions to interact with ClaimableBalances in Horizon.

You can:

  • Retrieve a claimable balance.
  • List all claimable balances.
  • List a claimable balance's transactions.
  • List a claimable balance's operations.

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

Summary

Functions

Lists all available claimable balances.

Lists claimable balances matching the given canonical asset.

Lists claimable balances matching the given claimant.

Lists claimable balances matching the given sponsor.

Lists successful operations referencing a given claimable balance.

Lists successful transactions referencing a given claimable balance.

Retrieves information of a specific claimable balance.

Types

@type account_id() :: String.t()
@type asset() :: String.t()
Link to this type

claimable_balance_id()

View Source
@type claimable_balance_id() :: String.t()
@type options() :: Keyword.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}
@type server() :: Stellar.Horizon.Server.t()

Functions

Link to this function

all(server, options \\ [])

View Source
@spec all(server :: server(), options :: options()) :: response()

Lists all available claimable balances.

Parameters:

  • server: The Horizon server to query.

Options

  • sponsor: Account ID of the sponsors.
  • asset: An issued asset represented as “Code:IssuerAccountID”.
  • claimant: Account ID of the destination address.
  • 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> ClaimableBalances.all(Stellar.Horizon.Server.testnet(), limit: 2, order: :asc)
{:ok, %Collection{records: [%ClaimableBalance{}, ...]}}

# list by sponsor
iex> ClaimableBalances.all(Stellar.Horizon.Server.testnet(), sponsor: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%ClaimableBalance{}, ...]}}

# list by claimant
iex> ClaimableBalances.all(Stellar.Horizon.Server.testnet(), claimant: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", order: :desc)
{:ok, %Collection{records: [%ClaimableBalance{}, ...]}}

# list by canonical asset address
iex> ClaimableBalances.all(Stellar.Horizon.Server.testnet(), asset: "TEST:GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD", limit: 20)
{:ok, %Collection{records: [%ClaimableBalance{}, ...]}}
Link to this function

list_by_asset(server, asset, options \\ [])

View Source
@spec list_by_asset(server :: server(), asset :: asset(), options :: options()) ::
  response()

Lists claimable balances matching the given canonical asset.

Parameters:

  • asset: An issued asset represented as “Code:IssuerAccountID”.

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> ClaimableBalances.list_by_asset(Stellar.Horizon.Server.testnet(), "TEST:GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%ClaimableBalance{asset: "TEST:GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD"}, ...]}}
Link to this function

list_by_claimant(server, claimant, options \\ [])

View Source
@spec list_by_claimant(
  server :: server(),
  claimant :: account_id(),
  options :: options()
) :: response()

Lists claimable balances matching the given claimant.

Parameters:

  • server: The Horizon server to query.
  • claimant: Account ID of the destination address.

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> ClaimableBalances.list_by_claimant("GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%ClaimableBalance{claimant: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD"}, ...]}}
Link to this function

list_by_sponsor(server, sponsor, options \\ [])

View Source
@spec list_by_sponsor(
  server :: server(),
  sponsor :: account_id(),
  options :: options()
) :: response()

Lists claimable balances matching the given sponsor.

Parameters:

  • server: The Horizon server to query.
  • sponsor: Account ID of the sponsor.

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> ClaimableBalances.list_by_sponsor(Stellar.Horizon.Server.testnet(), "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD")
{:ok, %Collection{records: [%ClaimableBalance{sponsor: "GCXMWUAUF37IWOOV2FRDKWEX3O2IHLM2FYH4WPI4PYUKAIFQEUU5X3TD"}, ...]}}
Link to this function

list_operations(server, claimable_balance_id, options \\ [])

View Source
@spec list_operations(
  server :: server(),
  claimable_balance_id :: claimable_balance_id(),
  options :: options()
) :: response()

Lists successful operations referencing a given claimable balance.

Parameters

  • server: The Horizon server to query.
  • claimable_balance_id: A unique identifier for the claimable balance.

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> ClaimableBalances.list_operations(Stellar.Horizon.Server.testnet(), "00000000ca6aba5fb0993844e0076f75bee53f2b8014be29cd8f2e6ae19fb0a17fc68695", limit: 20)
{:ok, %Collection{records: [%Operation{}, ...]}}

# join transactions
iex> ClaimableBalances.list_operations(Stellar.Horizon.Server.testnet(), "00000000ca6aba5fb0993844e0076f75bee53f2b8014be29cd8f2e6ae19fb0a17fc68695", join: "transactions")
{:ok, %Collection{records: [%Operation{transaction: %Transaction{}}, ...]}}
Link to this function

list_transactions(server, claimable_balance_id, options \\ [])

View Source
@spec list_transactions(
  server :: server(),
  claimable_balance_id :: claimable_balance_id(),
  options :: options()
) :: response()

Lists successful transactions referencing a given claimable balance.

Parameters

  • server: The Horizon server to query.
  • claimable_balance_id: A unique identifier for the claimable balance.

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> ClaimableBalances.list_transactions(Stellar.Horizon.Server.testnet(), "00000000ca6aba5fb0993844e0076f75bee53f2b8014be29cd8f2e6ae19fb0a17fc68695", limit: 20)
{:ok, %Collection{records: [%Transaction{}, ...]}}
Link to this function

retrieve(server, claimable_balance_id)

View Source
@spec retrieve(server :: server(), claimable_balance_id :: claimable_balance_id()) ::
  response()

Retrieves information of a specific claimable balance.

Parameters:

  • server: The Horizon server to query.
  • claimable_balance_id: A unique identifier for the claimable balance.

Examples

iex> ClaimableBalances.retrieve(Stellar.Horizon.Server.testnet(), "00000000ca6aba5fb0993844e0076f75bee53f2b8014be29cd8f2e6ae19fb0a17fc68695")
{:ok, %ClaimableBalance{}}