I run into the uncaught error: new BigNumber() not a base 16 number. It's been discussed here and might occur due to a bug in web3.js

Maybe it's just my code that causes this error. Here it is:

pragma solidity ^0.4.8;
contract Test {
    struct Addresses{ 
        string  id;
        string[] fname;
        string[] lname;
        string[] streetaddress;
        string[] zip;
    mapping(string => Addresses) UserProfile;

    //Set Variables
    function setData(string uid,string firstname,string lastname,string street,string zipVal) { 
        UserProfile[uid].id = uid;

    //Return Variables
    function getFirstname(string uid, uint8 pos) constant returns (string) {
        return UserProfile[uid].fname[pos];
    function getLastname(string uid, uint8 pos) constant returns (string) {
        return UserProfile[uid].lname[pos];
    function getGender(string uid, uint8 pos) constant returns (string) {
        return UserProfile[uid].streetaddress[pos];
    function getDOB(string uid, uint8 pos) constant returns (string) {
        return UserProfile[uid].zip[pos];

and here is my Javascript:

function getUserProfile() {
    var struid = document.getElementById('uid').value;
    var iPos = parseInt("0");
    returnFirstname = UserProfile.getFirstname(struid, iPos);
    returnLastname = UserProfile.getLastname(struid, iPos);
    console.log("GET DATA FUNCTION");
    console.log("UID: "+struid);
    console.log("Pos: "+iPos);
    document.getElementById('firstname').innerHTML = returnFirstname;
    document.getElementById('lastname').innerHTML = returnLastname;

Maybe it's the combination of strings and integers that is throwing this error.

Any pointer would help! Thanks

  • Can you add the code in Javascript that you use? Commented Feb 14, 2017 at 12:44
  • Hi Xavier, i've just added my Javascript to the original post. Thanks
    – Borinho
    Commented Feb 14, 2017 at 13:05
  • It would help if you added information on how you run the JS code (some browser, I assume), where does the error happen and stack trace of the error.
    – comodoro
    Commented Feb 14, 2017 at 19:35
  • Hey Comodoro, the JS code is run by Chrome/Firefox/IE. I dont think the problem is related to any browser as even the JS Console of my private Ethereum (geth on windows) is throwing this error when calling the function... Does this help as well?
    – Borinho
    Commented Feb 15, 2017 at 10:16
  • Can you console.log(iPos);? Commented Feb 15, 2017 at 14:29

2 Answers 2


Base 16 is hexadecimal. The variable iPos you're giving to getFirstname is base 10 IE "0"

Hexademical is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F <-- Sixteen positions.

Demical is 0,1,2,3,4,5,6,7,8,9 <-- Ten positions.

The number zero in Base 16 is 0x0.

  • Thanks for that Info. What type should be defined in javascript to handover a 0 as 0x0 for a smart contract?
    – Borinho
    Commented Jul 10, 2017 at 9:01

finally found out why I was getting this problem. First of all, when passing on an integer, I got an error which I could counter with converting it to hex. But more importantly I found out that the BigNumber error is thrown when:

  • I tried to "query" a transaction that was created by another contract e.g. not the current version. Don't ask me why, just an observation
  • I queried a position that was not existing. Like for instance if there was nothing pushed...

Maybe this will help someone running into the same issue.


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.