Hi I am trying to make a call to the Dai contract in the Kovan testnet using web3.js and have to set the value of web3.eth.defaultChain to 'kovan'. The docs state that the default value for web3.eth.defaultChain is 'mainnet' but it is giving me 'undefined'. I think this is also why I am getting the wrong result on querying the balanceOf method. Could someone please tell me why this is happening? Here is my code :
const Web3 = require("web3");
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
console.log(web3.eth.defaultChain); //This returns 'undefined'
web3.eth.defaultChain = 'kovan';
var DaiContract = web3.eth.contract('ABI_HERE');
var dai = DaiContract.at('0xC4375B7De8af5a38a93548eb8453a498222C4fF2');
console.log(dai.balanceOf('0x3B1b198FE3Ee0428164a2fD38529CE958e63a0BD'));