A community controlled repository of relay and parachain information in the Polkadot ecosystem.
The goals of this repo are:
- Provide a community-managed index of Polkadot parachains and their connection information (rpcs, chainspecs)
- Provide a source of chain and token assets across the ecosystem
- Enable developers to retrieve this information via an API suitable to their project (json/rest, npm soon™)
- Move towards a decentralised model
The files in this repo, data/chaindata.json
, data/testnets-chaindata.json
and data/evm-networks.json
are used to configure a GitHub workflow which scrapes information from each chain and publishes it as a collection of JSON files in the pub
directory of this repo.
The published files can be browsed at this URL: https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/index.txt
As an example, you could use this request to get a summary of all chains including the the names, logos, genesisHashes and address type prefixes:
const chainsSummaryUrl = "https://raw.githubusercontent.com/TalismanSociety/chaindata/main/pub/v1/chains/summary.json"
const summary = await fetch(chainsSummaryUrl).then(result => result.json())
For an example of a more advanced use-case, you can check out the Talisman wallet source code.
The wallet uses chaindata to populate a database of chains and tokens which is used for features like account balance subscriptions and sending funds.
When breaking changes are made to the format of the built chaindata files, we increment the pub
directory version.
Old directories are generally not kept up-to-date, but they are also not deleted.
The effect of this is that newer @talismn/balances
releases will target the newer pub
version, while older releases will continue to operate with the most up-to-date chaindata before the breaking change occurred.
A brief rundown of the changes introduced by each pub
version:
-
dist
->pub/v1
The miniMetadatas for thesubstrate-native
balance module now include types forBalances::Holds
andBalances::Locks
.
Without upgrading@talismn/balances
, these new types causePortableRegistry
to throw on construction of anew Metadata(miniMetadata)
. -
pub/v1
->pub/v2
All miniMetadatas have been upgraded from metadata format v14 to v15.
Without upgrading@talismn/balances
, the new format causes the library to throw.
To make a contribution, please fork this repo and make your changes in your fork, then open a PR to merge your changes back into this repo.
- Identify the chain
id
fromchaindata.json
ortestnets-chaindata.json
- Add your logo (in
svg
format) toassets/chains/${id}.svg
- Identify the chain
id
from https://chainlist.org
Use the base-10 id (e.g.1
, or137
), not the base-16 id (e.g.0x1
, or0x89
) - Add your logo (in
svg
format) toassets/chains/${id}.svg
- Identify the token symbol (e.g.
KSM
) - Add your logo (in
svg
format) toassets/tokens/${symbol}.svg
- Install
pnpm
via corepack by runningcorepack enable
on the command line - Clone the repo with
git clone git@github.com:TalismanSociety/chaindata.git
- Install the dependencies with
pnpm install
- Copy
.env.sample
to.env
and fill in the variables - Run the build with
pnpm build
Some files are edited manually, some other are generated automatically as part of the CI.
The table below describes the purpose of each file and how it is edited.
File name | Edit Type | Purpose |
---|---|---|
data/chaindata.json |
manual | A list of all parachains and relay chains in the Polkadot ecosystem |
data/testnets-chaindata.json |
manual | A list of all parachains and relay chains in the Polkadot ecosystem |
data/generated/chains-extras-cache.json |
automatic | Caches static data for each substrate chain |
data/evm-networks.json |
manual | List of EVM chains supported by default in Talisman |
data/generated/known-evm-networks.json |
automatic | List of EVM networks, generated from ethereum-lists |
data/known-evm-networks-overrides.json |
manual | Overrides to known-evm-networks.json , matched by chain id |
data/cache/known-evm-networks-icons-cache.json |
automatic | Caches images for each network defined in ethereum-lists |
data/cache/known-evm-tokens-cache.json |
automatic | Caches static data for ERC20 tokens |
There are a few sections in this repo which could do with a tidy up.
Here is a list of some of them, feel free to add more!
-
The use of relative logo paths vs absolute logo paths is confusing.
We should decide on one, and then also clear up exactly how it is that logos are handled in the repo.
Byclear up
, I mean to make the code easier to understand where possible, and to add docs anywhere it needs to remain complex.
It is currently unclear to contributors whether they only need to add their own logos, or if changes also need to be made to the files indata
. -
The code for merging
known-evm-networks.json
withevm-networks.json
is complex, stateful, full of side-effects and therefore difficult to re-use between the build stage and the fetch-external stage.
It is currently co-located inside ofscripts/build/steps/addEvmNetworks.ts
.
We should decide on a simpler mechanism for merging these two files, and extract the implementation of that into a util file.
An example of where this currently fails is inscripts/fetch-external/steps/fetchErc20TokenSymbols.ts
.
In here we append the two files like soconst allNetworks = knownEvmNetworks.concat(evmNetworks)
, which results in duplicate networks in theallNetworks
list.
This makes it difficult to e.g. extract a coingeckoId for a given erc20 contract address on a given network, since the code usingallNetworks
needs to account for duplicate networks with potentially conflicting information. -
Currently all of the EVM tokens are hydrated from known-tokens, while all substrate tokens are hydrated from tokens.json.
This is counter-intuitive, and so it leads to questions like "Why can I only see substrate tokens on chaindata? Are the EVM tokens missing / broken?"
We should either consolidate the two lists of tokens in one place, or change the naming used to clarify that not all tokens can be found in one place.
curl 'https://interface.gateway.uniswap.org/v1/graphql' \
-X 'POST' \
-H 'Content-Type: application/json' \
-H 'Origin: https://app.uniswap.org' \
--data-binary '{"operationName":"TopV2Pairs","variables":{"first":100,"chain":"ETHEREUM"},"query":"query TopV2Pairs($chain: Chain!, $first: Int!, $cursor: Float, $tokenAddress: String) {\n topV2Pairs(\n first: $first\n chain: $chain\n tokenFilter: $tokenAddress\n tvlCursor: $cursor\n ) {\n protocolVersion\n address\n }\n}"}'
Possible values for chain
when this was written:
ARBITRUM, AVALANCHE, ETHEREUM, ETHEREUM_GOERLI, ETHEREUM_SEPOLIA, OPTIMISM, POLYGON, CELO, BNB, BASE, BLAST