Skip to content

Instantly share code, notes, and snippets.

@what-the-func
Created September 4, 2020 06:51
Show Gist options
  • Save what-the-func/19c96f0ac38d010d959a592dd42c0654 to your computer and use it in GitHub Desktop.
Save what-the-func/19c96f0ac38d010d959a592dd42c0654 to your computer and use it in GitHub Desktop.
CHI Token Gas Rebate Contract
// 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