ForgeAbi v1.9.0 ForgeAbi.Unit View Source
Unit is the smallest, non-fungible unit used for Forge Apps. If app define decimal as 16, then 1 token (e.g. ABT) = 10^16 unit(e.g. arc). When sending transfer tx or exchange tx, the value shall be created with Unit.
Link to this section Summary
Functions
Convert integer to ForgeAbi.BigUint.t()
Link to this section Functions
Link to this function
new_unit(i)
View Source
new_unit(i)
View Source
new_unit(integer()) :: ForgeAbi.BigUint.t()
new_unit(integer()) :: ForgeAbi.BigUint.t()
Convert integer to ForgeAbi.BigUint.t()
Examples:
iex> use ForgeAbi.Unit iex> a = new_unit(10) %ForgeAbi.BigUint{value: <<10>>} iex> b = new_unit(2) %ForgeAbi.BigUint{value: <<2>>} iex> c = new_unit(-2) %ForgeAbi.BigUint{value: <<0>>} iex> a + b %ForgeAbi.BigUint{value: <<12>>} iex> a - b %ForgeAbi.BigUint{value: <<8>>} iex> b - a %ForgeAbi.BigUint{value: <<0>>} iex> a + c %ForgeAbi.BigUint{value: <<10>>}
Link to this function
one_token(decimal \\ 0)
View Source
one_token(decimal \\ 0)
View Source
one_token(non_neg_integer()) :: non_neg_integer()
one_token(non_neg_integer()) :: non_neg_integer()
Link to this function
token_to_unit(n)
View Source
token_to_unit(n)
View Source
token_to_unit(number()) :: ForgeAbi.BigUint.t()
token_to_unit(number()) :: ForgeAbi.BigUint.t()
Link to this function
unit_to_token(i)
View Source
unit_to_token(i)
View Source
unit_to_token(ForgeAbi.BigUint.t() | non_neg_integer()) :: number()
unit_to_token(ForgeAbi.BigUint.t() | non_neg_integer()) :: number()