1

I'm trying to initiate a transaction onClick of a button on my UI, however on load web3.eth.accounts is returning emtpy, is this because Im running locally? does MetaMask not work locally?

Yet when I run 'web3.eth.accounts' in the console, it returns addresses relevant to MetaMask

1
  • Put more information....
    – Gawey
    Commented Jul 17, 2017 at 13:37

2 Answers 2

2

When you say "running locally", you make me think you're initializing a separate web3 object that is not initialized with MetaMask's provider object.

To use MetaMask accounts, you should be initializing any local web3 instance from the injected metamask provider, as shown in this example:

https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#partly_sunny-web3---ethereum-browser-environment-check

1
  • Thanks, yes this was the problem I was initializing a web3 object with both MetaMask and infura, this was conflicting with 'to: address' attribute and returning a invalid address error Commented Jul 18, 2017 at 9:08
0

You can configure Metamask to work with your local test node. On the top left corner where you see the fox icon wyou can click where it says Ethereium Main Network and select localhost:8545 or add a custom RPC address.

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.