TrueFiEng / useDApp

Framework for rapid Dapp development. Simple. Robust. Extendable. Testable
https://usedapp.io
MIT License
1.59k stars 370 forks source link

What's the standard way of adding chains? #346

Closed Oni-giri closed 2 years ago

Oni-giri commented 3 years ago

UseDapp provides a limited set of supported chains. However I can't seem to be able to configure it to work with alternative chains: is it a design choice or do I miss the "right" way of doing it?

Currently, the only way I see is to fork the repo and add manually the chain data in the constants folder.

Here is my (unfortunate) setup for arbitrum:

const config = {
  readOnlyChainId: 42220,
  supportedChains: [42220],
  multicallAddresses: {
    42220: '0xCe129333458f037867C81DFbD70E4D57A3b1c5eb',
}, 
  readOnlyUrls: {
    42161: 'https://arb-mainnet.g.alchemy.com/v2/API-KEY',
  },
}

While the DApp can connect to Metamask, it is unable to load the provider it appears as "undefined".

If there's no good way to do it, I guess adding support to manage it in the config should solve a good amount of issues, past, present and future.

christianvari commented 3 years ago

Agree with you, having the same problem developing a dapp on Cronos testnet

quagliero commented 3 years ago

@Oni-giri Yes I've found you can fake it to a degree using your own local version of ChainId that you extend, but it will ultimately fall over if the chain isn't in the core code. I suggest opening a PR like this one: https://github.com/EthWorks/useDApp/pull/336/files

Oni-giri commented 3 years ago

@Oni-giri Yes I've found you can fake it to a degree using your own local version of ChainId that you extend, but it will ultimately fall over if the chain isn't in the core code. I suggest opening a PR like this one: https://github.com/EthWorks/useDApp/pull/336/files

Since the owner isn't replying, I forked the repo and uploaded it on NPM, so that I don't have to think about it any more.

jcheese1 commented 2 years ago

hey @Oni-giri , did you get this to fix? I also forked and added arbitrum manually, but I'm getting message: "Internal JSON-RPC error."

Oni-giri commented 2 years ago

@yuyao17

You can either use https://www.npmjs.com/package/ethers-allstars-multicall, which is my fork of the package, or add those addresses, if you want to build it yourself:

const multicallAddresses = {
  1: '0xeefba1e63905ef1d7acba5a8513c70307c1ce441',
  3: '0xF24b01476a55d635118ca848fbc7Dab69d403be3',
  4: '0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821',
  5: '0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e',
  42: '0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a',
  56: '0x1Ee38d535d541c55C9dae27B12edf090C608E6Fb',
  100: '0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a',
  137: '0xc4f1501f337079077842343Ce02665D8960150B0',
  1337: '0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e',
  80001: '0x5a0439824F4c0275faa88F2a7C5037F9833E29f1',
  42161: '0x813715eF627B01f4931d8C6F8D2459F26E19137E', // Arbitrum Mainnet
  97: '0x6e5BB1a5Ad6F68A8D7D6A5e47750eC15773d6042', // BSC Testnet
  42220: '0xC1138494271E9312BFae15023d70Ce68085535da', // Celo Mainnet
  11297108109: '0x99a73dfE34578348fb81BD078201C0BA84E9c840', // Palm MN
  1666600000: '0xFE4980f62D708c2A84D3929859Ea226340759320', // Harmony MN
  250: '0xdc85396592f0F466224390771C861EE3957a3ff4', // Fantom MN
  361: '0xe2ec58a54f3ab2714eddbae87533793011f1e14e', // Theta MN
  1285: '0xa9177F8d98DAaB74C24715Ba0A81b73654710523', // Moonriver MN
  30: '0x6C62Bf5440de2cB157205B15C424BcEb5C3368F5' // RSK MN
jcheese1 commented 2 years ago

@Oni-giri ty. where do i put this info on this library though? or are you talking about something else?

Oni-giri commented 2 years ago

@Oni-giri ty. where do i put this info on this library though? or are you talking about something else?

https://github.com/EthWorks/useDApp/blob/daa3b7ed17ac08ad57203e2d9faa2bbaa4284e24/packages/core/src/constants/chainId.ts

Here ser.

item333 commented 2 years ago

@Oni-giri ty. where do i put this info on this library though? or are you talking about something else?

https://github.com/EthWorks/useDApp/blob/daa3b7ed17ac08ad57203e2d9faa2bbaa4284e24/packages/core/src/constants/chainId.ts

Here ser.

I'm also trying to use a unsupported chain. whenever useContractFunction the react site crashes with an error of unsupported chain. is there any way around this?

bashebr commented 2 years ago

Does this support Fantom testnet? if not, can I add to list of chainId and supprted chains?

Janmajayamall commented 2 years ago

Does this support Fantom testnet? if not, can I add to list of chainId and supprted chains?

No it does not. You can add it.

tt-marek commented 2 years ago

Closing for now, continued in #394