Multichain applications setup a network/chain config that could be simplified to an object where each key is a unique ID for a supported chain such as the chainId
as follows:
// typescript:
enum ChainIds {
Ethereum = 1,
BSC = 56,
AVAX = 43114,
};
const NetworkConfig = {
[ChainIds.Ethereum]: {
blockTime: 15_000, // 15s/block
gasLimit: 15_000_000 // 15m/block
},
[ChainIds.BSC]: {
blockTime: 3_000, // 3s/block
gasLimit: 100_000_000 // 100m/block
},
[ChainIds.AVAX]: {
blockTime: 3_000, // 3s/block
gasLimit: 8_000_000 // 8m/block
},
};
const chainId = 1; // how to get the chainId in subgraph environment
const gasPerS = NetworkConfig[chainId].gasLimit/NetworkConfig[chainId].blockTime;
This is one way of developing a subgraph in a network agnostic way, however I couldn't find any way to get the chainId
from within a subgraph in thegraphs documentation. Is it possible to do so and if not how could/should a subgraph be developed in a chain agnostic manner.