View Source Numscriptex.Builder (numscriptex v0.2.5)
Numscriptex.Builder
makes it possible to build Numscripts dynamically within your application.
Summary
Functions
Receives a map with the metadata necessary to build your numscript.
Types
@type fixed_split() :: %{ type: :fixed | :percent, amount: pos_integer(), account: bitstring(), asset: bitstring() }
@type metadata() :: %{ :splits => [fixed_split()] | [percent_split()], optional(:remaining_to) => bitstring(), optional(:percent_asset) => bitstring() }
@type percent_split() :: %{ :type => :fixed | :percent, :amount => pos_integer(), optional(:account) => bitstring(), optional(:splits) => [percent_split()], optional(:remaining_to) => bitstring() }
Functions
Receives a map with the metadata necessary to build your numscript.
iex> metadata = %{
...> splits: [
...> %{
...> type: :fixed,
...> amount: 500,
...> asset: "BRL/2",
...> account: "some:destination"
...> }
...> ]
...> }
...>
...> Numscriptex.Builder.build(metadata)
{:ok, %{script: "send [BRL/2 500] (
source = @user
destination = @some:destination
)
"}}
If you want to learn more about this feature you can check its guide here