0

I am working on signing and sending a transaction using web3 v1.0 and Infura.io. I have setup a script to run the TX but cannot seem to get ethereum-tx to connect in the browser.

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>
<script src="js/ethereum-tx.js"></script>

I dowloaded ethereum-tx.js from github and reference but keep getting the error TX is undefined.

var transaction = new TX(txData);

Does ethereum-tx not work in the browser? It works on the local machine after doing the npm install.

Here is the link to the download I am using -

https://github.com/ethereumjs/browser-builds/blob/master/dist/ethereumjs-tx/ethereumjs-tx-1.3.3.min.js

1 Answer 1

2

I see two elements that could help solving your problem:

  • You are calling new TX(txData) instead of the recommended way new EthereumTx(txParams). Now, this might be to simple different naming of variables on your side, but sticking to the standards is often helpful in debugging.
  • Besides, ethereumjs-tx depends on some JS ES6 capabilities, which are not always supported by the browsers. Hence you can use so-called shims, which patch the missing capabilities of the browser. For ethereumjs-txin particular, there is a disclaimer that you should consider using this shim.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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