0

I have deployed a contract in private blockchain using mist wallet. When I try to call the function in the smart contract using web3 api it through the below error

/home/karthikeyan/Desktop/n2/node_modules/web3/lib/solidity/address.js:23
return !!name.match(/address(\[([0-9]*)\])?/);
             ^                                               
TypeError: Cannot read property 'match' of undefined
 at SolidityTypeAddress.isType 

My code:

var Web3 = require('web3');
var web3 = new Web3(new 
Web3.providers.HttpProvider("http://54.212.192.158:8545"));

var abi = [ Contract ABI];

var myContract = web3.eth.contract(abi);
var myContractInstance = myContract.at("0x1AAFef75Fd4349F1747F051819B0E6DDb9903826");
var result = myContractInstance.balanceOf("0x7F0991e4c4613fbD4B84bb3B3f195f104936ABe7");
console.log(result);
0

It seems that name is undefined. Try logging out variable name right before you call it to see what the problem might be.

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.