Last active
September 1, 2023 13:39
-
-
Save JhonatanHern/0d7d50d73d161be00c646480ada77f30 to your computer and use it in GitHub Desktop.
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: MIT | |
pragma solidity ^0.8.9; | |
// IMPORTANT | |
// Use 0xf3bE1A4a47576208C1592Cc027087CE154B00672 | |
// As the contract address. Don't deploy from scratch. | |
// To send the mint transaction use 10 Finney as value | |
import 'https://github.com/immutable/zkevm-contracts/blob/master/contracts/token/erc721/abstract/ImmutableERC721Base.sol'; | |
// contracts/royalty-enforcement/RoyaltyAllowlist.sol | |
contract ZkBasicSale is ImmutableERC721Base{ | |
uint256 private tokenCounter; | |
uint256 public constant MAX_SUPPLY = 1000; // The fixed supply limit | |
uint256 public constant MINT_FEE = 0.00001 ether; // The small amount of the native token to be paid | |
address public immutable owner; // The owner of the contract | |
constructor(address royaltyAllowlist) ImmutableERC721Base( | |
msg.sender, | |
"ExampleToken", | |
"EXT", | |
"http://example.com/", | |
"", | |
royaltyAllowlist, | |
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, | |
1000 | |
) | |
{ | |
owner = msg.sender; | |
} | |
function mint(address to) public payable { | |
require(msg.value >= MINT_FEE, "You must pay at least the mint fee"); // Check if the sender paid enough | |
require(tokenCounter < MAX_SUPPLY, "All tokens have been minted"); // Check if the supply limit is reached | |
tokenCounter++; // Increment the token id counter | |
uint256 tokenId = tokenCounter; // Get the current token id | |
_mint(to, tokenId); // Mint the token to the receiver address | |
if (msg.value > MINT_FEE) { // If the sender paid more than the mint fee | |
payable(msg.sender).transfer(msg.value - MINT_FEE); // Return the excess amount to the sender | |
} | |
} | |
function claim() public { | |
require(msg.sender == owner, "Only the owner can claim"); // Check if the sender is the owner | |
payable(owner).transfer(address(this).balance); // Transfer the balance to the owner | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment