0

I am using the following code to get transactions in ether.js

var init = function () {
  var wss = new ethers.providers.WebSocketProvider(url);
      wss.getTransaction(tx).then(function (transaction) {
         wss.on("pending", (tx) => {
           console.log(transaction.gasLimit);
           }
      });
  });

which returns the transaction, but the data is formatted as

BigNumber { _hex: '0x0245e5', _isBigNumber: true },

How can I get the decimal value, from the hex?

Thanks

1
0

Per the link in the comment above, simple call .toString() on the BN, for example before your console.log, you can have

    let gasLimitBN = transaction.gasLimit;
    console.log(gasLimitBN.toString());

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