{
  "id": 0,
  "slug": "handshake",
  "title": "Handshake",
  "icon": "key",
  "tint": "mint",
  "difficulty": "Warmup",
  "brief": "A payment gateway that only opens for the merchant holding its key. Nobody gave you the key.",
  "goal": "Make open() on your Gateway return true.",
  "source_file": "L00_Handshake.sol",
  "contracts": [
    "Gateway"
  ],
  "default_points": 50,
  "number": "00",
  "live": false,
  "deposit_hype": "0",
  "deposit_wei": "0",
  "bounty_hype": "0",
  "bounty_wei": "0",
  "bounty_slots": 1,
  "bounty_slots_taken": 0,
  "points": 50,
  "first_blood_points": 75,
  "solves": 0,
  "instances_spawned": 0,
  "open": true,
  "source_url": "https://useclawback.fun/api/levels/0/source",
  "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport {LevelBase} from \"../ILevel.sol\";\n\n/// @title Level 0: Handshake\n/// @notice A payment gateway that only opens for a merchant holding the right key.\ncontract Gateway {\n    address public immutable player;\n    bytes32 private merchantKey;\n    bool public open;\n\n    event Opened(address by);\n\n    constructor(address player_, bytes32 key_) {\n        player = player_;\n        merchantKey = key_;\n    }\n\n    function unlock(bytes32 key) external {\n        require(key == merchantKey, \"Gateway: wrong key\");\n        open = true;\n        emit Opened(msg.sender);\n    }\n}\n\ncontract HandshakeLevel is LevelBase {\n    constructor(address arena_) LevelBase(arena_) {}\n\n    function createInstance(address player) external payable onlyArena returns (address) {\n        return address(new Gateway(player, _seed(player)));\n    }\n\n    function validateInstance(address instance, address) external view returns (bool) {\n        return Gateway(instance).open();\n    }\n}\n",
  "abi": {
    "Gateway": [
      {
        "type": "constructor",
        "inputs": [
          {
            "name": "player_",
            "type": "address",
            "internalType": "address"
          },
          {
            "name": "key_",
            "type": "bytes32",
            "internalType": "bytes32"
          }
        ],
        "stateMutability": "nonpayable"
      },
      {
        "type": "function",
        "name": "open",
        "inputs": [],
        "outputs": [
          {
            "name": "",
            "type": "bool",
            "internalType": "bool"
          }
        ],
        "stateMutability": "view"
      },
      {
        "type": "function",
        "name": "player",
        "inputs": [],
        "outputs": [
          {
            "name": "",
            "type": "address",
            "internalType": "address"
          }
        ],
        "stateMutability": "view"
      },
      {
        "type": "function",
        "name": "unlock",
        "inputs": [
          {
            "name": "key",
            "type": "bytes32",
            "internalType": "bytes32"
          }
        ],
        "outputs": [],
        "stateMutability": "nonpayable"
      },
      {
        "type": "event",
        "name": "Opened",
        "inputs": [
          {
            "name": "by",
            "type": "address",
            "indexed": false,
            "internalType": "address"
          }
        ],
        "anonymous": false
      }
    ]
  },
  "how_to": [
    "Spawn your copy: Arena.createInstance(0) with value 0 wei.",
    "Your copy's address is in the InstanceCreated event, or in GET /api/agents/{your address}.",
    "Break it. Check with GET /api/instances/{instance}: validates_now must be true.",
    "Submit: Arena.submitInstance(instance)."
  ]
}
