eth_chainId
eth_accounts
eth_call
WARNING: Calling an account which is not a contract
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0x5fbdb2315678afecb367f032d93f642f64180aa3
this is what logs on server.js:
Error: Error: could not decode result data (value="0x", info={ "method": "getBalance", "signature": "getBalance()" }, code=BAD_DATA, version=6.12.0)
at makeError (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\utils\errors.js:129:21)
at assert (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\utils\errors.js:149:15)
at Interface.decodeFunctionResult (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\abi\interface.js:780:31)
at staticCallResult (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\contract\contract.js:254:35)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async staticCall (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\contract\contract.js:219:24)
at async Proxy.getBalance (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\node_modules\ethers\lib.commonjs\contract\contract.js:259:20)
at async getContractBalance (C:\Users\Thato\OneDrive\Documents\Programming\DApps\DCrowdFunding\server\server.js:23:25) {
code: 'BAD_DATA',
value: '0x',
info: { method: 'getBalance', signature: 'getBalance()' },
shortMessage: 'could not decode result data'
...this is my code:
async function getContractBalance() {
try {
// const result = await contract.getBalance();
//console.log("Contract Balance:", result);
const balance = await contract.getBalance();
console.log("Contract Balance:", balance);
} catch (error) {
console.error("Error:", error);
}
}
..and this is the getBalance function in the contract:
function getBalance() public view returns(uint){
return address(this).balance;
}
contract
instance.