-
-
Save izqui/e5591fc082f5cb0950d8c4a081c73d7e to your computer and use it in GitHub Desktop.
Idea of a modifier for functions that call externally to assert the gas consumed in between. Protects against re-entrancy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract ConservativeSender { | |
ERC20 token; | |
modifier max_gas(uint max_delta) { | |
uint initialGas = msg.gas; | |
_; | |
assert(initialGas - msg.gas < max_delta); | |
} | |
function proxyTransfer(address _to, uint _value) | |
max_gas(110000) { | |
token.transfer(_to, _value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment