intrepidshape/elm-web3/1.0.0

NOTE: the latest version is 3.0.0

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/IntrepidShape/elm-web3.

What we checked: The repo moved to github.com/IntrepidShape/elm-web3 and tag 1.0.0 is there; its commit 9d919244f65e is from 2026-05-09 11:48 UTC, before the version was published (2026-05-09 11:58 UTC); elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one (GitHub's zip no longer comes out byte for byte the same), so the contents were checked instead.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/intrepidshape/elm-web3/zipball/1.0.0/

Web3.Units

ETH / ERC-20 unit conversion — pure Elm, no JS required.

formatEther (BigInt.fromInt 1500000000000000000) == "1.5"
parseEther "1.5" == Just <1500000000000000000>
formatEther : BigInt -> String

Convert Wei to a human-readable ETH string with up to 18 significant decimal places. Trailing zeros are trimmed.

formatEther zero         == "0"
formatEther (10^18 wei)  == "1"
formatEther (1.5×10^18)  == "1.5"
formatEther (10^15 wei)  == "0.001"
parseEther : String -> Maybe BigInt

Parse a human-readable ETH string to Wei. Returns Nothing for invalid input, non-numeric strings, or negative values.

parseEther "1"                       == Just <10^18>
parseEther "1.5"                     == Just <1.5×10^18>
parseEther "0.000000000000000001"    == Just (BigInt.fromInt 1)
parseEther "not-a-number"            == Nothing
parseEther "-1"                      == Nothing
formatUnits : Int -> BigInt -> String

Convert a token amount (in its smallest unit) to a human-readable string for a token with the given number of decimal places. Trailing zeros are trimmed.

formatUnits 6 (BigInt.fromInt 1500000)  == "1.5"   -- USDC
formatUnits 8 (BigInt.fromInt 100000000) == "1"    -- WBTC
parseUnits : Int -> String -> Maybe BigInt

Parse a human-readable token amount to its smallest unit, given the token's decimal count. Returns Nothing for invalid or negative input.

parseUnits 6 "1.5"  == Just (BigInt.fromInt 1500000)   -- USDC
parseUnits 6 "0"    == Just BigInt.zero
parseUnits 6 "-1"   == Nothing