View Source Ethers.Utils (Ethers v0.0.1-dev)
Utilities for interacting with ethereum blockchain
Link to this section Summary
Functions
Convert WEI to ETH
Decode from hex with (or without) 0x prefix.
Encode to hex with 0x prefix.
Converts a hexadecimal integer to integer form
Converts integer to its hexadecimal form
Adds gas limit estimation to the parameters if not already exists
Converts ETH to WEI
Link to this section Functions
@spec from_wei(non_neg_integer()) :: float()
Convert WEI to ETH
examples
Examples
iex> Ethers.Utils.from_wei(1000000000000000000)
1.0
iex> Ethers.Utils.from_wei(3140000000000000000)
3.14
Decode from hex with (or without) 0x prefix.
examples
Examples
iex> Ethers.Utils.hex_decode("0x6574686572735f6578")
{:ok, "ethers_ex"}
iex> Ethers.Utils.hex_decode("6574686572735f6578")
{:ok, "ethers_ex"}
Encode to hex with 0x prefix.
examples
Examples
iex> Ethers.Utils.hex_encode("ethers_ex")
"0x6574686572735f6578"
Converts a hexadecimal integer to integer form
examples
Examples
iex> Ethers.Utils.hex_to_integer("0x11111")
{:ok, 69905}
Converts integer to its hexadecimal form
examples
Examples
iex> Ethers.Utils.integer_to_hex(69905)
"0x11111"
Adds gas limit estimation to the parameters if not already exists
@spec to_wei(number()) :: non_neg_integer()
Converts ETH to WEI
examples
Examples
iex> Ethers.Utils.to_wei(1)
1000000000000000000
iex> Ethers.Utils.to_wei(3.14)
3140000000000000000