@faremeter/info
@faremeter/info centralizes metadata and helpers for producing Coinbase x402 payment requirement payloads. It wraps the shared @faremeter/types schemas with typed builders so callers can focus on business logic instead of boilerplate defaults.
- Compatible with Node 18+ (ESM) and TypeScript 5.2+.
- Depends on sibling packages
@faremeter/types/evmand@faremeter/types/solanafor address validation.
Quick start
Export overview
Utility types
UnitInput: union ofstring | numberused for human-readable amount inputs while preserving precision when converted to strings.addX402PaymentRequirementDefaults(req): fillsdescriptionandmimeTypewith Coinbase x402 defaults before returning the partially constructed requirement. Use it when assembling custom payloads to keep consistency with other builders.
Solana module (solana)
Network helpers
KnownCluster,isKnownCluster(value): whitelist and guard for supported clusters (devnet,testnet,mainnet-beta).lookupX402Network(cluster): expands a Solana cluster into the identifiers expected by downstream x402 middleware (adds the plainsolanaalias for mainnet-beta).
KnownSPLToken,isKnownSPLToken(token): currently limited toUSDC, extendable in code.lookupKnownSPLToken(cluster, token): returns the mint address and atoUnithelper for formatting amounts, orundefinedwhen the token is unsupported on that cluster.
x402Exact(args): returns an array of payment requirement objects (one per network alias) with schemeexact. Throws if the token/cluster pair is unknown. Internally applies a 60 second timeout to match Coinbase middleware defaults.xSolanaSettlement(args): builds a single requirement using the custom@faremeter/x-solana-settlementscheme. Accepts either"sol"or aKnownSPLToken; throws for unsupported assets.
EVM module (evm)
Network helpers
KnownX402Network,isKnownX402Network(name): guard the curated list of Base and SKALE network identifiers.lookupKnownX402Network(name): returns chain metadata (currently justchainId) for known networks.lookupX402Network(chainId): maps a numericchainIdto the known key when possible or falls back to aneip155:{chainId}string.
KnownAsset,isKnownAsset(asset): presently supportsUSDC.lookupKnownAsset(network, asset): resolves contract metadata, optional forwarder details, and atoUnithelper. Accepts either a known network key or numericchainId.findAssetInfo(network, assetOrInfo): convenience wrapper that accepts a raw asset name (using the catalog) or a customContractInfoobject. Throws for unknown assets or unsupported networks.
evm.x402Exact(args): creates a singleexactscheme requirement with a 300 second timeout. Throws if the asset is unknown for the specified network.
Usage patterns
Multi-chain payment requirements
Custom requirement with defaults
Error handling
- Builder functions throw when asked for unsupported assets, clusters, or networks. Surface these to integrators (e.g., HTTP 400) so they can correct configuration.
- Catalog guards (
isKnownCluster,isKnownSPLToken,isKnownAsset,isKnownX402Network) are designed for pre-validation when consuming user input.
Extending the catalog
When adding new assets or tokens, update the relevant constants insrc/solana.ts or src/evm.ts and expand the documentation accordingly. Ensure:
- The mint/contract addresses are accurate per network.
toUnitimplementations return stringified amounts in the denomination expected by downstream settlement logic.- Tests or examples cover the new asset to prevent regressions.
Related references
@faremeter/types: canonical x402 schemas and validation helpers.@faremeter/facilitator: consumes these requirement builders when orchestrating multi-network payment flows.