Cannot deploy contract

I got an error while deploying my contract


here is my code :slight_smile: // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
/**

  • @dev Extends ERC20 Token Standard basic implementation
    */
    contract SlimeCheckinToken is ERC721Enumerable, Ownable, ReentrancyGuardUpgradeable{
    mapping(address => uint256) private lastMintDay;
    mapping(address => uint256) private mintedTokens;
    uint256 public constant dailyLimit = 1 days;
    bytes32 public merkleRoot;

    uint256 public MAX_SUPPLY = 10000; // 10000 SeedNFT
    uint256 public constant MINT_END = 1730273185; // Fri Jun 30 2024 01:33:05 GMT+0000
    event Minted(address minter, uint tokenId);
    event UpdatedMerkleRoot(bytes32 _merkleRoot);
    event Referred(address user, address ref, address token, uint amount);

    constructor(address initialOwner)
    ERC721("MyToken", "MTK")
    Ownable(initialOwner)
    {}

    function mint() external {
    require(lastMintDay[msg.sender] < getCurrentDay(), "You have already minted today");
    lastMintDay[msg.sender] = getCurrentDay();
    mintedTokens[msg.sender]++;
    uint _tokenId = 1 * 1e18;
    _mint(msg.sender,_tokenId );
    emit Minted(msg.sender, _tokenId);

    }

    function mintRefer(uint tier, bytes32 calldata proof, uint amount, address ref) public nonReentrant {
    require(block.timestamp <= MINT_END, "CLAIM_ENDED");
    require(msg.sender != ref, "REF_INVALID");

     uint _left = left(msg.sender, tier, proof);
     require(amount <= _left, "MINTED");
     require(totalSupply() + amount <= MAX_SUPPLY, "INVALID_AMOUNT");
    
     if(ref != address(0)){
         uint _tokenId = totalSupply() + 1;
         _safeMint(msg.sender, _tokenId);
         emit Minted(msg.sender, _tokenId);
    
         _tokenId = totalSupply() + 1;
         _safeMint(ref, _tokenId);
         emit Referred(msg.sender, ref, address(this), 1);
     }
     mintedTokens[msg.sender] += amount;
    

    }

    function hasMintedToday(address user) external view returns (bool) {
    return lastMintDay[user] == getCurrentDay();
    }

    function getCurrentDay() internal view returns (uint256) {
    return block.timestamp / 1 days;
    }

    function allocated(address account, uint tier, bytes32 calldata proof) internal view returns(uint) {
    bytes32 leaf = keccak256(abi.encodePacked(account, tier * 1e18));
    bool isValidLeaf = MerkleProof.verify(proof, merkleRoot, leaf);

     if (!isValidLeaf){      // Not in merkle root can claim 1 NFT
         return 1;
     }
     if (tier == 1){         // Tier 1 can claim 10 NFTs
         return 10;
     }
     if (tier == 2){         // Tier 2 can claim 5 NFTs
         return 5;
     }
     
     return 1; 
    

    }

    function left(address account, uint tier, bytes32 calldata proof) public view returns(uint) {
    uint _allocated = allocated(account, tier, proof);
    return _allocated - mintedTokens[account];
    }

    function getTimeUntilNextMint(address user) external view returns (uint256) {
    uint256 lastMintTime = lastMintDay[user] * 1 days;
    uint256 currentTime = block.timestamp;

     if (lastMintTime == 0) {
         return 0;
     }
    
     uint256 nextMintTime = lastMintTime + 1 days;
    
     if (nextMintTime > currentTime) {
         return nextMintTime - currentTime;
     } else {
         return 0;
     }
    

    }

    function getMintedTokens(address user) external view returns (uint256) {
    return mintedTokens[user];
    }

}

2 Likes

I just tried to deploy the exact same contract on sepolia and here it is - https://sepolia.etherscan.io/address/0xf571a79ab3a94cb1df7ff8db20b2f877dcb8371f

Can you provide some details, what chain are you deploying on, and what environment you are using.

thanks u,
I have deployed successfully

Can you help with the next contract


You are trying to deploy an upgradeable contract but the thing is that this contract is the implementation contract.

So you don't define constructor, instead you'll need an initialize function.

2 Likes

Thank you. I read and corrected my code but it doesn't seem to work. Can you help me fix it?

pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

/**

  • @dev Extends ERC721 Non-Fungible Token Standard basic implementation
    */
    contract SeedNFT is ERC721Enumerable, Ownable, ReentrancyGuardUpgradeable {
    using Strings for uint256;
    string public baseUri;

    uint256 public MAX_SUPPLY = 10000; // 10000 SeedNFT
    uint256 public constant MINT_END = 1730273185; // Fri Jun 30 2024 01:33:05 GMT+0000
    mapping(address => uint) public userMinted;
    bytes32 public merkleRoot;

    event Minted(address minter, uint tokenId);
    event UpdatedBaseUri(string baseUri);
    event UpdatedMerkleRoot(bytes32 _merkleRoot);
    event Referred(address user, address ref, address token, uint amount);

    constructor(string memory _baseUri, bytes32 _merkleRoot) ERC721("Seed NFT of VePlus", "SeedNFT") {
    baseUri = _baseUri;
    merkleRoot = _merkleRoot;
    }

    function setBaseURI(string memory _baseUri) external onlyOwner {
    baseUri = _baseUri;
    emit UpdatedBaseUri(_baseUri);
    }g d

Accurate explanation :clap: :clap: :clap: :clap: