Metamasks injected web3 gives an error when using web3.eth.sendTransaction()
web3.eth.sendTransaction({from:web3.eth.accounts[0], to:'', data: // hash to interact with contraact, gas:85000});
What would be a way to use Metamask to have a website prompt a user to sign a transaction ?
Best Answer
You're missing the last argument to
sendTransaction
, the callbackfunction(error, transactionHash) { ... }
The MetaMask FAQ states:
All Async - Think of MetaMask as a light client
So all calls to web3.js should have a callback as their last argument: the only calls where that's not needed are for
web3.eth.accounts
andweb3.eth.coinbase
. The generic form of the callback isfunction(error, result)
.