Skip to content

Types

The wire types: what a node or wallet sends and receives. Each is a module that exports an Effect Schema and the TypeScript type it decodes to. They belong to the JSON-RPC layer and are imported from @ethect/core/rpc.

import { Effect } from "effect";
import type { Receipt } from "@ethect/core/rpc";
import { Eth } from "@ethect/core/rpc";
// Name a type in your own signatures.
const failed = (receipt: Receipt.Receipt): boolean => receipt.status === "reverted";
const check = (hash: `0x${string}`) =>
Effect.map(Eth.getTransactionReceipt(hash), (receipt) =>
receipt === null ? undefined : failed(receipt),
);

Every module follows the same pattern.

Export Is Example
X.schema the schema of the module’s main shape Receipt.schema
X.X the type that schema decodes to Receipt.Receipt
X.nameSchema the schema of another shape of the module Block.headerSchema, Receipt.statusSchema
X.Name the type of that shape Block.Header, Receipt.Status
import type { Block, Transaction } from "@ethect/core/rpc";
import { Log, Receipt } from "@ethect/core/rpc";
type Header = Block.Header;
type Eip1559 = Transaction.Eip1559;
Receipt.schema; // decodes a receipt
Log.schema; // decodes a log

The same rules hold for every type. Values on the wire explains them.

On the wire In code
a large quantity: wei, gas, a block number, a timestamp bigint
a small quantity: a chain id, a nonce, an index, a count number
an address Address.Address, lowercase, and sent in its EIP-55 form
a hash, bytes `0x${string}`
a type or status code a name: "eip1559", "success"
a field a node may omit or send as null an optional field
a field that is null in a known situation a field typed | null
a field the schema does not know dropped
Type Describes
Block a block: its header, with transaction hashes, or with transactions in full
BlockId how a call names a block: a number, a tag, or a hash object
Transaction a signed transaction as a node returns it, one shape per type
TransactionRequest a transaction as a caller describes it
Receipt what executing a transaction did
Log an event log
Filter which logs to match
FeeHistory what eth_feeHistory returns
AccessList the addresses and slots a transaction declares it touches
Authorization an EIP-7702 authorization
Withdrawal a validator withdrawal
Proof a Merkle proof of an account and its storage
Account an account’s state
SyncStatus whether a node is syncing, and how far it is
ChainConfig the fork configuration a node runs
Capabilities what history a node keeps
BlockAccessList what a block read and wrote, per account
Type Describes
StateOverride state a call pretends is on chain
BlockOverride header fields a call pretends its block has
Simulate the payload and the result of eth_simulateV1
Type Describes
Trace the tracers a debug_trace* call can run
StructLog the struct logger: one log per opcode
CallFrame the callTracer: the tree of calls
Prestate the prestateTracer: the accounts touched
Type Describes
MineOptions what to mine
MinedBlock a mined block with what its transactions did
NodeInfo how a test node is set up
NodeMetadata what identifies a test node
TransactionPool the node’s transaction pool
Type Describes
WalletChain a chain as an app describes it to a wallet
WatchAsset a token an app suggests a wallet track
Permission a wallet permission
PermissionGrant permissions for a session key or account
Calls a batch of calls for a wallet to send
CallsStatus the status of a batch
WalletCapabilities the optional features of a wallet
WalletAsset the assets a wallet holds for an account
SubAccount an account owned by a wallet’s main account

A schema decodes data that did not come through a method, and encodes native values back to the wire.

import { Effect, Schema } from "effect";
import { Block } from "@ethect/core/rpc";
const decodeHeader = (json: unknown) =>
Schema.decodeUnknownEffect(Block.headerSchema)(json);
// Effect<Block.Header, Schema.SchemaError>
const encodeHeader = Schema.encodeEffect(Block.headerSchema);
// (header: Block.Header) => Effect<the wire object, Schema.SchemaError>

To add the fields of your chain to a type, see A wider result.