0

I'm trying to learn how web3 works and I'm creating a simple HTML page to send a transaction, but I'm getting the following error:

(inpage.js:1)   MetaMask - RPC Error: validateTxParams@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:80654
e/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:65579
_@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230907
[1286]</w/o._invoke@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230697
[1286]</E/</e[t]@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2231083
n@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630306
[254]</r.default/</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630285
S@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:930364
[254]</r.default/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630241
[25]</$</<.value</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:66281
e/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:64573
_@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230907
[1286]</w/o._invoke@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230697
[1286]</E/</e[t]@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2231083
n@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630306
[254]</r.default/</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630285
S@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:930364
[254]</r.default/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630241
[25]</$</<.value</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:65202
e/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:175590
_@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230907
[1286]</w/o._invoke@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2230697
[1286]</E/</e[t]@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:2231083
n@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630306
[254]</r.default/</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630285
S@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:930364
[254]</r.default/<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:630241
[70]</t.exports</<.value</<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:175752
[609]</t.exports/<.eth_sendTransaction<@moz-extension://e67892be-b68e-4c30-a024-c6ded3ddf733/background.js:1:1218722

Here's the code:

web3.eth.sendTransaction({
        from: '0xbe03ede9d060679c18df54dbdbde924b0261075b',
        to: "0xA396923aD14c3CcA2Af9D0C5BC97A5180416E700",
        value: "0.01"
    }, function(error, hash){
        alert(error);
    });
  • 1
    Change "0.01" to "10e+16". – goodvibration Jun 1 at 6:36
  • thanks. How can I estimate the gas if I'm sending data? I've found it's 21000 + 68*byte, but I'm guessing there's a better way of doing so @goodvibration – Johnny Jun 1 at 8:27
  • Are you asking this in order to determine the gas-limit? Just put in a little extra, you'll get back te difference between what you've put and what was actually used. – goodvibration Jun 1 at 9:14
2

Ethereum transaction don't accept float point as their value, the value will be send is the value in wei so if you want to send 0.01 ether u have to take 0.01 * 10 ^ 18 to get the wei and then send it. You can also use web3.eth.toWei

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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