quietgarden/elm-web3/2.0.0

NOTE: the latest version is 2.0.1

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/quietgarden/elm-web3 is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 2.0.0 found (5 same-name repos checked); no cached copy. Use another version.

Details

Web3.Block

Block number and block data queries.

-- One-shot block number query:
port web3Cmd : Json.Encode.Value -> Cmd msg
port web3Sub : (Json.Decode.Value -> msg) -> Sub msg


type Msg = GotBlock Block.Msg | ...


subscriptions model =
    web3Sub (Json.Decode.decodeValue Block.decoder >> Result.toMaybe >> Maybe.map GotBlock)


fetchBlock : Platform.Cmd msg
fetchBlock =
    web3Cmd (Block.encode (Block.getBlockNumber "my-id"))
type Cmd
= RequestBlockNumber String
| RequestBlock BlockNumber String
| WatchBlockNumber String
| RequestBlockTxCount BlockNumber String

Commands to query block data via port.

type Msg
= GotBlockNumber String Int
| GotBlock String Block
| GotBlockTxCount String Int

Messages from the JS block port.

type alias Block =
{ number : Int
, hash : String
, timestamp : Int
, gasLimit : BigInt
, gasUsed : BigInt
, baseFeePerGas : Maybe BigInt
, parentHash : String
}

A block header with key fields.

getBlockNumber : String -> Cmd

Request the current block number. The id is echoed back in the response.

getBlock : BlockNumber -> String -> Cmd

Request a specific block by block number. The id is echoed back.

watchBlockNumber : String -> Cmd

Start polling the block number every 4 seconds. The id tags each GotBlockNumber response so you can distinguish multiple watchers.

Request the number of transactions in a block. The second argument is a request ID.

encode : Cmd -> Value

Encode a Cmd for the JS port.

decoder : Decoder Msg

Decode Msg responses from the JS port.