web3js.eth.sendSignedTransaction 可以获取结果hash,但是有的可以转账成功,有的无法无法转账,也不能在链上查询到交易信息

酒透 酒透 提出于 2025-01-20 17:31 7656 浏览

转账部分的代码:

let txObject = {
    nonce: web3js.utils.toHex(txCount),
    from: from_address,
    to: coins[contract_name].address,
    gasLimit: web3js.utils.toHex(550000),
    gasPrice: web3js.utils.toHex(web3js.utils.toWei('10', 'gwei')),
    data: contractData,
}
const privateKey = Buffer.from(mainAddressSecret, 'hex');
const tx = new Tx(txObject, config.chain.getChain());
tx.sign(privateKey);

const serializedTx = tx.serialize()
const raw = '0x' + serializedTx.toString('hex');

web3js.eth.sendSignedTransaction(raw, (error, txHash) => {
    if (!error) {
        resolve(txHash);
    } else {
        ferror("send error" + error);
        reject("error: " + error);
    }
});

发起转账后web3js.eth.sendSignedTransaction 都能获取到结果hash,大部分都能转账成功,链上可以查到,但是有时候转账不成功,链上也查不到相关hash的信息。 还请懂得朋友指点指点,谢谢。

0 条评论 5 学分

3 个回答

xwisen 2025-01-31 13:26
Jeack 2025-01-21 19:18
fake 前端开发 2025-02-07 16:26

写回答

你需要登录后才可以回答问题,登录