chainmap v0.0.236
πΊοΈ ChainMap
ChainMap provides a comprehensive map of EVM blockchain networks and their associated data. It includes information such as chain IDs, network names, RPC URLs, and currency details.
import chainMap from "chainmap";
import { JsonRpcProvider, formatUnits } from "ethers";
const ethereum = chainMap.ethereum.mainnet;
const provider = new JsonRpcProvider(ethereum.rpc[0]);
Features
- πΊοΈ A Comprehensive map of blockchain networks.
- π Includes chain IDs, network names, image assets, RPC URLs, and currency details.
- β‘οΈ Free RPC URLs for each network.
- π Built daily to ensure RPCs are working.
Installation
You can install ChainMap using npm/yarn/bun:
npm install chainmap
Supported Networks
Arbitrum Goerli (421613), Arbitrum Mainnet (42161), Arbitrum Nova (42170), Arbitrum Sepolia (421614), Avalanche C-chain (43114), Avalanche Fuji Testnet (43113), Base (8453), Binance SmartChain Mainnet (56), Binance SmartChain Testnet (97), Celo Alfajores Testnet (44787), Celo Baklava Testnet (62320), Celo Mainnet (42220), Cronos Mainnet (25), Ethereum Goerli (5), Ethereum Mainnet (1), Ethereum Sepolia (11155111), Fantom Opera (250), Fantom Testnet (4002), Gnosis (100), Harmony Mainnet Shard 0 (1666600000), Harmony Testnet Shard 0 (1666700000), Klayton Mainnet (8217), Moonbase Alpha (1287), Moonbeam (1284), Moonriver (1285), Moonrock (1288), OP Mainnet (10), Polygon (137), Polygon Mumbai (80001), Polygon Zkevm (1101), Polygon Zkevm Testnet (1442), Zora (7777777)
Usage
Get a specific chains data:
import chainMap from "chainmap";
chainMap.ethereum.mainnet.rpc; // <- an array of free RPC URLs
chainMap.ethereum.mainnet.chainId; // <- the chain ID e.g. "1"
chainMap.ethereum.mainnet.name; // <- the network name e.g. "Ethereum Mainnet"
chainMap.ethereum.mainnet.currency; // <- the currency details e.g. { name: "Ether", symbol: "ETH", decimals: 18 }
chainMap.ethereum.mainnet.explorerUrl; // <- the explorer URL e.g. "https://etherscan.io"
Get a chains data by its chain ID:
import chainMap from "chainmap";
const ethereumInfo = chainMap[1] // <- in this example '1' is the chain ID for Ethereum Mainnet.
ethereumInfo.rpc; // <- an array of free RPC URLs
... // etc
Docs
ChainInfo
: An object containing information about a blockchain.
Property | Type | Description |
---|---|---|
name | string | The name of the blockchain |
chainId | number | The ID of the blockchain |
rpc | string[] | An array of RPC URLs |
currency | CurrencyInfo | Information about the blockchain's currency |
explorerUrl | string (optional) | The URL of the blockchain's explorer (if available) |
iconUrl | string (optional) | The URL of the blockchain's icon (if available) |
CurrencyInfo
: An object containing information about a blockchain's currency.
Property | Type | Description |
---|---|---|
name | string | The name of the currency |
symbol | string | The symbol of the currency |
decimals | number | The number of decimal places for the currency |
iconUrl | string (optional) | The URL of the currency's icon (if available) |
Contributing
Chainmap source files are generated from specifications in data
directory. During the generation process, rpcs are tested to ensure they are working. If a network fails to connect, it is removed from the generated source files.
βοΈ Modify a network
Open the network data file data/<network>.list.ts
, and make your modifications, ensuring the
default exported Object still confroms to the ChainMap
interface.
β Add a network
Create a new file in the data
directory, named <network>.list.ts
. The file should export an object that conforms to the ChainMap
interface.
e.g. Creating a new network called mychain
with chain ID 1234
and RPC URL https://mychain.com
:
import { ChainMap } from "./types";
export const MYC {
name: "MyCoin",
symbol: "MYC",
decimals: 18,
}
export default {
mainnet: {
chainId: 1234,
name: "MyChain mainnet",
currency: MYC,
explorerUrl: "https://mychain.com",
rpc: [
"https://rpc.mychain.com",
"https://rpc2.mychain.com",
],
},
} as ChainMap; // <- ensures the object conforms to the ChainMap interface
Generate and build
Typically source files should be generated by the github action, but you can generate them locally using bun.
Prerequisites:
bun run generate
You can then build the distribution files:
bun run build
Testing networks
You can check that all network RPCs are working by running:
bun test
16 hours ago
2 days ago
3 days ago
4 days ago
5 days ago
6 days ago
8 days ago
7 days ago
9 days ago
10 days ago
11 days ago
12 days ago
13 days ago
14 days ago
15 days ago
16 days ago
17 days ago
18 days ago
19 days ago
20 days ago
21 days ago
22 days ago
23 days ago
24 days ago
25 days ago
26 days ago
28 days ago
27 days ago
29 days ago
30 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago