TransWikia.com

WEB3.JS problem

Ethereum Asked on August 26, 2021

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

Pierre

One Answer

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

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

Answered by clement on August 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP