Ethex.Utils (Ethex v1.1.1)

View Source

Utils

Summary

Functions

From hex

Convert wei to eth.

Convert eth to wei.

Functions

from_hex(arg)

@spec from_hex(String.t()) :: integer()

From hex

Example

iex> Ethex.Utils.from_hex "0x2766"
10086

from_wei(number, decimals)

@spec from_wei(integer(), pos_integer()) :: float()

Convert wei to eth.

Example

iex> Ethex.Utils.from_wei(4011000000000000, 18)
0.004011

to_hex(number)

@spec to_hex(integer()) :: String.t()

To hex

Example

iex> Ethex.Utils.to_hex 10086
"0x2766"

to_wei(number, decimals)

@spec to_wei(number(), pos_integer()) :: integer()

Convert eth to wei.

Example

iex> Ethex.Utils.to_wei(0.1, 18)
100000000000000000