Returned error: invalid sender

志辉 志辉 提出于 2021-05-17 02:49 7844 浏览

提示Error: Returned error: invalid sender ,这是heco主网节点,链id16进制的也试过了也不行

var Web3 = require('web3')
      var web3 = new Web3('https://http-mainnet-node.huobichain.com/')
      const EthereumTx = require('ethereumjs-tx').Transaction
      const privateKey = Buffer.from(
        'siyao',
        'hex',
      )
      const txParams = {
        gasPrice: '0x09184e72a000',
        gasLimit: '0x2710',
        to: '0xa89765D7B7b7f5eF981430Df85115a932234ac1d',
        value: '0x00',
        common: {
          customChain: {
            name: 'heco_main',
            networkId: '0x80',
            chainId: '0x80'
          }
        }
      }
      const tx = new EthereumTx(txParams)
      tx.sign(privateKey)
      const serializedTx = tx.serialize()
      console.log(serializedTx)
      web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
        if (!err) {
          console.log(hash)
        } else {
          console.log(err)
        }
      })

最佳答案

2021-05-17 09:47

半夜昏头了,id写错地方了。

志辉

采纳率 33% · 回答于 2021-05-17 02:55

其它 1 个回答

Tiny熊 2021-05-17 10:33

擅长:智能合约,以太坊

写回答

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