Whenever I try to execute a function that uses address(this).balance
I get an invalid opcode
error. It compiles fine using 0.6.0.
Using truffle debug I get the following error:
Transaction halted with a RUNTIME ERROR.
There was no revert message. This may be due to an in intentional halting expression, such as assert(), revert(), or require(), or could be due to an unintentional exception such as out-of-gas exceptions.
Please inspect your transaction parameters and contract code to determine the meaning of this error.
I checked the docs but there's no breaking change for using address(this).balance
. Am i missing something?
Edit: I just tested this code in remix and it throws as well:
pragma solidity 0.6.0;
contract A {
uint public total;
receive() external payable {
total = address(this).balance;
}
}
address(this).balance
if using Istanbul EVM", so your issue could actually be a subsequent result of the recent hard-fork.SELFBALANCE
opcode. This opcode is supported by the main Ethereum network, but not by many emulators yet.