Overview
Chain configuration utilities and constants for Ethereum, Base, Arbitrum, and BNB Chain. Includes RPC URLs, explorer links, Aave v3 addresses, Morpho Blue addresses, and asset configurations.
Functions
getChainConfig
Retrieves the configuration for a supported chain by chain ID.
function getChainConfig ( chainId : number | null | undefined ) : ChainConfig | null
chainId
number | null | undefined
required
The numeric chain ID (e.g., 1 for Ethereum, 8453 for Base)
The chain configuration object, or null if the chain is not supported
Example:
import { getChainConfig } from "@/lib/chains" ;
const ethereumConfig = getChainConfig ( 1 );
if ( ethereumConfig ) {
console . log ( ethereumConfig . name ); // "Ethereum"
console . log ( ethereumConfig . aaveV3PoolAddress );
console . log ( ethereumConfig . rpcUrl );
}
const unsupported = getChainConfig ( 999 );
console . log ( unsupported ); // null
Constants
SUPPORTED_CHAINS
Array of all supported chain configurations.
const SUPPORTED_CHAINS : readonly ChainConfig [] = [
{
id: 1 ,
name: "Ethereum" ,
nativeSymbol: "ETH" ,
rpcUrl: "https://rpc.ankr.com/eth" ,
explorerBaseUrl: "https://etherscan.io" ,
aaveV3PoolAddress: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2" ,
aaveV3WethGatewayAddress: "0x893411580e590D62dDBca8a703d61Cc4A8c7b2b9" ,
aaveV3ProtocolDataProviderAddress: "0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3" ,
aaveV3PoolAddressesProvider: "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e" ,
aaveV3UiPoolDataProviderAddress: "0x91c0eA31b49B69Ea18607702c5d9aC360bf3dE7d" ,
aaveV3UiIncentiveDataProviderAddress: "0x162A7AC02f547ad796CA549f757e2b8d1D9b10a6" ,
morphoBlueAddress: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb" ,
},
// ... Base, Arbitrum, BNB Chain
]
Supported Networks:
Show Ethereum Mainnet (Chain ID: 1)
{
"id" : 1 ,
"name" : "Ethereum" ,
"nativeSymbol" : "ETH" ,
"rpcUrl" : "https://rpc.ankr.com/eth" ,
"explorerBaseUrl" : "https://etherscan.io" ,
"aaveV3PoolAddress" : "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2" ,
"morphoBlueAddress" : "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
}
Show Base (Chain ID: 8453)
{
"id" : 8453 ,
"name" : "Base" ,
"nativeSymbol" : "ETH" ,
"rpcUrl" : "https://mainnet.base.org" ,
"explorerBaseUrl" : "https://basescan.org" ,
"aaveV3PoolAddress" : "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5" ,
"morphoBlueAddress" : "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
}
Show Arbitrum One (Chain ID: 42161)
{
"id" : 42161 ,
"name" : "Arbitrum" ,
"nativeSymbol" : "ETH" ,
"rpcUrl" : "https://arb1.arbitrum.io/rpc" ,
"explorerBaseUrl" : "https://arbiscan.io" ,
"aaveV3PoolAddress" : "0x794a61358D6845594F94dc1DB02A252b5b4814aD" ,
"morphoBlueAddress" : "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
}
Show BNB Chain (Chain ID: 56)
{
"id" : 56 ,
"name" : "BNB Chain" ,
"nativeSymbol" : "BNB" ,
"rpcUrl" : "https://bsc-dataseed.binance.org" ,
"explorerBaseUrl" : "https://bscscan.com" ,
"aaveV3PoolAddress" : "0x6807dc923806fE8Fd134338EABCA509979a7e0cB" ,
"morphoBlueAddress" : "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
}
CHAIN_ASSETS
Token configurations for USDC and BTC collateral on each supported chain.
const CHAIN_ASSETS : Record < SupportedChainId , ChainAssets > = {
1 : {
usdc: { symbol: "USDC" , address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" , decimals: 6 },
btcCollateral: { symbol: "WBTC" , address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" , decimals: 8 },
},
8453 : {
usdc: { symbol: "USDC" , address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" , decimals: 6 },
btcCollateral: { symbol: "cbBTC" , address: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf" , decimals: 8 },
},
42161 : {
usdc: { symbol: "USDC" , address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831" , decimals: 6 },
btcCollateral: { symbol: "WBTC" , address: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f" , decimals: 8 },
},
56 : {
usdc: { symbol: "USDC" , address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d" , decimals: 18 },
btcCollateral: { symbol: "BTCB" , address: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c" , decimals: 18 },
},
}
Example:
import { CHAIN_ASSETS } from "@/lib/assets" ;
const ethereumUsdc = CHAIN_ASSETS [ 1 ]. usdc ;
console . log ( ethereumUsdc . address ); // "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
console . log ( ethereumUsdc . decimals ); // 6
const baseCollateral = CHAIN_ASSETS [ 8453 ]. btcCollateral ;
console . log ( baseCollateral . symbol ); // "cbBTC"
Type Definitions
ChainConfig
Configuration object for a supported blockchain network.
type ChainConfig = {
id : SupportedChainId ;
name : string ;
nativeSymbol : string ;
rpcUrl : string ;
explorerBaseUrl : string ;
aaveV3PoolAddress : `0x ${ string } ` | null ;
aaveV3WethGatewayAddress : `0x ${ string } ` | null ;
aaveV3ProtocolDataProviderAddress : `0x ${ string } ` | null ;
aaveV3PoolAddressesProvider : `0x ${ string } ` | null ;
aaveV3UiPoolDataProviderAddress : `0x ${ string } ` | null ;
aaveV3UiIncentiveDataProviderAddress : `0x ${ string } ` | null ;
morphoBlueAddress : `0x ${ string } ` | null ;
};
Chain ID: 1 (Ethereum), 8453 (Base), 42161 (Arbitrum), or 56 (BNB Chain)
Human-readable chain name
Native token symbol (e.g., “ETH”, “BNB”)
Aave v3 Pool contract address
Aave v3 WETH Gateway contract address
aaveV3ProtocolDataProviderAddress
Aave v3 Protocol Data Provider contract address
aaveV3PoolAddressesProvider
Aave v3 Pool Addresses Provider contract address
aaveV3UiPoolDataProviderAddress
Aave v3 UI Pool Data Provider contract address
aaveV3UiIncentiveDataProviderAddress
Aave v3 UI Incentive Data Provider contract address
Morpho Blue protocol contract address
SupportedChainId
type SupportedChainId = 1 | 8453 | 42161 | 56
Union type of supported chain IDs.
ChainAssets
Token configurations for a specific chain.
type ChainAssets = {
usdc : TokenConfig ;
btcCollateral : TokenConfig ;
};
TokenConfig
ERC-20 token configuration.
type TokenConfig = {
symbol : string ;
address : `0x ${ string } ` ;
decimals : number ;
};
Token symbol (e.g., “USDC”, “WBTC”, “cbBTC”)
Number of decimals (e.g., 6 for USDC, 8 for WBTC, 18 for most ERC-20s)
Usage Examples
Multi-Chain Transaction Building
import { getChainConfig } from "@/lib/chains" ;
import { CHAIN_ASSETS } from "@/lib/assets" ;
import { encodeAaveRepay } from "@/lib/protocols/aave" ;
async function repayOnChain ( chainId : number , userAddress : Address ) {
const config = getChainConfig ( chainId );
if ( ! config ?. aaveV3PoolAddress ) {
throw new Error ( "Aave not supported on this chain" );
}
const assets = CHAIN_ASSETS [ chainId as SupportedChainId ];
const repayCalldata = encodeAaveRepay ({
asset: assets . usdc . address ,
amount: 1000000 n , // 1 USDC (6 decimals)
interestRateMode: 2 n ,
onBehalfOf: userAddress ,
});
// Submit to Aave Pool on the target chain
return {
to: config . aaveV3PoolAddress ,
data: repayCalldata ,
};
}
Explorer Link Generation
import { getChainConfig } from "@/lib/chains" ;
function getTransactionUrl ( chainId : number , txHash : string ) : string {
const config = getChainConfig ( chainId );
return config ? ` ${ config . explorerBaseUrl } /tx/ ${ txHash } ` : "" ;
}
function getAddressUrl ( chainId : number , address : string ) : string {
const config = getChainConfig ( chainId );
return config ? ` ${ config . explorerBaseUrl } /address/ ${ address } ` : "" ;
}