@venusprotocol/chains
v0.15.0
Published
This package lists all the chain-related metadata for the Venus Protocol.
Keywords
Readme
Venus Protocol - chains package
This package lists all the chain-related metadata for the Venus Protocol.
Getting started
Set environment variables
Create a .env file in the root of the project using the .env.template file as a template.
Chains
Chain IDs are exported via the ChainId enum. Chains are exported via the chains constant.
import { chains, ChainId } from '@venusprotocol/chains';
console.log(chains[ChainId.BSC_MAINNET].name); // Outputs "BNB Chain"Tokens
Retrieving tokens and vTokens
Tokens and vTokens are exported via the tokens constant.
import { tokens, vTokens, ChainId } from '@venusprotocol/chains';
console.log(tokens[ChainId.BSC_MAINNET][0].symbol);
console.log(vTokens[ChainId.BSC_MAINNET][0].symbol);The library also exports a getToken function to retrieve a singular token on a given chain using
its symbol. The symbol parameter is not case-sensitive.
import { getToken, ChainId } from '@venusprotocol/chains';
const xvs = getToken({
chainId: ChainId.BSC_MAINNET,
symbol: 'XVS',
});
console.log(xvs?.symbol); // "XVS"The icon source of a vToken can be retrieved using the getVTokenIconSrc function:
import { getVTokenIconSrc, ChainId } from '@venusprotocol/chains';
const vTokenIconSrc = getVTokenIconSrc({
chainId: ChainId.BSC_MAINNET,
vTokenAddress: '0x6bCa74586218dB34cdB402295796b79663d816e9', // vWBNB market
});Adding a token
Add the token icon into the images directory, then run the command yarn
generate to update the token manifest. You can then list the
token in any of the token metadata files.
VTokens are automatically generated by making calls to an RPC provider.
