solidity
solidity copied to clipboard
this.balance in Truffle
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.
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.