@parallel-protocol/chains
v0.5.0
Published
Parallel Protocol on-chain catalogue — chain ids, contract addresses, viem-typed ABIs
Readme
@parallel-protocol/chains
On-chain catalogue for the Parallel Protocol — viem chain objects, Parallel-specific contract addresses, and viem-typed ABIs.
Install
npm install @parallel-protocol/chains viemviem is a peer dependency.
Design
Each entry in CHAINS_STATIC is a Parallel overlay on top of a canonical
viem Chain object:
interface ChainStaticConfig {
viem: ViemChain; // id, name, native currency, RPCs, explorers, multicall3 — from viem/chains
status: ChainStatus; // "active" | "paused" | "sunset"
lzEid: number; // LayerZero V2 endpoint id
contracts: ChainContracts; // Parallel-specific: usdp, parallelizer, susdp, bridgeableUsdp, …
}viem stays the source of truth for chain id, name, native currency, default RPCs, block explorers, and multicall3. The two chains that don't ship multicall3 in viem (hyperEvm, hemi) get the canonical address injected.
Usage
import {
CHAINS_STATIC,
ACTIVE_CHAINS,
PARALLELIZER_CHAINS,
getUSDpAddress,
isParallelizerChain,
} from "@parallel-protocol/chains";
CHAINS_STATIC.ethereum.viem.id; // 1
CHAINS_STATIC.ethereum.viem.name; // "Ethereum"
CHAINS_STATIC.ethereum.contracts.parallelizer;
// → "0x6efeDDF9269c3683Ba516cb0e2124FE335F262a2"
ACTIVE_CHAINS;
// → ["ethereum", "base", "arbitrum", …] (status: "active")
isParallelizerChain("ethereum"); // true
getUSDpAddress("base"); // "0x76A9A0062ec…"Metered x402 payments (scheme upto) settle through the UptoEscrow contract, deployed per chain. UPTO_CHAINS lists the chains that carry one and getUptoEscrowAddress returns it; payers and facilitators take the address from here, never from an invoice.
import { UPTO_CHAINS, getUptoEscrowAddress } from "@parallel-protocol/chains";
UPTO_CHAINS; // → ["base"]
getUptoEscrowAddress("base"); // "0xcCA03ed95Ab…"ABIs are exposed under the /abi subpath:
import { PARALLELIZER_ABI, ERC20_ABI, UPTO_ESCROW_ABI } from "@parallel-protocol/chains/abi";Payment tokens
getTokenDecimals is the single source of truth for the decimals of every
Parallel payment token — USDp, sUSDp, USDC and the Parallelizer backing
collaterals — so merchant and payer sides price amounts identically:
import { getTokenDecimals, COLLATERAL_TOKENS } from "@parallel-protocol/chains";
getTokenDecimals("base", "0x76A9A0062ec…"); // 18 (USDp)
getTokenDecimals("base", "0x833589fCD6…"); // 6 (USDC)
getTokenDecimals("base", "0x820C137fa7…"); // 18 (USDS, a backing collateral)
getTokenDecimals("base", "0xdead…"); // undefined — outside the catalogue
COLLATERAL_TOKENS.base; // { "0x820c…": { symbol: "USDS", decimals: 18 }, … }Values are verified on-chain and immutable per token; undefined lets callers
decide their own fallback for tokens outside the catalogue.
Staking
SPRL2_CHAIN_ADDRESSES lists the sPRL2 v2 vault per chain (Ethereum and Base),
BPT_POOL_IDS the Balancer V3 80PRL/20WETH pool it stakes on each of them (on
V3 the pool id is the BPT address), and SPRL2_V2_ABI its interface.
SPRL2_ADDRESS, BPT_POOL_ID and SPRL2_ABI are kept for existing code: the
first two now point at the Ethereum v2 vault and pool, the ABI is still the v1
one. SPRL2_V1_ADDRESS is the paused v1 vault and SPRL2_MIGRATOR_ADDRESS the
contract that moves a v1 position to v2 on Ethereum. PRL_CHAIN_ADDRESSES and
WETH_CHAIN_ADDRESSES give the pool's two tokens on each chain, and
REWARD_MERKLE_DISTRIBUTOR_CHAIN_ADDRESSES the epoch reward distributor per
chain (Base since the migration, Polygon for the legacy history).
Composing your RPC layer
Pass .viem straight to createPublicClient — RPC URLs are intentionally
not bundled so consumers stay free to pick Alchemy, Infura, public RPCs, or
any combination:
import { createPublicClient, http } from "viem";
import { CHAINS_STATIC, PARALLELIZER_ABI } from "@parallel-protocol/chains";
const eth = createPublicClient({
chain: CHAINS_STATIC.ethereum.viem,
transport: http(`https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`),
});
const fees = await eth.readContract({
address: CHAINS_STATIC.ethereum.contracts.parallelizer!,
abi: PARALLELIZER_ABI,
functionName: "getCollateralRatio",
});License
MIT
