@ethernauta/core
v0.0.48
Published
Primitive Valibot schemas for Ethernauta — addresses, bytes, hashes, uints, hex.
Maintainers
Readme
Philosophy
This module is the canonical home of the primitive Valibot schemas used everywhere else in the monorepo — addresses, fixed-width byte sequences, uintN sizes, the 32-byte hash type, and a few small protocol primitives. Every other package depends on it; nothing here depends on the rest of the library.
The shapes mirror the Ethereum execution-apis base types. A schema in @ethernauta/core is the single source of truth — feature packages compose these primitives instead of redeclaring regexes.
Modules
- abi [NPM]
- chain [NPM]
- cli [NPM]
- core [NPM]
- crypto [NPM]
- eip [NPM]
- ens [NPM]
- erc [NPM]
- eth [NPM]
- react [NPM]
- transaction [NPM]
- transport [NPM]
- utils [NPM]
- wallet
API
Every export pairs a xxxSchema Valibot schema with an Xxx type inferred via v.InferOutput. The idiom across the monorepo is:
import { parse } from "valibot"
import { AddressSchema } from "@ethernauta/core"
function transfer(_to: string) {
const to = parse(AddressSchema, _to) // validated `Address`
// …
}Address
import { type Address, AddressSchema, AddressesSchema } from "@ethernauta/core"
// `AddressSchema` — single 0x-prefixed 20-byte address
// `AddressesSchema` — array of addressesHash
import { type Hash32, Hash32Schema } from "@ethernauta/core"
// `Hash32Schema` — 0x-prefixed 32-byte hash (transaction / block / topic)Bytes
import {
type Byte, ByteSchema,
type Bytes, BytesSchema,
type BytesMax32, BytesMax32Schema,
type Bytes4, Bytes4Schema,
type Bytes8, Bytes8Schema,
type Bytes32, Bytes32Schema,
type Bytes48, Bytes48Schema,
type Bytes64, Bytes64Schema,
type Bytes65, Bytes65Schema,
type Bytes256, Bytes256Schema,
} from "@ethernauta/core"
// `ByteSchema` — single 0x-prefixed byte
// `BytesSchema` — arbitrary 0x-prefixed byte string
// `BytesMax32Schema` — 0x-prefixed byte string ≤ 32 bytes
// `bytesNSchema` — fixed-width N-byte string (4, 8, 32, 48, 64, 65, 256)Unsigned integers
import {
type Uint, UintSchema,
type Uint8, Uint8Schema,
type Uint16, Uint16Schema,
type Uint24, Uint24Schema,
type Uint32, Uint32Schema,
type Uint40, Uint40Schema,
type Uint48, Uint48Schema,
type Uint56, Uint56Schema,
type Uint64, Uint64Schema,
type Uint96, Uint96Schema,
type Uint128, Uint128Schema,
type Uint160, Uint160Schema,
type Uint192, Uint192Schema,
type Uint224, Uint224Schema,
type Uint256, Uint256Schema,
} from "@ethernauta/core"
// One schema per ABI uintN width. All accept 0x-prefixed
// quantities, validated against `2^N - 1`.Ratio
import { type Ratio, RatioSchema } from "@ethernauta/core"
// A 0x-prefixed fraction in [0, 1] (used by tip / cap ratios).NotFound
import { type NotFound, NotFoundSchema } from "@ethernauta/core"
// The protocol's "absent" sentinel — `null` wrapped as a schema
// so JSON-RPC responses that may resolve to `null` (missing
// block, missing receipt) can be composed with `union([…, NotFoundSchema])`.