Skip to content

Instantly share code, notes, and snippets.

@developerfred
Created April 30, 2023 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developerfred/baca33fff3a5f298fade4bf752a5eee4 to your computer and use it in GitHub Desktop.
Save developerfred/baca33fff3a5f298fade4bf752a5eee4 to your computer and use it in GitHub Desktop.
Pepe Works on Arbitrum Nova
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "approved",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [],
"name": "MAX_MINT_PER_TX",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_PEPE_WORKS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MINT_PRICE",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getApproved",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getPepe",
"outputs": [
{
"components": [
{
"internalType": "enum PepeWorks.Profession",
"name": "profession",
"type": "uint8"
},
{
"internalType": "enum PepeWorks.Rarity",
"name": "rarity",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "specialAbility1",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "specialAbility2",
"type": "uint256"
}
],
"internalType": "struct PepeWorks.Pepe",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isMintingActive",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "numberOfTokens",
"type": "uint256"
}
],
"name": "mintPepeWorks",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ownerOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "setApprovalForAll",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "baseURI",
"type": "string"
}
],
"name": "setBaseTokenURI",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "toggleMinting",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenOfOwnerByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]

Are you ready to join the action of the new Pepe Works collection? This NFT contract features 10,000 units randomly generated through generative art, making each Pepe Works unique with a random profession and rarity. Collecting a Pepe Works can lead you to a world of incredible possibilities, from transaction fee discounts to participation in exclusive cryptocurrency events.

Professions range from cryptocurrency miners to smart contract developers and DeFi strategists. Each Pepe Works has a randomly assigned rarity in three levels: common, rare, and legendary, with the rare and legendary ones possessing special abilities such as early access to new cryptocurrency projects and exclusivity in future NFT collections.

Don't waste any time! Take advantage of this opportunity to join an incredibly unique and randomly generated NFT collection. Be aware that your purchase will also be funding open-source developers. So, don't hesitate to mint your own Pepe Works on Arbitrum Nova at 0x5de932bd252dd79231c9edb5f2e30d488b785109.

For more information about the project builder and to contribute to its development, visit the Gitcoin Grants link: https://explorer.gitcoin.co/#/round/1/0x12bb5bbbfe596dbc489d209299b8302c3300fa40/0x12bb5bbbfe596dbc489d209299b8302c3300fa40-121. We look forward to having you in this incredible Pepe Works collection!

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract PepeWorks is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
uint256 public constant MAX_PEPE_WORKS = 10000;
uint256 public constant MAX_MINT_PER_TX = 20;
uint256 public constant MINT_PRICE = 0.05 ether;
string private _baseTokenURI;
bool public isMintingActive = false;
enum Rarity { Common, Rare, Legendary }
enum Profession {
CryptoMiner,
TokenTrader,
SmartContractDeveloper,
Hodler,
NFTCollector,
CryptoInfluencer,
DeFiStrategist,
CryptoInvestor,
AirdropHunter,
MemeMaker
}
struct Pepe {
Profession profession;
Rarity rarity;
uint256 specialAbility1;
uint256 specialAbility2;
}
mapping(uint256 => Pepe) private _pepes;
constructor() ERC721("Pepe Works", "PEPE") {}
function mintPepeWorks(uint256 numberOfTokens) public payable {
require(isMintingActive, "Minting is not active");
require(numberOfTokens > 0 && numberOfTokens <= MAX_MINT_PER_TX, "Invalid number of tokens");
require(_tokenIdCounter.current() + numberOfTokens <= MAX_PEPE_WORKS, "Mint limit exceeded");
require(msg.value >= MINT_PRICE * numberOfTokens, "Insufficient ether");
for (uint256 i = 0; i < numberOfTokens; i++) {
_mintUniqueToken(msg.sender);
}
}
function _mintUniqueToken(address to) private {
uint256 newTokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_pepes[newTokenId] = _generatePepe();
_safeMint(to, newTokenId);
}
function _generatePepe() private view returns (Pepe memory) {
uint256 rand = _random();
Profession profession = Profession(rand % 10);
Rarity rarity = _getRarity(rand / 10);
uint256 specialAbility1 = rarity == Rarity.Common ? 0 : rand / 100;
uint256 specialAbility2 = rarity == Rarity.Legendary ? rand / 1000 : 0;
return Pepe(profession, rarity, specialAbility1, specialAbility2);
}
function _getRarity(uint256 rand) private pure returns (Rarity) {
if (rand % 100 < 60) {
return Rarity.Common;
} else if (rand % 100 < 90) {
return Rarity.Rare;
} else {
return Rarity.Legendary;
}
}
function _random() private view returns (uint256) {
return uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty, msg.sender)));
}
function _baseURI() internal view override returns (string memory) {
return _baseTokenURI;
}
function toggleMinting() public onlyOwner {
isMintingActive = !isMintingActive;
}
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function getPepe(uint256 tokenId) public view returns (Pepe memory) {
require(_exists(tokenId), "Token ID does not exist");
return _pepes[tokenId];
}
function setBaseTokenURI(string memory baseURI) public onlyOwner {
_baseTokenURI = baseURI;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment