Skip to content

Instantly share code, notes, and snippets.

View DonkeVerse's full-sized avatar

DonkeVerse

View GitHub Profile
pragma solidity 0.8.13;

contract ExampleMint {

    uint256 public constant MAX_SUPPLY = 10000;
    address[MAX_SUPPLY] _owners;
    uint256 public constant PRICE = 0.01 ether;
    uint256 private index = 1;
 

You can paste this code into remix to verify these results

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.11;

contract RevertRequire {
    error TestError();

 // optimization set to 10,000
function mint() external payable {
    uint256 _currentIndex = currentIndex;
    require(_currentIndex < MAX_ID_PLUS_ONE);
    require(msg.value == PRICE, "wrong price");
    require(msg.sender == tx.origin, "only EOA");

    _owners[_currentIndex] = msg.sender;
    emit TransferSingle(msg.sender, address(0), msg.sender, _currentIndex, 1);
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/Strings.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/access/Ownable.sol";

contract ERC1155NFT is ERC1155, Ownable {
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.10;

import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/Strings.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/access/Ownable.sol";

contract ERC1155NFT is ERC1155, Ownable {
    using Strings for uint256;
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/utils/Strings.sol";
import "http://github.com/OpenZeppelin/openzeppelin-contracts/contracts/access/Ownable.sol";

contract ERC1155NFT is ERC1155, Ownable {
mapping(address => uint256) amountMintedSoFar;

function presale(bytes calldata _proof) external payable {
        require(totalSupply() < MAX_TOKEN_SUPPLY);
        require(msg.value == PRICE);
        require(validateUser(_proof, msg.sender);
        require(amountMintedSoFar[msg.sender] < MAX_PER_USER);
        
 amountMintedSoFar[msg.sender]++;
mapping(address => uint256) amountLeftToMint;
addUserToPresale(address _buyer, uint256 _amt) external onlyOwner {
    amountLeftToMint[_buyer] = _amt;
}
function presaleSingle(bytes calldata _proof) external payable {
    // ... other require statements
    require(amountLeftToMint[msg.sender] > 0);

 amountLeftToMint[msg.sender]--;
uint256 private constant MAX_INT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint256 private ticketGroup0 = MAX_INT;
uint256 private ticketGroup1 = MAX_INT;
uint256 private ticketGroup2 = MAX_INT;
uint256 private constant MAX_TICKETS = 3 * 256;
function claimTicketOrBlockTransactionV5(uint256 ticketNumber) external {
    require(ticketNumber < MAX_TICKETS, "bad ticket");
    uint256 storageSlot;             // rename storageOffset to storageSlot to be more clear since we aren't using an array
    uint256 offsetWithin256;
    function claimTicketOrBlockTransactionV2(uint256 ticketNumber) external {
        require(ticketNumber < arr.length * 256, "bad ticket");
        uint256 storageOffset;
        uint256 offsetWithin256;
        uint256 localGroup;
        uint256 storedBit;
        unchecked {
            storageOffset = ticketNumber / 256;
 offsetWithin256 = ticketNumber % 256;