Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
contract IdentityContract {
uint256 public nonce;
function getSigner(bytes32 raw, bytes sig) public view returns(address signer) {
return ECTools.prefixedRecover(raw, sig);
modifier onlyValidSignature(uint256 relayerReward, address target, uint256 value, bytes data, bytes dataHashSignature) {
bytes32 dataHash = keccak256(abi.encodePacked(data, relayerReward, value, target, nonce));
address signer = getSigner(dataHash, dataHashSignature);
emit LogActionAuthorised(nonce, signer);
     * @dev executes a transaction only if it is formatted and signed by the owner of this. Anyone can call execute. Nonce introduced as anti replay attack mechanism.
     * @param relayerReward - the value to be sent back to the relayer
     * @param target - the contract to be called
     * @param value - the value to be sent to the target
     * @param data - the data to be sent to be target
     * @param dataHashSignature - signed bytes of the keccak256 of target, nonce, value and data keccak256(target, nonce, value, data)
function execute(address target, uint256 relayerReward, uint256 value, bytes data, bytes dataHashSignature) public payable onlyValidSignature(relayerReward, target, value, data, dataHashSignature) returns (bool) {
// solium-disable-next-line security/no-call-value
emit LogActionExecuted(nonce-1, target, relayerReward, value, data, dataHashSignature);
return true;
function rewardMsgSender(uint256 reward) internal returns(bool) {
// Override this to make your reward logic work
emit LogRewardsPaid(nonce-1, msg.sender, reward, deployer, 0x0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment