{"id":20093943,"url":"https://github.com/api3dao/chains","last_synced_at":"2025-05-06T04:32:26.165Z","repository":{"id":151645805,"uuid":"608654728","full_name":"api3dao/chains","owner":"api3dao","description":"The single source of truth for chain-related data across API3 projects","archived":true,"fork":false,"pushed_at":"2025-02-24T10:10:41.000Z","size":1279,"stargazers_count":4,"open_issues_count":13,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-23T13:14:24.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://api3.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/api3dao.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-02T13:22:24.000Z","updated_at":"2025-02-24T15:23:18.000Z","dependencies_parsed_at":"2023-10-30T13:39:06.589Z","dependency_job_id":"3529c3c7-64dd-418b-96e8-fe6c120ecddd","html_url":"https://github.com/api3dao/chains","commit_stats":null,"previous_names":[],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api3dao%2Fchains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api3dao%2Fchains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api3dao%2Fchains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/api3dao%2Fchains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/api3dao","download_url":"https://codeload.github.com/api3dao/chains/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252622469,"owners_count":21777994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T16:48:54.368Z","updated_at":"2025-05-06T04:32:25.855Z","avatar_url":"https://github.com/api3dao.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003e\nAPI3 chains\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm version](https://img.shields.io/npm/v/%40api3%2Fchains)](https://www.npmjs.com/package/@api3/chains)\n![downloads per week](https://img.shields.io/npm/dw/%40api3%2Fchains)\n[![continuous build](https://img.shields.io/github/actions/workflow/status/api3dao/chains/continuous-build.yml?label=build)](https://github.com/api3dao/chains/actions/workflows/continuous-build.yml)\n[![provider checks](https://img.shields.io/github/actions/workflow/status/api3dao/chains/check-providers.yml?label=provider%20checks)](https://github.com/api3dao/chains/actions/workflows/check-providers.yml)\n[![license](https://img.shields.io/npm/l/%40api3%2Fchains)](https://www.npmjs.com/package/@api3/chains)\n\n\u003c/div\u003e\n\n\u003ch4 align=\"center\"\u003e\nThe single source of truth for chain-related information across API3 projects\n\u003c/h4\u003e\n\n## 📦 Installation\n\n```sh\nnpm install @api3/chains --save\nyarn add @api3/chains\npnpm add @api3/chains\n```\n\n## 📖 API\n\nThe following variables/functions are exported from this package\n\n### CHAINS\n\nThe single source of truth for the list of supported chains.\nA static array of `Chain` objects.\n\n```ts\nimport { CHAINS } from '@api3/chains';\nconsole.log(CHAINS);\n/*\n[\n  {\n    name: 'Arbitrum Sepolia testnet',\n    alias: 'arbitrum-sepolia-testnet',\n    id: '421614',\n    ...\n  },\n  ...\n]\n*/\n```\n\n### hardhatConfig.networks()\n\nReturns an object where the key is each chain's alias and the value is an object that can be used as the `networks` field of [`hardhat.config.js`](https://hardhat.org/hardhat-runner/docs/config).\n\nThe default `url` values can be overridden with chain specific environment variables. These environment variables take the form of `HARDHAT_HTTP_RPC_URL_${toUpperSnakeCase(chain.alias)}`. e.g. `HARDHAT_HTTP_RPC_URL_ARBITRUM_SEPOLIA_TESTNET`.\n\n```ts\nimport { hardhatConfig } from '@api3/chains';\nconsole.log(hardhatConfig.networks());\n/*\n{\n  \"arbitrum-sepolia-testnet\": {\n      accounts: { mnemonic: '' },\n      chainId: '421614',\n      url: 'https://...',\n  },\n  ...\n}\n*/\n```\n\n### hardhatConfig.etherscan()\n\nReturns an object where the key is each chain's alias and the value is an object that can be used as the `etherscan` field of [`hardhat.config.js`](https://hardhat.org/hardhat-runner/docs/config) (requires the [`hardhat-etherscan` plugin](https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-etherscan)).\n\nNOTE: [hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) requires us to use a dummy API key with Blockscout block explorer APIs. We use \"DUMMY_VALUE\" but it could have been anything else.\n\n```ts\nimport { hardhatConfig } from '@api3/chains';\nconsole.log(hardhatConfig.etherscan());\n/*\n{\n  apiKey: {\n    'arbitrumSepolia': { ... }\n  },\n  customChains: [\n    ...\n  ]\n}\n*/\n```\n\n### hardhatConfig.getEnvVariableNames()\n\nReturns an array of expected environment variable names for chains that have an API key required for the explorer. The array also includes a single `MNEMONIC` variable that can be used to configure all networks.\n\nNOTE: Each `ETHERSCAN_API_KEY_` and `HARDHAT_HTTP_RPC_URL_` environment variable has the chain alias as a suffix, where the alias has been converted to upper snake case.\n\n```ts\nimport { hardhatConfig } from '@api3/chains';\nconsole.log(hardhatConfig.getEnvVariableNames());\n/*\n[\n  'MNEMONIC',\n  'ETHERSCAN_API_KEY_ARBITRUM_SEPOLIA_TESTNET',\n  ...\n  'HARDHAT_HTTP_RPC_URL_ARBITRUM_SEPOLIA_TESTNET',\n  ...\n]\n*/\n```\n\n### viemConfig.chains()\n\nReturns an array of chains in the format that [Viem](https://viem.sh/docs/chains/introduction) expects. Each Chain object can be used to [create a Viem public client](https://viem.sh/docs/clients/public#usage).\n\nAdditional `rpcUrls` values can (optionally) be added through the use of environment variables. These environment variables take the form of `API3_CHAINS_HTTP_RPC_URL_${toUpperSnakeCase(chain.alias)}`. If a matching environment variable is detected for a given chain, then it will be added to the `http` array of the `rpcUrls.environment` object. If no matching environment variable is detected, then the `http` array is left empty.\n\n```ts\nimport { viemConfig } from '@api3/chains';\nconsole.log(viemConfig.chains());\n/*\n[\n  {\n    id: 421613,\n    name: 'arbitrum-sepolia-testnet',\n    network: 'arbitrum-sepolia-testnet',\n    rpcUrls: { default: ..., public: ..., environment: ... }\n    ...\n  },\n  ...\n]\n*/\n```\n\n### Types\n\nTypes are also exported and can be found in `src/types.ts`.\nTypes are generated from [zod](https://github.com/colinhacks/zod) schemas.\nThese schemas are also used to validate each chain.\n\n## 📄 Scripts\n\nThe following utility scripts are available\n\n### generate:chains\n\nGenerates the latest `CHAINS` array and outputs the file to `src/generated/chains.ts`\n\n```sh\npnpm generate:chains\n```\n\n### providers:ping\n\nIterates through the list of chains to check that the chain is configured correctly and is responsive.\n\n```sh\npnpm providers:ping\n```\n\n## 🛠️ Development\n\nThe most common type of change would be adding or updating a chain. This can be done by creating or editing the relevant JSON file in the `chains/` directory.\n\nIf any changes are made to chains, you will need to \"regenerate\" the chains. This will compile all of the JSON files into a single TypeScript file for projects to import. This can be done with the following command\n\n```sh\npnpm generate:chains\n```\n\nThe list of TypeScript chains is also validated against all of the list of JSON files to ensure that everything is in sync.\n\nNOTE: You will not be able to push changes to chains without having regenerated the TypeScript chains.\n\n### Validation\n\nValidations can be run with the following commands.\n\n```sh\n# Validate each chain JSON file conforms to the zod schemas\npnpm validate:chains\n\n# Run all validations\npnpm validate\n```\n\n## 🚢 Releasing\n\nReleasing new versions is handled automatically with [changesets](https://github.com/changesets/changesets). Pull requests should include a changeset file before being merged.\nThese can be generated by running `pnpm changeset` and following the instructions. Once a new version is ready to be released, simply merge `main` into the `production`\nbranch. Changeset files will be consolidated into a single new version and that version released to npm.\n\n\u003c!-- markdown-link-check-disable --\u003e\n\nMore information is contained in the [API3 guidelines](https://github.com/api3dao/tasks/blob/main/API3%20Packages/changeset.md).\n\n\u003c!-- markdown-link-check-enable --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi3dao%2Fchains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapi3dao%2Fchains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapi3dao%2Fchains/lists"}