Hi I'm trying to interact with an Ethereum smart contract from my node js api.
My controller function is as follows:
var web3 = require('web3');
module.exports.getTokenBalance = function(req, res) {
var abi = //long ABI
var MyContract = web3.eth.contract(abi);
// initiate contract for an address
var myContractInstance = MyContract.at('...');
myContractInstance.balanceOf.call('addr', function(err, data) {
}
}
I'm using the web3@0.20
package. When I try to call this API function I get the following error :
"Cannot read property 'contract' of undefined."
Am I missing something stupid?