I am trying to get the ETH balance of a contract:
const balance = await contract.getBalance();
but it fails:
TypeError: contract.getBalance is not a function
What I do wrong and how to fix the error?
balancescontract-invocationetherethers.js
I am trying to get the ETH balance of a contract:
const balance = await contract.getBalance();
but it fails:
TypeError: contract.getBalance is not a function
What I do wrong and how to fix the error?
Best Answer
getBalance is a function of the Ether.js blockchain provider object, it is used this way :
Note that you can use
contract.address
to obtain the address of the contract instance.