1

In hardhat, you can get the chainId by calling await getChainId(). However, I'm looking for the chain name. Is there a way to get the chain name without explicitly creating a mapping myself?

EDIT: You can only use this getChainId functionality with hardhat-deploy

4

1 回答 1

1

Hardhat core package doesn't include any map from chainId to the chain name.

But:

  • They have a mapping in the Etherscan integration package (GitHub source).
  • You can define the map in your application according to the EIP-155 where the list of chain IDs was first introduced, or the expanded list (anyone can add to this list - GitHub).
于 2021-04-02T18:38:16.210 回答