1

I've created a fairly simple smart contract that has been deployed to the rinkeby testnet. You can see the code below:

pragma solidity ^0.4.18;

contract KVStore {

 mapping(address => mapping(string => string)) store;
 uint MAX_STR_LENGTH = 1000;

 function get(address _acct, string _key) public view returns(string) {
    return store[_acct][_key];
 }
 function set(string _key, string _value) public {
   if (bytes(_value).length <= MAX_STR_LENGTH) {
     store[msg.sender][_key] = _value;
   }
 }

}

I'm using geth to call the set function and then the get function. However, when I call kvstore.get(address, key) I get the following error:

Error: new BigNumber() not a base 16 number: 

I'm not sure whats going on or how to fix. The set function works fine and writes to the rinkeby chain.

I first run this:

geth --verbosity 0 console --rinkeby

Then

var kvstoreContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"_key","type":"string"},{"name":"_value","type":"string"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_acct","type":"address"},{"name":"_key","type":"string"}],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]).at("0xf8daca377691c8f52b07ef77dfc0e7ca287622c5");

Then

kvstoreContract.set("fly","star",{from:eth.accounts[1]});

Which works fine and sends a transaction to the contract address.

When I try to do

kvstoreContract.get(eth.accounts[1],"fly");

I get the bigNumber error. Any idea why? I'd really appreciate the help.

2

Figured it out finally. Was passing in the wrong contract address the whole time... that'll get ya!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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