2

I'm working on a smart contract that can hold some ETH.

Currently, I'm unable to see what is its balance in the Remix IDE.

I'm trying to use the console:

enter image description here

I have access to web3 but how to check the balance? Or maybe it's somewhere in the UI, that would be even better.

Sample contract that can receive Ether via fallback function:

pragma solidity ^0.4.25;

contract Payable {
    function() external payable { }
}
2

You can able to check account balance by

web3.eth.getBalance("your contract address")It will work for me. I am using the solidity version but a different web3 version. I think that is the problem. But I don't know why it will not work for you

2
  • I have used the same solidity compiler version. but a different web3 version. I don't know why it will not work for you Oct 1 '21 at 5:55
  • It works, thanks Oct 7 '21 at 11:53
1

From Remix docs 'web3 is only available if the web provider or injected provider mode is selected', so you can't use web3 with JavaScript VM.

As a workaround you may add a function that returns this.balance in your contract

1
  • @Stock Market answer works. Oct 7 '21 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.