0

the input data of the variable uint256 is "22092018" but when using ethereum-input-data-decoder I return "BN: 15118f2". Instead of getting "BN: 15118f2" with the decoder, have the original value of the transaction data entry "22092018".

enter image description here

Code:

const InputDataDecoder = require('ethereum-input-data-decoder');
const decoder = new InputDataDecoder(`${__dirname}/abi.json`);

const data = `0x070ec83b000000000000000000000.......;

const result = decoder.decodeData(data);

console.log(result);
3

I don't fully understand the question but I think this might help.

JavaScript has no type for a 256-bit integer so web3.js includes the bignumber.js library.

Web3.js 1.0: https://web3js.readthedocs.io/en/1.0/web3-utils.html?highlight=bignumber#bn

Web3.js 0.x: https://github.com/ethereum/wiki/wiki/JavaScript-API#a-note-on-big-numbers-in-web3js

To avoid loss of precision, cast JavaScript variables as bigNumbers and perform all math with the bigNumber implementation. Convert to strings or regular integers for interactions with humans.

Try your BN variable.toString();

More documentation on bigNumber itself: https://github.com/MikeMcl/bignumber.js/

Hope it helps.

  • 1
    Also 22092018 in hexadecimal is 1511f82 that is inside BN. – Ismael Jan 10 at 2:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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