
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
evm-chainlist
Advanced tools
chainlist for easy manage and access to EVM-based Chains information
the project is a library for interacting with metadata of the Chain. It provides a set of functions for reading metadata to the chain object, managing listings.
when your project need maintain multiple chain or access the metadata of chains, chainlist can help you.
npm i evm-chainlist
or
yarn add evm-chainlist
EVM_CHAINLIST_DISABLE_AUTOLOAD Disable autoload the data of chains, will export an empty instance of Chains. only Node.js environmentEVM_CHAINLIST_DATA_DIR This contains the path to the directory containing your chains files, them will be autoload to instance of Chains, default read process.cwd() + '/chains' directory, the file extension can be .json, .json5, .yaml, .yml, the chains data must includes name and chainId fields. only Node.js environmentWe have some metadata for chains. you can find them here ethereum-lists/chains.
const ethereumMetadata = {
"name": "Ethereum Mainnet",
"chain": "ETH",
"icon": "ethereum",
"features": [{ "name": "EIP155" }, { "name": "EIP1559" }],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://ethereum.org",
"shortName": "eth",
"chainId": 1,
"networkId": 1,
"code": "ethereum"
};
const rinkebyMetadata = {
"name": "Rinkeby",
"title": "Ethereum Testnet Rinkeby",
"chain": "ETH",
"nativeCurrency": {
"name": "Rinkeby Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://www.rinkeby.io",
"shortName": "rin",
"chainId": 4,
"networkId": 4,
"status": "inactive"
};
const goerliMetadata = {
"name": "Goerli",
"title": "Ethereum Testnet Goerli",
"chain": "ETH",
"nativeCurrency": {
"name": "Goerli Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://goerli.net/#about",
"shortName": "gor",
"chainId": 5,
"networkId": 5,
"testnet": true,
"alias": {
"internal": "goerli"
}
};
It's like access ordinary JSON objects, but it provide index and useful methods
import { Chain } from 'evm-chainlist';
// Get ethereum
const ethereum = new Chain(ethereumMetadata);
const rinkeby = new Chain(rinkebyMetadata);
// Get goerli, and set indexes
const goerli = new Chain(goerliMetadata, {indexes: ['alias.internal']});
// Access metadata
console.log(ethereum.get('nativeCurrency.name')); // Output: Ether
console.log(ethereum.name); // Output: Ethereum Mainnet
console.log(ethereum.infoURL); // Output: https://ethereum.org
console.log(goerli.title); // Output: Ethereum Testnet Goerli
// Default indexes: name, chainId, networkId
console.log(goerli.equal('Ethereum Mainnet'); // Output: true
console.log(ethereum.equal(1); // Output: true
console.log(ethereum.equal('ethereum')); // Output: false
// Specify indexes
console.log(goerli.equal('goerli')); // Output: true
console.log(goerli.indexes()); // Output: ['alias.internal']
console.log(goerli.indexValues()); // Output: ['goerli']
// Provide methods
console.log(ethereum.isTestnet(), goerli.isTestnet()); // Output: false true
console.log(rinkeby.supportFeature('EIP155')); // Output: false
console.log(goerli.active(), rinkeby.inactive()); // Output: true true
// ...
Some businesses only support some chains
import { ChainList } from 'evm-chainlist';
// Instantiate by Chain or metadata
const list = new ChainList([ethereumMetadata, rinkebyMetadata]);
// Add Chain
list.add(new Chain(goerliMetadata, {indexes: ['alias.internal']}));
// Access chain by index value
const ethereum = list.get(1);
console.log(ethereum.name); // Output: Ethereum Mainnet
const goerli = list.get('goerli');
console.log(goerli.name); // Output: Goerli
console.log(list.include(4)); // Output: true
// Del chain by index value
list.del('Rinkeby');
// ...
Global access all chain and list.
import { Chains } from 'evm-chainlist';
const data = [{
"name": "Ethereum Mainnet",
"chainId": 1
}, {
"name": "OP Mainnet",
"chainId": 10
}, {
"name": "Binance Smart Chain",
"chainId": 56
}, {
"name": "Kovan",
"chainId": 42
}, {
"name": "Rinkeby",
"chainId": 4
}];
// Instantiate by Chain or metadata
const chains = new Chains(data, {lists: {
'business1': [1, 56, 5],
}});
// Add Chain
chains.addChain(new Chain({
"name": "Goerli",
"chainId": 5,
"alias": {
"internal": "goerli"
}
}, {indexes: ['alias.internal']}));
const rinkeby = chains.getChain(4);
console.log(rinkeby.name); // Output: Rinkeby
// Add ChainList
chains.addChainList('test', ['goerli', 42]);
// Access ChainList
const testList = chains.getChainList('test');
console.log(testList.include(5)); // Output: true
// ...
This module will autoload the chains data and export the instance of Chains;
import chains, { Chains } from 'evm-chainlist';
// import defaults the instance of Chains through auto load your project 'chains' directory
console.log(chains instanceof Chinas); // Output: true
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request. Make sure to read the contribution guidelines before getting started.
This project is licensed under the MIT License.
FAQs
This library for easy manage and access to EVM-based Chains information
The npm package evm-chainlist receives a total of 2 weekly downloads. As such, evm-chainlist popularity was classified as not popular.
We found that evm-chainlist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.