trufflesuite/drizzle

Connect to blockchain even if the wallet provider hasn’t been enabled or has timed out

vladmee opened this issue · 1 comments

Hi! I want to set my Infura provider as default for my dapp, regardless of the user having a wallet installed, enabled, or connected. Providing it as a 'customProvider' in the 'drizzleOptions' file doesn't work as it still tries to connect to the wallet provider (ie. MetaMask)

There is a way to have the following priority of providers in drizzle:

  1. Infura provider ALWAYS
  2. Wallet provider (ie. Metamask) ONLY IF the user specifically asks to connect within the dapp
  3. Fallback if everything else fails (the fallback currently works for me)

Here's my drizzleOptions configuration:
const options = { web3: { block: false, customProvider: new Web3("wss://mainnet.infura.io/ws/v3/API_KEY"), fallback: { type: "ws", url: fallbackUrl, }, }, contracts: [Contract], events: {}, syncAlways: true, polls: { accounts: 1500, }, };

Any help is appreciated. Thank you!

Looking to do that too. @vladmee did you get to do it?
Can we just set Infura as fallback if MetaMask is not connected?