Conversions and Helpers
Useful helpers for concise value declarations.
txParams : Send
txParams =
{ to = Just myContract
, from = Nothing
, gas = Nothing
, gasPrice = Just (gwei 3)
, value = Just (eth 3)
, data = Just data
, nonce = Nothing
}
gwei : Basics.Int -> BigInt
eth : Basics.Int -> BigInt
Helpers for dealing with floats.
Eth Unit Useful for displaying to, and taking user input from, the UI
toWei : EthUnit -> String -> Result String BigInt
Convert a given stringy EthUnit to it's Wei equivalent
toWei Gwei "50" == Ok (BigInt.fromInt 50000000000)
toWei Wei "40.9123" == Ok (BigInt.fromInt 40)
toWei Kwei "40.9123" == Ok (BigInt.fromInt 40912)
toWei Gwei "ten" == Err
fromWei : EthUnit -> BigInt -> String
Convert stringy Wei to a given EthUnit
fromWei Gwei (BigInt.fromInt 123456789) == "0.123456789"
fromWei Ether (BigInt.fromInt 123456789) == "0.000000000123456789"
Note Do not pass anything larger than MAX_SAFE_INTEGER into BigInt.fromInt MAX_SAFE_INTEGER == 9007199254740991
bigIntToWei : EthUnit -> BigInt -> BigInt
Convert a given BigInt EthUnit to it's Wei equivalent