With injected provider (MetaMask) web3.eth.sendTransaction fails
Closed this issue · 4 comments
Description
I encounter this error when I try to call to a contract for the browser:
Wrong response id alc-web3:0 (expected: 8) in {"jsonrpc":"2.0","id":8,"method":"eth_sendTransaction","params":[{"value":"0xde0b6b3a7640000","from":"0x308163aea0cae49b4d4014374ae77f8cb6a6142e","to":"0xf1f364b55200b999768ea4329891833576ea4916","gas":"0x15f90","data":"0x8a83fbeb000000000000000000000000000000000000000000000000000000000000029b","gasPrice":"0x3b9aca00"}]}
The transaction is accepted in the MetaMask popup.
Snippet
const injectedProvider = window.ethereum ?? window.web3?.currentProvider
const w3 = createAlchemyWeb3(
'wss://eth-mainnet.ws.alchemyapi.io/ws/<...>',
injectedProvider ? { writeProvider: injectedProvider } : undefined,
)
w3.eth.handleRevert = true
try {
await web3.eth.sendTransaction({
value: web3.utils.toWei('1', 'ether'),
from: account,
to: contractAddress,
gas: 90000,
data: contract.methods.send().encodeABI(),
})
} catch (err) {
// error can't be caught here
console.error(err)
}
We just run into the same error... :(
Hello all,
Thank you for the report! I have reproduced the bug and am working on a fix. I'll let you know when I have more information.
This should be fixed in version 1.0.2. Thank you once again for the report!
Thank you @dphilipson!