KingSlayer
Difficulty
Your typical King of the Ether! It's a Game of Throne!
Author: Razzor
Network: Goerli
Deployer: 0x35b6815696d82ef17c8003d77ae033c35d873346
Contract Code
pragma solidity 0.8.12;
import "./ERC721.sol";
import "./Counters.sol";
contract KingSlayer is ERC721("KingSlayer", "KS"){
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
address public King;
uint public KingsContribution;
address deployer;
bool initialized;
event newKing(address indexed);
function initialize() external{
require(!initialized, "Already Initialized");
initialized = true;
King = msg.sender;
KingsContribution = 0.01 ether;
deployer = msg.sender;
}
function gameOfThrone() external payable {
require(msg.sender != King, "Already a King. What else do you want?");
require(msg.value >= KingsContribution + 0.05 ether);
payable(King).call{value: KingsContribution}("");
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_mint(msg.sender, tokenId);
if (Address.isContract(King))
address(King).call(abi.encodeWithSelector(IERC721Receiver.onERC721Received.selector, _msgSender(), King, tokenId, ""));
King = msg.sender;
KingsContribution = msg.value;
emit newKing(msg.sender);
}
function destroy() external{
require(msg.sender == deployer, "Only Deployer");
selfdestruct(payable(msg.sender));
}
fallback() external payable{
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
revert("Don't cheat the system!");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public override {
revert("Don't cheat the system!");
}
function tokenURI(uint256) public pure override returns (string memory) {
return "https://ciphershastra.com/KingSlayer.html";
}
}