Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SAG Proxy Contract Source (DEFCON Quals 2018)
pragma solidity ^0.4.17;
import "./Sag.sol";
contract SagProxy {
event PrizeRequest(bytes32 msgHash, uint8 v, bytes32 r, bytes32 s);
event PrizeReady(address winner, bytes prize);
Sag private sag;
address private owner;
modifier onlyOwner
require(msg.sender == owner);
constructor(address sag_addr) public
owner = msg.sender;
sag = Sag(sag_addr);
function gamble(uint256 guess, uint256 seed) public
sag.gamble(guess, seed);
function requestPrize(bytes32 msgHash, uint8 v, bytes32 r, bytes32 s) public
returns (bool is_winner)
if (ecrecover(msgHash, v, r, s) == msg.sender && sag.isWinner(msg.sender)) {
emit PrizeRequest(msgHash, v, r, s);
return true;
return false;
function deliverPrize(address winner, bytes prize) public onlyOwner
emit PrizeReady(winner, prize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment