[Ethereum] Uncaught Error: new BigNumber() not a base 16 number (I know it might be the known bug)

go-ethereumsolidityweb3js

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;
        UserProfile[uid].fname.push(firstname);
        UserProfile[uid].lname.push(lastname);
        UserProfile[uid].streetaddress.push(street);
        UserProfile[uid].zip.push(zipVal);
    }

    //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);
    //OUTPUT TO CONSOLE
    console.log("-----------------");
    console.log("GET DATA FUNCTION");
    console.log("UID: "+struid);
    console.log("Pos: "+iPos);
    //OUTPUT TO HTML
    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

Best Answer

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.

Related Topic