I have a simple contract that deletes the last element of the array:
pragma solidity^0.4.11;
contract GasRefundTest {
uint[] myArray = [1, 2];
function deleteLastElem() public returns(bytes32) {
myArray.length--;
}
}
Transaction cost for calling deleteLastElem()
is 17182 gas.
When I change it to:
pragma solidity^0.4.11;
contract GasRefundTest {
uint[] myArray = [1, 2];
function deleteLastElem() public returns(bytes32) {
delete myArray[1];
myArray.length--;
}
}
the transaction cost becomes 22480 gas.
I thought deleting storage slots should result in gas refund, instead I see gas increase.
Can anyone explain what's going on here.