├── .solhintignore ├── .env.sample ├── .gitignore ├── contracts ├── Interface │ ├── IDKeeperEscrow.sol │ ├── IDeepToken.sol │ └── IDKeeper.sol ├── DKeeperEscrow.sol ├── DeepToken.sol ├── Airdrop.sol ├── NFT │ ├── DKeeper.sol │ └── ERC721AUpgradeable.sol └── NFTStaking.sol ├── tsconfig.json ├── .solhint.json ├── README.md ├── tests ├── utils │ ├── utils.js │ └── sinature.js ├── nft-mint.test.js └── staking.test.js ├── .prettierrc ├── hardhat.config.ts ├── scripts ├── MultiCall.json └── FilterStakers.js ├── package.json └── deploy └── deploy.ts /.solhintignore: -------------------------------------------------------------------------------- 1 | # folders 2 | contracts/uniswap/ 3 | node_modules/ -------------------------------------------------------------------------------- /.env.sample: -------------------------------------------------------------------------------- 1 | ETHERSCAN_API= 2 | RINKEBY_PRIVKEY= 3 | MAINNET_PRIVKEY= 4 | ALCHEMY_KEY= -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | artifacts/ 4 | cache/ 5 | arguments/ 6 | types/ 7 | package-lock.json 8 | .openzeppelin 9 | .env 10 | .vscode 11 | yarn-error.log 12 | yarn.lock 13 | types/ -------------------------------------------------------------------------------- /contracts/Interface/IDKeeperEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity 0.8.4; 5 | 6 | interface IDKeeperEscrow { 7 | function mint(address account, uint256 amount) external; 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "sourceMap": true, 5 | "types": ["node", "mocha"], 6 | "lib": ["es2015"], 7 | "target": "es2016", 8 | "module": "commonjs", 9 | "declaration": true, 10 | "esModuleInterop": true 11 | }, 12 | "include": [ 13 | "./**/*.ts" 14 | ] 15 | } -------------------------------------------------------------------------------- /contracts/Interface/IDeepToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity 0.8.4; 5 | 6 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 7 | 8 | interface IDeepToken is IERC20 { 9 | function mint(address account, uint256 amount) external; 10 | } 11 | -------------------------------------------------------------------------------- /contracts/Interface/IDKeeper.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity 0.8.4; 5 | 6 | import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; 7 | 8 | interface IDKeeper is IERC721 { 9 | function mintedPrice(uint256 tokenId) external returns (uint256); 10 | } 11 | -------------------------------------------------------------------------------- /.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "solhint:recommended", 3 | "rules": { 4 | "func-order": "off", 5 | "mark-callable-contracts": "off", 6 | "no-empty-blocks": "off", 7 | "compiler-version": "off", 8 | "private-vars-leading-underscore": "error", 9 | "reason-string": "off", 10 | "not-rely-on-time": "off", 11 | "var-name-mixedcase": "off", 12 | "max-states-count": "off", 13 | "func-visibility": ["error", { "ignoreConstructors": true }] 14 | } 15 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Install 2 | 3 | Install dependencies: 4 | 5 | ```bash 6 | $ yarn 7 | ``` 8 | 9 | or 10 | 11 | ```bash 12 | $ npm install 13 | ``` 14 | 15 | ## Compile 16 | 17 | Compile smart contracts and create typechain: 18 | 19 | ```bash 20 | $ yarn compile 21 | ``` 22 | 23 | or 24 | 25 | ```bash 26 | $ npm run compile 27 | ``` 28 | 29 | ## Test 30 | 31 | Test smart contracts against ./tests: 32 | 33 | ```bash 34 | $ yarn test 35 | ``` 36 | 37 | or 38 | 39 | ```bash 40 | $ npm run test 41 | ``` 42 | -------------------------------------------------------------------------------- /tests/utils/utils.js: -------------------------------------------------------------------------------- 1 | const hre = require('hardhat') 2 | module.exports.advanceTime = async (seconds) => { 3 | await hre.network.provider.request({ 4 | method: "evm_increaseTime", 5 | params: [seconds] 6 | }) 7 | await hre.network.provider.request({ 8 | method: "evm_mine", 9 | params: [] 10 | }) 11 | } 12 | 13 | module.exports.currentTimestamp = async () => { 14 | const block = await (ethers.getDefaultProvider()).getBlock('latest') 15 | return block.timestamp - 1000 16 | } 17 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": "*.sol", 5 | "options": { 6 | "printWidth": 100, 7 | "tabWidth": 4, 8 | "useTabs": false, 9 | "singleQuote": false, 10 | "bracketSpacing": false, 11 | "explicitTypes": "always" 12 | } 13 | }, 14 | { 15 | "files": "*.js", 16 | "options": { 17 | "printWidth": 120, 18 | "tabWidth": 2, 19 | "useTabs": false, 20 | "singleQuote": false, 21 | "bracketSpacing": false, 22 | "explicitTypes": "always" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /contracts/DKeeperEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity 0.8.4; 5 | 6 | import "@openzeppelin/contracts/access/Ownable.sol"; 7 | 8 | import "./Interface/IDeepToken.sol"; 9 | 10 | /** 11 | * @title DKeeper Escrow contract 12 | */ 13 | contract DKeeperEscrow { 14 | IDeepToken public deepToken; 15 | address public dKeeper; 16 | 17 | constructor(address deepToken_, address dKeeper_) { 18 | require(deepToken_ != address(0), "Invalid token address"); 19 | require(dKeeper_ != address(0), "Invalid DKeeper address"); 20 | 21 | deepToken = IDeepToken(deepToken_); 22 | dKeeper = dKeeper_; 23 | } 24 | 25 | function mint(address _account, uint256 _amount) external { 26 | require(msg.sender == dKeeper, "msg.sender should be same with DKeeper address"); 27 | deepToken.mint(_account, _amount); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/utils/sinature.js: -------------------------------------------------------------------------------- 1 | const ethers = require("ethers"); 2 | 3 | const SIGNING_DOMAIN_NAME = "MagicCraft"; 4 | const SIGNING_DOMAIN_VERSION = "1"; 5 | 6 | class WhiteList { 7 | constructor({contract, signer}) { 8 | this.contract = contract; 9 | this.signer = signer; 10 | } 11 | 12 | async createWhiteList(whiteListAddress, isBool) { 13 | const value = {userAddress: whiteListAddress}; 14 | const domain = await this._signingDomain(); 15 | const types = { 16 | WhiteList: [{name: "userAddress", type: "address"}], 17 | }; 18 | 19 | const signature = await this.signer._signTypedData(domain, types, value); 20 | return { 21 | ...value, 22 | signature, 23 | }; 24 | } 25 | 26 | async _signingDomain() { 27 | if (this._domain != null) { 28 | return this._domain; 29 | } 30 | const chainId = await this.contract.getChainID(); 31 | this._domain = { 32 | name: SIGNING_DOMAIN_NAME, 33 | version: SIGNING_DOMAIN_VERSION, 34 | verifyingContract: this.contract.address, 35 | chainId, 36 | }; 37 | return this._domain; 38 | } 39 | } 40 | 41 | module.exports = { 42 | WhiteList, 43 | }; 44 | -------------------------------------------------------------------------------- /tests/nft-mint.test.js: -------------------------------------------------------------------------------- 1 | const {expect} = require("chai"); 2 | const {ethers} = require("hardhat"); 3 | const {advanceTime, currentTimestamp} = require("./utils/utils"); 4 | const {WhiteList} = require("./utils/sinature"); 5 | const {BigNumber} = require("ethers"); 6 | 7 | describe("Starting the minting test", () => { 8 | let alice, bob, nft; 9 | 10 | before(async () => { 11 | [alice, bob] = await ethers.getSigners(); 12 | const MagicNFT = await ethers.getContractFactory("DKeeperNFT"); 13 | nft = await MagicNFT.deploy(); 14 | 15 | await nft.initialize("DKeeper NFT", "DKeeper", 200, alice.address); 16 | }); 17 | 18 | it("Test: Public Mint Success", async function () { 19 | await nft.connect(bob).publicMint(1, {value: ethers.utils.parseEther("0.5")}); 20 | 21 | const owner = await nft.ownerOf(1); 22 | expect(owner).to.equal(bob.address); 23 | }); 24 | 25 | it("Test: Owner Mint Success", async function () { 26 | await nft.connect(alice).ownerMint(1); 27 | 28 | const owner = await nft.ownerOf(2); 29 | const ownerMinted = await nft.ownerMinted(); 30 | expect(owner).to.equal(alice.address) && expect(BigNumber.from(ownerMinted)).to.eq(1); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /contracts/DeepToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) 3 | 4 | pragma solidity 0.8.4; 5 | 6 | import "@openzeppelin/contracts/access/Ownable.sol"; 7 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; 8 | 9 | /** 10 | * @title DEEPToken 11 | */ 12 | contract DeepToken is ERC20Capped, Ownable { 13 | // Minters of DeepToken 14 | mapping(address => bool) public minters; 15 | 16 | // The maximum number of minting tokens from minters 17 | mapping(address => uint256) public allocation; 18 | 19 | // The number of token minted from minters 20 | mapping(address => uint256) public minted; 21 | 22 | constructor() ERC20Capped(1e26) ERC20("DEEPToken", "DEEP") {} 23 | 24 | modifier onlyMinter() { 25 | require(minters[msg.sender], "Invalid minter address"); 26 | _; 27 | } 28 | 29 | ///////////////////////// 30 | //// Owner Functions //// 31 | ///////////////////////// 32 | 33 | function setMinter(address _account, bool _isMinter) public onlyOwner { 34 | require(_account != address(0), "Invalid address"); 35 | minters[_account] = _isMinter; 36 | } 37 | 38 | function setAllocation(address _account, uint256 _amount) public onlyOwner { 39 | require(_account != address(0), "Invalid address"); 40 | allocation[_account] = _amount; 41 | } 42 | 43 | ///////////////////////// 44 | //// Minter Functions /// 45 | ///////////////////////// 46 | 47 | function mint(address _account, uint256 _amount) public onlyMinter { 48 | require( 49 | minted[msg.sender] + _amount <= allocation[msg.sender], 50 | "Not able to mint more tokens" 51 | ); 52 | minted[msg.sender] += _amount; 53 | _mint(_account, _amount); 54 | } 55 | 56 | function burn(address _account, uint256 _amount) public onlyMinter { 57 | _burn(_account, _amount); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from "path"; 2 | require("dotenv").config(); 3 | 4 | import { HardhatUserConfig } from "hardhat/config"; 5 | import { NetworkUserConfig } from "hardhat/types"; 6 | 7 | import "@nomiclabs/hardhat-waffle"; 8 | import "@nomiclabs/hardhat-etherscan"; 9 | import "@nomiclabs/hardhat-truffle5"; 10 | import "@openzeppelin/hardhat-upgrades"; 11 | import "hardhat-typechain"; 12 | import "solidity-coverage"; 13 | import "hardhat-contract-sizer"; 14 | 15 | //if (!process.env.MNEMONICS) throw new Error("MNEMONICS missing from .env file"); 16 | if (!process.env.MAINNET_PRIVKEY) 17 | throw new Error("MAINNET_PRIVKEY missing from .env file"); 18 | 19 | //const mnemonics = process.env.MNEMONICS; 20 | 21 | const config = { 22 | defaultNetwork: "hardhat", 23 | networks: { 24 | hardhat: { 25 | allowUnlimitedContractSize: true, 26 | blockGasLimit: 100000000, 27 | gas: 100000000, 28 | }, 29 | bsc: { 30 | url: `https://bsc-dataseed.binance.org/`, 31 | accounts: [process.env.MAINNET_PRIVKEY], 32 | }, 33 | testnet: { 34 | url: `https://data-seed-prebsc-1-s1.binance.org:8545/`, 35 | accounts: [process.env.MAINNET_PRIVKEY], 36 | }, 37 | }, 38 | etherscan: { 39 | apiKey: process.env.BSCSCAN_API, 40 | }, 41 | paths: { 42 | artifacts: "./artifacts", 43 | cache: "./cache", 44 | sources: "./contracts", 45 | tests: "./tests", 46 | }, 47 | solidity: { 48 | compilers: [ 49 | { 50 | version: "0.8.4", 51 | settings: { 52 | optimizer: { 53 | enabled: true, 54 | runs: 200, 55 | }, 56 | }, 57 | }, 58 | ], 59 | settings: { 60 | optimizer: { 61 | enabled: true, 62 | runs: 200, 63 | }, 64 | }, 65 | }, 66 | mocha: { 67 | timeout: 2000000000, 68 | }, 69 | typechain: { 70 | outDir: "types/contracts", 71 | target: "truffle-v5", 72 | }, 73 | }; 74 | 75 | export default config; 76 | -------------------------------------------------------------------------------- /scripts/MultiCall.json: -------------------------------------------------------------------------------- 1 | { 2 | "contract": { 3 | "56": "0x1ee38d535d541c55c9dae27b12edf090c608e6fb", 4 | "97": "0x35be5ca7917442ed5d2d4cc56ec9988dd158513e" 5 | }, 6 | "abi": [ 7 | { 8 | "constant": true, 9 | "inputs": [], 10 | "name": "getCurrentBlockTimestamp", 11 | "outputs": [{ "name": "timestamp", "type": "uint256" }], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "components": [ 21 | { "name": "target", "type": "address" }, 22 | { "name": "callData", "type": "bytes" } 23 | ], 24 | "name": "calls", 25 | "type": "tuple[]" 26 | } 27 | ], 28 | "name": "aggregate", 29 | "outputs": [ 30 | { "name": "blockNumber", "type": "uint256" }, 31 | { "name": "returnData", "type": "bytes[]" } 32 | ], 33 | "payable": false, 34 | "stateMutability": "nonpayable", 35 | "type": "function" 36 | }, 37 | { 38 | "constant": true, 39 | "inputs": [], 40 | "name": "getLastBlockHash", 41 | "outputs": [{ "name": "blockHash", "type": "bytes32" }], 42 | "payable": false, 43 | "stateMutability": "view", 44 | "type": "function" 45 | }, 46 | { 47 | "constant": true, 48 | "inputs": [{ "name": "addr", "type": "address" }], 49 | "name": "getEthBalance", 50 | "outputs": [{ "name": "balance", "type": "uint256" }], 51 | "payable": false, 52 | "stateMutability": "view", 53 | "type": "function" 54 | }, 55 | { 56 | "constant": true, 57 | "inputs": [], 58 | "name": "getCurrentBlockDifficulty", 59 | "outputs": [{ "name": "difficulty", "type": "uint256" }], 60 | "payable": false, 61 | "stateMutability": "view", 62 | "type": "function" 63 | }, 64 | { 65 | "constant": true, 66 | "inputs": [], 67 | "name": "getCurrentBlockGasLimit", 68 | "outputs": [{ "name": "gaslimit", "type": "uint256" }], 69 | "payable": false, 70 | "stateMutability": "view", 71 | "type": "function" 72 | }, 73 | { 74 | "constant": true, 75 | "inputs": [], 76 | "name": "getCurrentBlockCoinbase", 77 | "outputs": [{ "name": "coinbase", "type": "address" }], 78 | "payable": false, 79 | "stateMutability": "view", 80 | "type": "function" 81 | }, 82 | { 83 | "constant": true, 84 | "inputs": [{ "name": "blockNumber", "type": "uint256" }], 85 | "name": "getBlockHash", 86 | "outputs": [{ "name": "blockHash", "type": "bytes32" }], 87 | "payable": false, 88 | "stateMutability": "view", 89 | "type": "function" 90 | } 91 | ] 92 | } 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magic-craft-contracts", 3 | "version": "1.0.0", 4 | "description": "Magic Craft contracts", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "hardhat test", 8 | "compile": "hardhat compile", 9 | "coverage": "npx hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./tests/**/*.ts\"", 10 | "deploy": "hardhat run deploy/deploy.ts", 11 | "deploy:nft": "hardhat run deploy/nft.ts", 12 | "deploy:network": "hardhat run deploy/deploy.ts --network", 13 | "ganache": "yarn ganache-cli -e 1000000000000 -a 100 --networkId 999 -p 8545", 14 | "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"", 15 | "lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .", 16 | "verify": "hardhat verify --network", 17 | "flatten": "hardhat flatten" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MagicCraftCompany/Contract.git" 22 | }, 23 | "keywords": [], 24 | "author": "", 25 | "license": "ISC", 26 | "bugs": { 27 | "url": "https://github.com/MagicCraftCompany/Contract" 28 | }, 29 | "homepage": "https://github.com/MagicCraftCompany/Contract#readme", 30 | "devDependencies": { 31 | "@nomiclabs/hardhat-ethers": "^2.0.2", 32 | "@nomiclabs/hardhat-etherscan": "^3.1.0", 33 | "@nomiclabs/hardhat-truffle5": "^2.0.0", 34 | "@nomiclabs/hardhat-web3": "^2.0.0", 35 | "@openzeppelin/hardhat-upgrades": "^1.8.2", 36 | "@openzeppelin/test-helpers": "^0.5.15", 37 | "@typechain/truffle-v5": "^4.0.1", 38 | "@types/chai": "^4.2.21", 39 | "@types/mocha": "^8.2.2", 40 | "@typescript-eslint/eslint-plugin": "^3.10.1", 41 | "@typescript-eslint/parser": "^3.10.1", 42 | "chai": "^4.3.4", 43 | "dotenv": "^8.6.0", 44 | "eslint": "^7.27.0", 45 | "eslint-config-prettier": "^6.12.0", 46 | "ethers": "^5.2.0", 47 | "hardhat": "^2.3.0", 48 | "hardhat-contract-sizer": "^2.1.0", 49 | "prettier": "^2.4.1", 50 | "prettier-plugin-solidity": "^1.0.0-beta.18", 51 | "solhint": "^3.3.5", 52 | "solhint-plugin-prettier": "^0.0.5", 53 | "solidity-coverage": "^0.7.16", 54 | "ts-generator": "^0.1.1", 55 | "typechain": "^4.0.3", 56 | "typescript": "^3.9.7" 57 | }, 58 | "dependencies": { 59 | "@nomiclabs/hardhat-waffle": "^2.0.1", 60 | "@openzeppelin/contracts": "^4.4.2", 61 | "@openzeppelin/contracts-upgradeable": "^4.4.2", 62 | "@truffle/hdwallet-provider": "^1.4.0", 63 | "axios": "^0.27.0", 64 | "ethereum-waffle": "^3.4.0", 65 | "ganache-cli": "^6.12.2", 66 | "hardhat-typechain": "^0.3.4", 67 | "multi-token-standard": "^2.2.2", 68 | "truffle": "^5.3.7", 69 | "truffle-flattener": "^1.5.0", 70 | "truffle-plugin-verify": "^0.5.6", 71 | "ts-node": "^9.1.1" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /deploy/deploy.ts: -------------------------------------------------------------------------------- 1 | import { BigNumber, Contract, ContractFactory } from "ethers"; 2 | // We require the Hardhat Runtime Environment explicitly here. This is optional 3 | // but useful for running the script in a standalone fashion through `node