solidity icon indicating copy to clipboard operation
solidity copied to clipboard

this.balance in Truffle

Open hajduakos opened this issue 5 years ago • 1 comments
trafficstars

There is a Truffle test failing (Payable.sol). I isolated the issue, and seems like address(this).balance generates an invalid opcode. Even the following very simple example fails with Truffle:

pragma solidity >=0.5.0;

contract ThisBalance {
    uint x;
    function() external payable {
        x = address(this).balance;
    }
}

There was a change in v0.5.13 in the opcode:

Code Generator: Use SELFBALANCE opcode for address(this).balance if using Istanbul EVM.

So there might be some mismatch between the EVM version the compiler targets and the one we run using Truffle.

hajduakos avatar Dec 24 '19 10:12 hajduakos

Good catch, I was baffled at what's going on. If I change the version to petersburg the test passes. Let's keep this open, we need to upgrade to istanbul when truffle allows.

dddejan avatar Dec 24 '19 19:12 dddejan