-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d3580e6
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
artifacts | ||
cache | ||
node_modules | ||
|
||
.env | ||
package-lock.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; | ||
import "erc721a/contracts/ERC721A.sol"; | ||
|
||
contract LabPunks is Ownable, ERC721A, ReentrancyGuard { | ||
uint256 public constant MAX_SUPPLY = 1000; | ||
uint256 public constant maxPerAddressDuringMint = 5; | ||
bool public isPreSaleRunning = false; | ||
bool public isPublicSaleRunning = false; | ||
uint256 private _preSalePrice = 0.01 ether; | ||
uint256 private _salePrice = 0.015 ether; | ||
mapping(address => uint256) public preSaleList; | ||
|
||
event NewMint(address indexed _from, uint256 _quantity); | ||
|
||
constructor() ERC721A("LabPunks", "LP") {} | ||
|
||
modifier callerIsUser() { | ||
require(tx.origin == msg.sender, "The caller is another contract"); | ||
_; | ||
} | ||
|
||
function changePreSaleState(bool preSaleState) public onlyOwner { | ||
isPreSaleRunning = preSaleState; | ||
} | ||
|
||
function changePublicSaleState(bool publicSaleState) public onlyOwner { | ||
isPublicSaleRunning = publicSaleState; | ||
} | ||
|
||
function preSaleMint() external payable callerIsUser { | ||
require(isPreSaleRunning); | ||
require(preSaleList[msg.sender] > 0, "not eligible for allowlist mint"); | ||
require(totalSupply() + 1 <= MAX_SUPPLY, "reached max supply"); | ||
preSaleList[msg.sender]--; | ||
_safeMint(msg.sender, 1); | ||
emit NewMint(msg.sender, 1); | ||
} | ||
|
||
function mint(uint256 quantity) external payable callerIsUser{ | ||
require(isPublicSaleRunning); | ||
require(totalSupply() + quantity <= MAX_SUPPLY, "reached max supply"); | ||
require( | ||
numberMinted(msg.sender) + quantity <= maxPerAddressDuringMint, | ||
"can not mint this many" | ||
); | ||
_safeMint(msg.sender, quantity); | ||
emit NewMint(msg.sender, quantity); | ||
} | ||
|
||
function numberMinted(address owner) public view returns (uint256) { | ||
return _numberMinted(owner); | ||
} | ||
|
||
function preSalelist(address[] memory addresses, uint256[] memory numSlots) | ||
public | ||
onlyOwner | ||
{ | ||
require( | ||
addresses.length == numSlots.length, | ||
"addresses does not match numSlots length" | ||
); | ||
for (uint256 i = 0; i < addresses.length; i++) { | ||
preSaleList[addresses[i]] = numSlots[i]; | ||
} | ||
} | ||
|
||
string private _baseTokenURI; | ||
|
||
function _baseURI() internal view virtual override returns (string memory) { | ||
return _baseTokenURI; | ||
} | ||
|
||
function setBaseURI(string calldata baseURI) external onlyOwner { | ||
_baseTokenURI = baseURI; | ||
} | ||
|
||
function withdrawMoney() external onlyOwner nonReentrant { | ||
(bool success, ) = msg.sender.call{value: address(this).balance}(""); | ||
require(success, "Transfer failed."); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require('@nomiclabs/hardhat-waffle'); | ||
require('dotenv').config(); | ||
|
||
module.exports = { | ||
solidity: '0.8.4', | ||
networks: { | ||
rinkeby: { | ||
url: process.env.STAGING_ALCHEMY_KEY, | ||
accounts: [process.env.PRIVATE_KEY], | ||
}, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "ERC721-implementation", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@openzeppelin/contracts": "^4.4.2", | ||
"dotenv": "^15.0.0" | ||
}, | ||
"devDependencies": { | ||
"erc721a": "^2.2.0", | ||
"@nomiclabs/hardhat-ethers": "^2.0.4", | ||
"@nomiclabs/hardhat-waffle": "^2.0.2", | ||
"chai": "^4.3.6", | ||
"ethereum-waffle": "^3.4.0", | ||
"ethers": "^5.5.3", | ||
"hardhat": "^2.8.3" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const main = async () => { | ||
const nftContractFactory = await hre.ethers.getContractFactory('LabPunks'); | ||
const nftContract = await nftContractFactory.deploy(); | ||
await nftContract.deployed(); | ||
console.log("Contract deployed to:", nftContract.address); | ||
}; | ||
|
||
const runMain = async () => { | ||
try { | ||
await main(); | ||
process.exit(0); | ||
} catch (error) { | ||
console.log(error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
runMain(); |