This is a simple Express-based API for managing and fetching token information across multiple blockchain networks. The API allows you to get token data from a local registry and, if unavailable, fetch it from an RPC endpoint.
-
Clone the repository:
git clone https://github.com/gluexprotocol/tokens_registry.git cd tokens_registry
-
Install dependencies:
npm install
-
Build the server:
npm run build
-
Start the server:
npm run start
The server will run at
http://localhost:3000
.
- Ensure you have the following files:
./registry
: Contains token registry data../chains/metadata.json
: Contains metadata for different blockchain networks.
Returns a simple greeting message.
Request:
curl http://localhost:3000/
Response:
Hello, world!
Fetches all tokens, optionally filtered by specified chains.
Query Parameters:
chains
(optional): A comma-separated list of chain names.
Request Example:
curl "http://localhost:3000/tokens?chains=ETH,BNB"
Response Example:
{
"tokens": {
"1": [
{ "symbol": "ETH", "address": "0x..." },
{ "symbol": "USDC", "address": "0x..." }
],
"56": [
{ "symbol": "BNB", "address": "0x..." }
]
}
}
Fetches token information for a specific chain and token symbol.
Query Parameters:
chain
(required): Name of the blockchain.token
(required): Token symbol or Token's contract Address.
Request Example:
curl "http://localhost:3000/token?chain=ethereum&token=ETH"
Response Example (from registry):
{
"symbol": "ETH",
"address": "0x..."
}
Response Example (if not in registry, fetched from RPC):
{
"symbol": "ETH",
"address": "0x...",
"decimals": 18
}
├── src
│ ├── index.ts # Main server file
│ ├── routes
│ │ ├── index.ts # TokenRegistry class
│ │ ├── rpc.ts # RPCFetch class
│ │ ├── token.ts # Tokens route class
│ ├── chains
│ │ ├── metadata.json # Blockchain metadata
├── registry # Token registry files
├── package.json
├── README.md
This project is licensed under the MIT License - see the LICENSE file for details.
Currently deployed at
https://exchange-rates.gluex.xyz