我希望使用MetaMask发送ETH或ERC20令牌
下面的脚本是抛出错误,
RPC错误:错误: 0.001号的事务值无效,必须在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) {
}); 发布于 2020-03-17 08:10:29
In Ether, the smallest unit of the currency is wei, and 1 ETH === 10^18 wei var weiValue = web3.utils.toWei('1',‘醚’);// 1醚 console.log(weiValue);//1000000000000000000
发布于 2022-07-28 01:28:08
MetaMask不再注入web3。有关详细信息,请参阅:https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3
https://stackoverflow.com/questions/56751888
复制相似问题