dm3
dm3 copied to clipboard
Write own ethers provider to support multiple chains (backend side)
- [ ] Use correct provider based on namespace e.g.
.bnb
,.eth
- [ ] Use chain config like hardhat does it https://hardhat.org/hardhat-runner/docs/config
The Lib should contain a hardcoded mapping of specific networks and their corresponding contracts. In addition, a deliveryService operator could also add providers for other networks as well using the config.yml file.
To enable a network the deliveryService operator has to add the rpc URL of the network to the config.yml file.
In order to create providers for all supported networks at startup, the deliveryService parses the config.yml as described below
A=> Config.yml contains RPC address for a network specified within the Lib -> Add provider based on the config specified within in Lib B=> Config.yml contains RPC address,chainID,EnsRegistryAddr for a network specified within the Lib -> Use the values specified in the config.yaml to override the default setting of the Lib C=> Config.yml contains RPC address,chainID,EnsRegistryAddr for a network NOT specified within the Lib -> Create a new provider based on the values specified in the config.yaml D=> Config.yml contains something else or is missing a required field -> Throw exception; The delivery service won't start until the config is fixed
The network section of the config.yml should look like
networks
eth:
url: foo.bar
cg:
url: cg.rpc
ensRegistry: "0x..."
chainID: 1234