I am trying to use the library “ethereumjs-tx” but it does not work. I get this error message: “TypeError: Tx is not a constructor” on the code “const tx = new Tx(txObject)”.

Here is my code:

const Tx = require(‘ethereumjs-tx’)

const txObject = {

    nonce: web3.utils.toHex(txCount),

    to: account2,

    value: web3.utils.toHex(web3.utils.toWei('0.3', 'ether')),

    gasLimit: web3.utils.toHex(21000), 

    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))


const tx = new Tx(txObject)

Thank you for your help

Take care



It's const Tx = require('ethereumjs-tx').Transaction .

Here is the exemple from the Github repository : https://github.com/ethereumjs/ethereumjs-tx .

  • Thank you so much
    – Pierre
    Jul 18 '20 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.