Skip to content

Instantly share code, notes, and snippets.

@javier-tarazaga
Created March 24, 2020 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javier-tarazaga/4ab80dc58d2d0e8523ec29963b5b974c to your computer and use it in GitHub Desktop.
Save javier-tarazaga/4ab80dc58d2d0e8523ec29963b5b974c to your computer and use it in GitHub Desktop.
const { SuperHDWalletProvider, ManualSignProvider } = require("super-web3-provider");
...
The rest of your configuration here
...
// IMPORTANT: We need to globally store these providers here due to the fact that Truffle decides to call
// the provider() function multiple times during a deployment, therefore we would be re-creating
// a deployment on every call.
let rinkebyMetamaskProvider;
module.exports = {
...
networks: {
...
rinkeby_metamask: {
provider: () => {
// Let's not double create the provider (as we will create many deployments) as Truffle calls this function many times (◔_◔)
if (!rinkebyMetamaskProvider) {
rinkebyMetamaskProvider = new ManualSignProvider({
projectId,
projectToken,
from: '0x742980bB2B17ca355Fef76969326bab47c27baD4',
endpoint: 'https://rinkeby.infura.io/v3/14a9bebf5c374938b2476abe29ca5564',
networkId: '4',
})
}
return rinkebyMetamaskProvider;
},
network_id: '4'
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment