I've finally managed to get my web3.js to work.. I did this only for the purpose to display one specific value on my website.. I'm not so good with jquery and hope you guys can help me out.

This is the Direct link to the ABI Value


Contract Link ( https://etherscan.io/address/0xd2354acf1a2f06d69d8bc2e2048aabd404445df6#readContract )

Line ( 28. currentTier )

It is in HexDec. and I need to output it in Decimal. I quess I will need to store the Value in a Var and output it in html.. but kinda lost how to exactly do it.

Hope you can help me out. Thank you very much

  • Please share your code. If you call currentTier() using web3.js, you should get back a BigNumber (or BN, if using the 1.0 beta) instance, and you can just call .toString() or .toNumber() on it.
    – user19510
    Aug 14, 2018 at 23:48

1 Answer 1


You can just call the currentTier function. Your callback will be invoked with an error (if there is one) and a result, which is a BigNumber instance. Call .toString() on it to convert the value to a base-10 string. The below code assumes web3.js 0.2x.x. If you're using the 1.0 beta, the syntax is a little different:

var contract = web3.eth.contract([{"constant":true,"inputs":[],"name":"currentTier","outputs":[{"name":"","type":"uint16"}],"payable":false,"stateMutability":"view","type":"function"}]).at('0xd2354acf1a2f06d69d8bc2e2048aabd404445df6');
contract.currentTier(function (err, result) { console.log(result.toString()); });
// output: 351

You mentioned jQuery. To display the value in your HTML, you can do something like $('#myelement').text(result.toString()) instead.


Your Answer

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

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