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"))Messages from the JS block port.
A block header with key fields.
Request the current block number. The id is echoed back in the response.
Request a specific block by block number. The id is echoed back.
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.
Commands to query block data via port.