我用trezor的签名实现事务。但是我错误地说,尽管以太坊在两个钱包中,但资金却不足。
const trezorTransaction = async (value) => {
window.web3 = new Web3(new Web3.providers
.HttpProvider('https://kovan.infura.io/v3/adde26ec7b994797923aae6cdea28a63'));
const addressN = "m/44'/60'/0'/0";
const nonce = '00';
const gasPrice = (new BigNumber(web3.toWei('20', 'gwei'))).toString(16);
const gasLimit = (new BigNumber(21000)).toString(16);
const from = '0x5A224c68c74d989AAb41467AFC57794D0eCA8964';
const to = '0x5a938517b029c256e6f2f18d99558f01a0208cb2';
const currentValue = web3.toHex(web3.toWei(value, 'ether'));
const trezorSignParams = {
path: addressN,
transaction: {
from,
to,
value: currentValue,
chainId: 42,
nonce,
gasLimit,
gasPrice,
},
};
const signedTr = await TrezorConnect.ethereumSignTransaction(trezorSignParams);
const Tx = EthereumTx;
const rawTx = {
nonce: '0x00',
gasPrice: addHexPrefix(gasPrice),
gasLimit: addHexPrefix(gasLimit),
to: walletPath,
from,
value: currentValue,
...signedTr.payload,
};
const tx = new Tx(rawTx);
const serializedTx = tx.serialize();
web3.eth.sendRawTransaction(`0x${serializedTx.toString('hex')}`, (err, hash) => {
if (err) {
console.log(err);
}
if (!err) {
console.log(hash);
}
});
};
错误:
"Insufficient funds.
The account you tried to send transaction from does not have enough funds.
Required 1000420000000000000 and got: 0."
我还想了解如何找出并指定正确的随机数? 我也不明白您如何找到注销以太坊的必要钱包。