Skip to content

Instantly share code, notes, and snippets.

@wjmelements wjmelements/Sponsored v1

Last active Mar 10, 2018
Embed
What would you like to do?
Sponsored gas plugin
pragma solidity^0.4.19;
// like a less-liquid GasToken
contract Sponsored {
uint256[] wastedSpace;
function sponsor() external {
uint256 len = wastedSpace.length;
wastedSpace.length = len + 5;
wastedSpace[len] = 1;
wastedSpace[len+1] = 1;
wastedSpace[len+2] = 1;
wastedSpace[len+3] = 1;
wastedSpace[len+4] = 1;
}
modifier sponsored {
_;
uint256 len = wastedSpace.length;
if (len != 0) {
wastedSpace[--len] = 0;
wastedSpace[--len] = 0;
wastedSpace[--len] = 0;
wastedSpace[--len] = 0;
wastedSpace[--len] = 0;
wastedSpace.length = len;
}
}
}
@wjmelements

This comment has been minimized.

Copy link
Owner Author

wjmelements commented Mar 10, 2018

How to use:

contract Dapp is Sponsored {
    function action(/* */) external sponsored {
        /* */
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.