Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingjun authored and Mingjun committed Dec 11, 2023
0 parents commit d396034
Show file tree
Hide file tree
Showing 6 changed files with 13,793 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Hardhat files
cache
artifacts

/node_modules
/typechain-types
78 changes: 78 additions & 0 deletions contracts/loonies.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MIT
// ERC-721 Smart Contract for the Loonies NFT Collection
pragma solidity ^0.8.0;
import "hardhat/console.sol";

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

string constant tokenName = "Loonies";
string constant symbol = "LOON";

contract Loonies is ERC721Enumerable, Pausable, Ownable {
using Strings for uint256;

uint256 public maxTokens; // Should be 12000
uint256 public price; // Cost of each mint in ETH
string public baseTokenURI; // base uri of loonies assets

constructor(
uint256 _maxToken,
uint256 _price,
string memory _baseTokenURI
) ERC721("Loonies", "LOON") {
maxTokens = _maxToken;
price = _price;
baseTokenURI = _baseTokenURI;
}

function mintNft(address _to) public payable whenNotPaused {
uint256 id = totalSupply() + 1;

if (msg.sender != owner()) {
require(msg.value >= price, "Ether sent is not enough");
}

require(id <= maxTokens, "Exceeds maximum supply");

_safeMint(_to, id);
}

function burn(uint256 tokenId) public virtual {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721Burnable: caller is not owner nor approved"
);
_burn(tokenId);
}

function pause() public onlyOwner {
_pause();
}

function unpause() public onlyOwner {
_unpause();
}

function setPrice(uint256 _price) public onlyOwner {
price = _price;
}

function setBaseURI(string memory _baseTokenURI) public onlyOwner {
baseTokenURI = _baseTokenURI;
}

function withdraw(uint256 _amount) public payable onlyOwner {
require(payable(msg.sender).send(_amount));
}

function withdrawAll() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance));
}

function _baseURI() internal view override(ERC721) returns (string memory) {
return baseTokenURI;
}
}
23 changes: 23 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { HardhatUserConfig } from "hardhat/types";
import "@typechain/hardhat";
import dotenv from 'dotenv'

require("@nomicfoundation/hardhat-toolbox");

const SEI_PRIVATE_KEY="0x03a01f808bf1a1421ee59ff0e476ed07e41c5fa2229af228959f16e22dce8e82"

dotenv.config({ path: '.env.local' })

const config: HardhatUserConfig = {
solidity: {
compilers: [{ version: "0.8.1", settings: {} }],
},
networks: {
sei: {
url: 'http://127.0.0.1:8545',
accounts: [SEI_PRIVATE_KEY]
}
}
};

export default config;
59 changes: 59 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "loonies",
"version": "1.0.0",
"description": "A eth NFT project",
"main": "index.js",
"repository": "",
"author": "CrazyCaribou",
"license": "MIT",
"scripts": {
"eth:test_contract": "hardhat test",
"eth:dev:compile_contract": "hardhat compile",
"eth:dev:deploy_contract": "hardhat run --network localhost scripts/eth_contracts/deploy_local.js",
"eth:dev:get_eth": "hardhat run --network localhost scripts/utils/get_local_eth.js"
},
"dependencies": {
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^4.4.1",
"@typechain/hardhat": "^9.1.0",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"custom-env": "^2.0.1",
"dotenv": "^10.0.0",
"hardhat": "^2.19.2",
"hardhat-typechain": "^0.3.5",
"hardhat-waffle": "^0.0.1-security",
"next": "^12.0.7",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-markdown": "^7.1.1",
"react-toastify": "^8.1.0",
"swr": "^1.1.2",
"truffle": "^5.11.5",
"ts-generator": "^0.1.1",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"typechain": "^8.3.2",
"typescript": "^4.5.4"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@nomicfoundation/hardhat-verify": "^2.0.2",
"@typechain/ethers-v6": "^0.5.1",
"@types/chai": "^4.3.11",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.4",
"autoprefixer": "^10.4.1",
"chai": "^4.3.10",
"eslint": "^8.6.0",
"eslint-config-next": "^12.0.8",
"ethereum-waffle": "^3.4.0",
"hardhat-gas-reporter": "^1.0.9",
"postcss": "^8.4.5",
"solidity-coverage": "^0.8.5",
"tailwindcss": "^3.0.8"
}
}
Loading

0 comments on commit d396034

Please sign in to comment.