I want use MetaMask to send ETH or ERC20 Tokens
The following script i am using is throwing error,
RPC Error: Error: Invalid transaction value of 0.001 number must be in wei
const method = 'eth_sendTransaction'
const parameters = [{
from: account,
to: to,
value: 0.001
}]
const from = account
const payload = {
method: method,
params: parameters,
from: from,
}
web3.currentProvider.sendAsync(payload, function (err, response) {
});
In Ether, the smallest unit of the currency is wei, and 1 ETH === 10^18 wei
var weiValue = web3.utils.toWei('1', 'ether'); // 1 ether
console.log(weiValue);//1000000000000000000