5 我在使用sendSignedTransaction授权转账的时候, 执行成功, 但是链上没有任何交易记录

`这是授权转账的代码 执行成功, 但是链上没有任何交易记录 授权的钱包有足够的币, 同意授权的钱包也有足够的币 希望dalao帮忙解决一下

` async doTransferFrom(agentAddress, agentAPIKEY, userAddress, amount, callBack) { const web3 = new Web3('')

    web3.eth.defaultAccount = agentAddress
    web3.eth.getChainId((err, chainid) => {
        if (err != null) {
            console.log('区块链ID:' + chainid + ' 错误信息:' + err)
            return
        }

        const Contract = new web3.eth.Contract(
            abiERC20,
            ContractERC20,
            {
                from: userAddress,
                // gasPrice: '10000000000',
                // gas: 5000000
            })

        const ApproveEncodedABI = Contract.methods
            .approve(agentAddress, web3.utils.toHex(999999))
            .encodeABI()

        const value = web3.utils.toHex(web3.utils.toWei('0.001', 'ether'));
        web3.eth.getTransactionCount(userAddress, 'pending', (error, txCount) => {
            if (!error) {
                const txObject = {
                    chainId: web3.utils.toHex(chainid),
                    nonce: web3.utils.toHex(txCount+=27),
                    from: userAddress,
                    to: ContractERC20,
                    value: value,
                    gasLimit: web3.utils.toHex(210000),
                    gasPrice: web3.utils.toHex(8),
                    data: ApproveEncodedABI
                }

                console.log('txObject = ', txObject)
                const tx = new Tx(txObject)
                const privateKey = Buffer.from(agentAPIKEY, "hex")
                tx.sign(privateKey)
                const serializedTx = tx.serialize()

                web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), (err, txHash) => {
                    if (err) console.error('错误 = ', err)
                    else console.log('txHash = ', txHash)
                })
            }
        })
    })
}`
请先 登录 后评论

3 个回答

blockc0de
请先 登录 后评论
nono
请先 登录 后评论
Siondo
请先 登录 后评论