Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: token chain json examples #59

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions packages/metadata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# ZKchainHub - Metadata Package

## Overview

This package contains providers for fetching chains and tokens metadata.

### chains.json

This file contains an array of Chain metadata. To add a new one, follow the following interface:

```json
{
"chainId": 324, //mandatory
"name": "ZKsyncERA", //mandatory
"iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/24091.png", //optional
"publicRpcs": [
"https://mainnet.era.zksync.io",
"https://zksync.drpc.org",
"https://zksync.meowrpc.com"
], //optional,
"explorerUrl": "https://explorer.zksync.io/", //optional
"launchDate": 1679626800, //mandatory
"chainType": "Rollup", // "Rollup" | "Validium"
"baseToken": {
"name": "Ether", //mandatory
"symbol": "ETH", //mandatory
"type": "native", // "native" | "erc20"
"contractAddress": null, // null if "native", address if "erc20"
"imageUrl": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628", //optional
"decimals": 18 //mandatory
}
}
```

### tokens.json

This file contains an array of Token metadata. To add a new one, follow the following interface:

```json
{
"name": "0x Protocol Token", //mandatory
"symbol": "ZRX", //mandatory
"contractAddress": "0xE41d2489571d322189246DaFA5ebDe1F4699F498", // null if "native", address if "erc20"
"imageUrl": "https://assets.coingecko.com/coins/images/863/large/0x.png?1696501996", //optional
"type": "erc20", // "native" | "erc20"
"decimals": 18 //mandatory
}
```

Currently, there are three different providers:

- `LocalFileMetadataProvider`
- `GithubMetadataProvider`
- `StaticMetadataProvider`

Inside [examples](./examples/) folder, you'll find json examples. Copy it to your local machine and edit metadata as wanted. Also, you can use it to host your own file on Github (recommended)

At [ZKchainHub-metadata repository](https://github.com/defi-wonderland/ZKchainHub-metadata) you'll find the latest curated list of tokens. To use it, remember to copy file url as raw content.

> https://raw.githubusercontent.com/defi-wonderland/ZKchainHub-metadata/79779a6313ab43af055f59861be012bf67bb908d/chains_mainnet.json

## 📋 Prerequisites

- Ensure you have `node >= 20.0.0` and `pnpm >= 9.5.0` installed.

## Installation

```bash
$ pnpm install
```

## Building

To build the monorepo packages, run:

```bash
$ pnpm build
```

## Test

```bash
# unit tests
$ pnpm run test

# test coverage
$ pnpm run test:cov
```

## Contributing

To create a new provider, create it inside [`providers`](./src/providers/) folder and implement the [`IMetadataProvider`](./src/interfaces/metadata.interface.ts) interface.

Then, write the configuration interface inside [`metadataConfig.interface.ts`](./src/interfaces/metadataConfig.interface.ts) and add the provider to the [`MetadataProviderFactory`](./src/factory/index.ts) class.

Finally, export the provider and required files in [`external.ts`](./src/external.ts).
40 changes: 40 additions & 0 deletions packages/metadata/examples/chains.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
{
"chainId": 324,
"name": "ZKsyncERA",
"iconUrl": "https://s2.coinmarketcap.com/static/img/coins/64x64/24091.png",
"publicRpcs": [
"https://mainnet.era.zksync.io",
"https://zksync.drpc.org",
"https://zksync.meowrpc.com"
],
"explorerUrl": "https://explorer.zksync.io/",
"launchDate": 1679626800,
"chainType": "Rollup",
"baseToken": {
"name": "Ether",
"symbol": "ETH",
"contractAddress": null,
"type": "native",
"imageUrl": "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628",
"decimals": 18
}
},
{
"chainId": 388,
"name": "Cronos",
"iconUrl": "https://zkevm.cronos.org/images/chains/zkevm.svg",
"chainType": "Validium",
"publicRpcs": ["https://mainnet.zkevm.cronos.org"],
"explorerUrl": "https://explorer.zkevm.cronos.org/",
"baseToken": {
"symbol": "zkCRO",
"name": "zkCRO",
"contractAddress": "0x28Ff2E4dD1B58efEB0fC138602A28D5aE81e44e2",
"type": "erc20",
"imageUrl": "https://zkevm.cronos.org/images/chains/zkevm.svg",
"decimals": 18
},
"launchDate": 1679626800
}
]
Loading