# Web3 Contract.balanceOf is not a function

I have read this helpful SO answer about sending ERC20 contracts, but it seems that the Web3 docs and API have changed dramatically since then. I am trying to get the balance of a smart contract using Contract.balanceOf, but I am receiving errors saving that balanceOf is no longer a function.

var web3 = new Web3(new Web3.providers.HttpProvider("xx.xxx.xx.xx"));

var omisegoContract = web3.eth.Contract(omisegoAbi, '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07'); // 0xd26114cd6EE289AccF82350c8d8487fedB8A0C07 is the omisego contract addr. Other tokens will have different addresses

balance = web3.fromWei(omisegoContract.balanceOf("0xb8fd65fc6919c5b97453eaba6b895144597985b2"),"ether");


My error is that the Contract.balanceOf function cannot be found. How do I correctly get the balance of my ERC20 contract?

TypeError: omisegoContract.balanceOf is not a function

1. Change web3.eth.Contract to new web3.eth.Contract
2. Change omisegoContract.balanceOf to await omisegoContract.methods.balanceOf
Of course, the 2nd bullet implies that this line should be executed from an async function.
• @BarneyChambers: A contract method returns a Promise object when called from an off-chain (web3-client) script. You need to resolve this Promise object in order to obtain the actual value (in this case, the balance). One way to do this is by awaiting for the contract method to complete, which, due to the use of await must be done from an async function. – goodvibration Jun 6 at 10:34