burnable-tech/elm-ethereum/1.0.2

Renamed to team-toast/elm-ethereum. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as burnable-tech/elm-ethereum still install under that name. 3 versions of 3 come from the new location (see their notes).

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/team-toast/elm-ethereum.

What we checked: The repo moved to github.com/team-toast/elm-ethereum. Rebuilt with git archive from commit e79bdd0efe57 of https://github.com/team-toast/elm-ethereum (zip prefix burnable-tech-elm-ethereum-e941bde/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 01059137ad1764d5dd33de9f23e5d647595ca709.

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/burnable-tech/elm-ethereum/zipball/1.0.2/

Eth.Utils

String/Type Conversion and Application Helpers

Address

toAddress : String -> Result String Address

Safely convert a string into an address.

All lowercase or uppercase strings, shaped like addresses, will result in Ok. Mixed case strings will return Err if the EIP-55 checksum is invalid.

addressToString : Address -> String

Convert an Address to a String

addressToChecksumString : Address -> String

Convert an Address to a string conforming to the EIP-55 checksum.

Note: This lowercases all the characters inside the Address and runs it through the checksum algorithm.

isAddress : String -> Bool

Check if given string is a valid address.

Note: Works on mixed case strings, with or without the 0x.

isChecksumAddress : String -> Bool

Check if given string is a valid checksum address.

Hex

toHex : String -> Result String Hex

Safely convert a string into Hex.

hexToString : Hex -> String

Convert a Hex into a string.

isHex : String -> Bool

Check if given string is valid Hex

hexToAscii : Hex -> Result String String

Convert Given Hex into ASCII. Will fail if Hex is an uneven length.

hexToUtf8 : Hex -> Result String String

Convert Given Hex into UTF8. Will fail if Hex is an uneven length.

hexAppend : Hex -> Hex -> Hex

Append two Hex's together.

hexAppend (Hex 0x12) (Hex 0x34) == Hex 0x1234
hexConcat : List Hex -> Hex

Concatenate a list of Hex's

hexConcat [ Hex 0x12, Hex 0x34, Hex 0x56 ] == Hex 0x 00123456

Transaction Hash

toTxHash : String -> Result String TxHash

Safely convert a string to a TxHash.

txHashToString : TxHash -> String

Convert a given TxHash to a string.

isTxHash : String -> Bool

Check if given string is a valid TxHash.

i.e. Hex and 64 characters long.

Block Hash

toBlockHash : String -> Result String BlockHash

Safely convert a given string to a BlockHash.

blockHashToString : BlockHash -> String

Convert a given BlockHash to a string.

isBlockHash : String -> Bool

Check if given string is a valid BlockHash.

i.e. Hex and 64 characters long.

SHA3

functionSig : String -> Hex

Convert a contract function name to it's 4-byte function signature.

Utils.functionSig "transfer(address,uint256)" == Hex "a9059cbb"
keccak256 : String -> Hex

Hash a given string into it's SHA3/Keccak256 form.

isSha256 : String -> Bool

Checks if a given string is valid hex and 64 chars long.

lowLevelKeccak256 : List Int -> List Int

Same as ethereum_keccak_256 from this library.

Unsafe

User beware!! These are sidestepping the power of Elm, and it's static types.

Undoubtedly convenient for baking values, like contract addresses, into your source code.

All values coming from the outside world, like user input or server responses, should use the safe functions.

unsafeToHex : String -> Hex
unsafeToAddress : String -> Address
unsafeToTxHash : String -> TxHash
unsafeToBlockHash : String -> BlockHash

Application Helpers

type alias Retry =
{ attempts : Int
, sleep : Float
}

Config for a retry task

retry : Retry -> Task x a -> Task x a

Retry a given Task till it succeeds, or runs out of time.

The below will wait for 5 minutes until giving up, and polls every 5 seconds.

pollForMinedTx : HttpProvider -> TxHash -> Task Http.Error TxReceipt
pollForMinedTx ethNode txHash =
    Eth.getTxReceipt ethNode txHash
        |> retry { attempts = 60, sleep = 5 }
valueToMsg : (a -> msg) -> (Error -> msg) -> Decoder a -> Value -> msg

Useful for decoding past a result straight into a Msg. Comes in handy with Eth.Sentry.Event values.

transferDecoder : Value -> Msg
transferDecoder =
    valueToMsg Transfer Error transferEventDecoder


type Msg
    = Transfer (Event Transfer)
    | Error String