Created
September 4, 2020 06:51
-
-
Save what-the-func/19c96f0ac38d010d959a592dd42c0654 to your computer and use it in GitHub Desktop.
CHI Token Gas Rebate Contract
This file contains hidden or 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
// SPDX-License-Identifier: MIT | |
pragma solidity >=0.6.0 <0.7.0; | |
interface IFreeFromUpTo { | |
function freeFromUpTo(address from, uint256 value) external returns (uint256 freed); | |
} | |
contract GasSaver { | |
IFreeFromUpTo chi; | |
constructor (IFreeFromUpTo _chi) public { | |
chi = _chi; | |
} | |
modifier discountCHI { | |
uint256 gasStart = gasleft(); | |
_; | |
uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; | |
chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41130); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment