Gas Saver is a collection of smart contracts to save gas on Ethereum.
It defines a modifier that you can use to wrap the methods where you want to save gas burning gas tokens.
It uses Chi Gas tokens or GST2 Gas Tokens
Simply add the modifier to the methods you want, specifying the sponsor
that will pay part of the gas using Gas tokens.
You have to approve your contract to spend Gas tokens on sponsor behalf (i.e. call approve
)
Below an example with CHI tokens
import "@emilianobonassi/gas-saver/ChiGasSaver.sol";
contract MyContract is ChiGasSaver {
...
function myExpensiveMethod()
external
saveGas(msg.sender)
returns (bool) {
...
}
...
}
Below an example with GST2 tokens
import "@emilianobonassi/gas-saver/ChiGasSaver.sol";
contract MyContract is GST2GasSaver {
...
function myExpensiveMethod()
external
saveGas(msg.sender)
returns (bool) {
...
}
...
}