ForgeAbi v1.9.2 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

Link to this section Functions

Link to this function

new_unit(i) View Source
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

token_to_unit(n, decimal \\ 0) View Source
token_to_unit(number(), non_neg_integer()) :: ForgeAbi.BigUint.t()

Link to this function

unit_to_token(unit, decimal \\ 0) View Source
unit_to_token(ForgeAbi.BigUint.t() | non_neg_integer(), non_neg_integer()) ::
  number()