Block
Utilities & types for working with Blocks as defined in the Execution API specification
Examples
Converting from RPC Format
Blocks can be converted from RPC format to internal format using Block.fromRpc
:
import 'ox/window'
import { Block } from 'ox'
const block = await window.ethereum!
.request({
method: 'eth_getBlockByNumber',
params: ['latest', false],
})
.then(Block.fromRpc)
{ // ... hash: '0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd', number: 19868020n, size: 520n, timestamp: 1662222222n, // ... }
Functions
Name | Description |
---|---|
Block.fromRpc | Converts a Block.Rpc to an Block.Block . |
Block.toRpc | Converts a Block.Block to an Block.Rpc . |
Types
Name | Description |
---|---|
Block.Block | A Block as defined in the Execution API specification. |
Block.Hash | A Block hash. |
Block.Number | A Block number. |
Block.Rpc | An RPC Block as defined in the Execution API specification. |
Block.Tag | A Block Tag as defined in the Execution API specification. |