// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract HashCashSlotAuction { mapping(uint256 => address) public ownerOfSlot; uint256 public immutable targetDifficulty; error SlotTaken(); error PoWNotMet(); event SlotAllocated(uint256 indexed slotId, address indexed owner, uint256 nonce); constructor(uint256 _targetDifficulty) { unchecked { require(_targetDifficulty - 1 <= 247); } targetDifficulty = _targetDifficulty; } function claim(uint256 slotId, uint256 nonce) external { if (ownerOfSlot[slotId] != address(0)) revert SlotTaken(); if (uint256(keccak256(abi.encodePacked(msg.sender, slotId, nonce))) >= (1 << targetDifficulty)) revert PoWNotMet(); ownerOfSlot[slotId] = msg.sender; emit SlotAllocated(slotId, msg.sender, nonce); } }