Code Snippets

Minting Functions

// Function to mint a standard Lordz NFT
function mintToken(address user, string memory catNum, string memory lrdId) payable external returns (uint256) {
    require (msg.value >= bnbMintCost, "Not enough BNB");
    require((user == _msgSender() || _msgSender() == owner()), "Reserved function");
    require(IERC20(tokenAddr).balanceOf(user) >= lordzMintCost * 10 ** 9, "Not enough $LORDZ");
    IERC20(tokenAddr).transferFrom(user, royalAddr, lordzMintCost * 10 ** 9);
    uint256 id = totalSupply() + 1;
    catalog[id] = catNum;
    lordzID[id] = lrdId;
    _safeMint(user, id);
    _setTokenURI(id, string(abi.encodePacked(catNum, ".json")));
    return id;
}

// Function to mint a rare OP Lordz NFT using VRF for randomness
function mintVRFToken(address user, string memory catNum, string memory lrdId) payable external returns (uint256) {
    require (msg.value >= bnbVRFCost, "Not enough BNB");
    require((user == _msgSender() || _msgSender() == owner()), "Reserved function");
    require (!mintLocked[user], "Minting is locked");
    require(IERC20(tokenAddr).balanceOf(user) >= lordzVRFCost * 10 ** 9, "Not enough $LORDZ");
    IERC20(tokenAddr).transferFrom(user, royalAddr, lordzVRFCost * 10 ** 9);
    mintLocked[user] = true;
    uint256 id = totalSupply() + 1;
    catalog[id] = catNum;
    lordzID[id] = lrdId;
    bytes32 requestId = getRandomNumber();
    rarity[id] = resultVRF;
    reqId = requestId;
    _safeMint(user, id);
    _setTokenURI(id, string(abi.encodePacked(catNum, "a.json")));
    return id;
}

Burning Function

Transfer Functions

Approval Functions

Randomness Functions

Withdrawal Functions

Ownership Functions

Helper Functions

These snippets highlight the core functionality of the MemeLordz NFT smart contract, ensuring secure and efficient interactions with the NFTs within the ecosystem.

Full Smart Contract

Last updated

Was this helpful?