dm3 icon indicating copy to clipboard operation
dm3 copied to clipboard

Write own ethers provider to support multiple chains (backend side)

Open hai-ko opened this issue 2 years ago • 2 comments

  • [ ] Use correct provider based on namespace e.g. .bnb, .eth
  • [ ] Use chain config like hardhat does it https://hardhat.org/hardhat-runner/docs/config

hai-ko avatar Jan 10 '23 09:01 hai-ko

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

AlexNi245 avatar Jan 19 '23 11:01 AlexNi245

The network section of the config.yml should look like

networks
  eth: 
    url: foo.bar
  cg:
    url: cg.rpc
    ensRegistry: "0x..."
    chainID: 1234
    

AlexNi245 avatar Jan 19 '23 11:01 AlexNi245