Add networks to a family
A family driver is written once, and every chain and network it serves is data: a ChainInfo with its NetworkInfo entries (identity, fee model, FinalityPolicy, default confirmations, reorgWindow, replacement rules, explorer templates), plus provider presets that map (chain, network, apiKey) to endpoints. So an EVM chain needs no new adapter.
evmChainPlugin from crypto-aio/evm serves your EVM chains with the built-in driver, for both libraries. It checks the data when called, or throws CONFIG_INVALID: family evm, nonce ordering, the secp256k1-ecdsa scheme, and per network the decimal chain id as identity, an evm-1559 or evm-legacy fee model, and finalized-tag or confirmation finality. A network removes the capabilities it lacks: finality-tag without the tag, fee-market-1559 on evm-legacy, and replace-fee and cancel without a mempool. Optional network params describe the chain further: minPriorityFeePerGas (a bigint tip floor), l1DataFee: 'op-stack' (transactions also pay an OP Stack L1 data fee), and systemLogs: 'bor' (a bor client's system logs on every receipt, as on Polygon PoS, which a plain transfer then ignores).
import { CryptoAio, type ChainInfo } from 'crypto-aio';
import { evmChainPlugin } from 'crypto-aio/evm';
const acme: ChainInfo = {
id: 'acmechain', family: 'evm', model: 'account', ordering: 'nonce', schemes: ['secp256k1-ecdsa'],
nativeAsset: { symbol: 'ACME', decimals: 18 }, defaultNetwork: 'mainnet',
networks: {
mainnet: {
id: 'mainnet', identity: '777', testnet: false, feeModel: 'evm-1559', // eth_chainId 777
finality: { kind: 'confirmations', confirmations: 12 },
capabilities: { remove: ['finality-tag'] }, // no `finalized` tag on this chain
defaultConfirmations: 1, reorgWindow: 128, replacement: { minBumpPercent: 10 },
},
},
};
const aio = new CryptoAio({ plugins: [evmChainPlugin({ name: 'acme', chains: [acme] })] });It registers as evm:acme and also takes presets and assets. An asset is an erc20 ref, registered under its EIP-55 checksummed contract whatever case it is given in, as the driver names the token in its transfers and balances, so its alias and its transfers share one asset id; a mixed-case contract with a wrong checksum is CONFIG_INVALID. Augment ChainRegistry with acmechain: { family: 'evm'; network: 'mainnet' } to type the handle and ext.evm.
The registry rules that apply today already set the limits. A chain id registers once (a second registration fails with CONFIG_INVALID, "already registered"), so nobody can add a network to an existing chain id from outside. A plugin can add a new chain id, and it can add presets, or adapters for another library, to chains that are already registered.
The TON family has no helper like evmChainPlugin: its two networks are built in, and this release offers no way to change their settings.