0

I keep getting this error where my web3 throws an error saying that getCardByID is not a function, but it is clearly defined in my deployed smart contract. What am I missing here?

Smart contract code:

function getCardById(uint id) constant returns (uint idRet, string name, string email, string comment){

for (uint i = 0; i < count; i++) {

    if (cards[i].id == id) {

        idRet = cards[i].id;

        name = cards[i].name;

        email = cards[i].email;

        comment = cards[i].comment;

        return;

        }

    }

HTML/Jscript code:

 //pulls a record from the blockchain based on ID #
      function getCardByID() {
          web3.personal.unlockAccount(web3.eth.accounts[0], 'scrubbed');
          var vID = $("#id").val(); //pulls value from user input field
          var card = contract_instance.getCardByID(vID);
          console.log(card);
      }

Any help is greatly appreciated; thank you in advance.

1

getCardByID is not a function, but getCardById is.

Note the lower-case d in the function definition of the contract.

  • 1
    Thank you for catching that... clearly it's been a long day - yikes – Forrest Oct 11 '17 at 18:49

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.