I ran the truffle box react example with Metamask disabled and the stored value is correctly shown as 5.

simpleStorageInstance.set(5, {from: accounts[0]})

However when I enable the Metamask plugin in Chrome, the Metamask window appears asking for the transaction to be approved, before the SimpleStorage method set is called.

Question: Why was the transaction automatically approved/signed when Metamask is disabled, but not when Metamask is enabled?

My Guess: Is this because when Metamask is disabled, the web3 provider used is the one Truffle provided, and running truffle develop started a testrpc where all accounts are unlocked and thus require no approval for any transactions?

1 Answer 1


Your guess is entirely right. The truffle box code is configured to use the web3 provider injected into the browser through plugins first (MetaMast, Mist, Toshi, etc.), but there is a fallback which uses the local testrpc: https://github.com/truffle-box/react-box/blob/fafbd7ae6151338d570f2556fb322e8439552a75/client/src/utils/getWeb3.js#L20

The test PC automatically accepts all calls made to it and fulfills them using the accounts and keys it has created. In its default state it executes those generating new blocks instantaneously. This is great for testing and automation--you don't want to have to wait 1-3 minutes per function call before you can verify your code works.

The confirmation dialog is provided by MetaMask as a feature to you--it receives the call, prompts you to accept or reject that call, signs it instead with the key you have stored in MetaMask, and then transmits the transaction to the blockchain--likely in this case back to testrpc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.