Skip to main content

Code Examples

Minimal developer examples connected to canonical topics.

Fetch a Block with JSON-RPC

Query a block by number through a JSON-RPC endpoint and inspect its basic fields.

Fetch a Transaction Receipt

Retrieve a transaction receipt and inspect status, gas usage, logs, and block placement.

Validate an Address Format

Perform basic client-side validation before presenting a blockchain address to a user.

Read a Contract Method

Call a read-only smart-contract method through an RPC provider.

Quote a Token Amount Safely

Demonstrate integer-safe token amount handling and decimal conversion without floating-point assumptions.

Identify Network and Chain ID

Detect the connected chain ID before sending a transaction or directing a user to a Layer-2 network.

RPC Failover Pattern

Try multiple RPC endpoints in sequence when the primary endpoint is unavailable.

Represent a Cross-Chain Message

Model a typed cross-chain message envelope for application-level validation.

Estimate Fixed Transaction Budget

Calculate a simple transaction budget when a network uses a predictable fixed transaction cost.

Agent Transaction Policy

Represent an allowlisted transaction policy for an autonomous software agent.