Created
November 2, 2022 19:36
-
-
Save devtooligan/8e5353135d7818e7403aa5879b1f7758 to your computer and use it in GitHub Desktop.
RareSkills challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.15; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "hardhat/console.sol"; | |
// You may not modify this contract | |
contract NotRareToken is ERC721 { | |
mapping(address => bool) private alreadyMinted; | |
uint256 private totalSupply; | |
constructor() ERC721("NotRareToken", "NRT") {} | |
function mint() external { | |
// console.log(uint256(keccak256(type(OptimizedAttacker).creationCode))); | |
totalSupply++; | |
_safeMint(msg.sender, totalSupply); | |
alreadyMinted[msg.sender] = true; | |
} | |
} | |
address payable constant ZERO_ADDRESS = payable(address(0x0000000000000000000000000000000000000000)); | |
contract OptimizedAttacker { | |
constructor(address victim) payable { | |
unchecked { | |
uint256 begSupply = block.number; | |
NotRareToken(victim).mint(); | |
for (uint256 i = 1; i < 150;) { | |
NotRareToken(victim).mint(); | |
ERC721(victim).transferFrom(address(this), msg.sender, begSupply + i - 1); | |
++i; | |
} | |
ERC721(victim).transferFrom(address(this), msg.sender, begSupply - 1); | |
} | |
selfdestruct(ZERO_ADDRESS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment