我正在开发一个自定义的ETH钱包,我能够通过使用虚荣心来生成公钥/私钥。在收到这个钱包中的金额后,我需要将ETH发送到另一个我试图使用web3的钱包。我该怎么做呢?钱包目前很少有ETH但是当我尝试用web3代码检查余额时它显示零余额。那么如何使用web3代码将ETH从一个钱包转移到另一个钱包,请咨询。
我的钱包地址余额代码如下。
<script src="./node_modules/web3/dist/web3.min.js"></script>
<script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log("Balance = " + web3.fromWei(web3.eth.getBalance('Wallet_address'), 'ether').toNumber());
</script>
试试这个。
web3.eth.sendTransaction({from: acct1, to:acct2, value: web3.toWei(1, 'ether'), gasLimit: 21000, gasPrice: 20000000000})
这就是我在以前的项目中执行以太事务的方式。同样在将来发布此处,暂时可能会让您更快地回复https://ethereum.stackexchange.com/