├── .solhintignore ├── .npmignore ├── .eslintignore ├── .prettierignore ├── .prettierrc ├── .gitignore ├── contracts ├── test │ ├── LinkToken.sol │ ├── VRFCoordinatorMock.sol │ └── MockUFO.sol ├── ChampionQuestToken.sol └── ChampionQuest.sol ├── .solhint.json ├── .env.example ├── .eslintrc.js ├── hardhat-helper-config.js ├── deploy ├── 01_deploy_champion_quest_token.js ├── 00_deploy_mocks.js └── 02_deploy_champion_quest.js ├── package.json ├── scripts └── deploy.js ├── hardhat.config.js ├── README.md ├── test ├── championQuestToken.test.js └── championQuest.test.js └── gasReport.md /.solhintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | hardhat.config.js 2 | scripts 3 | test 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | artifacts 3 | cache 4 | coverage 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | artifacts 3 | cache 4 | coverage* 5 | gasReporterOutput.json 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "trailingComma": "all", 4 | "printWidth": 127 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | coverage 4 | coverage.json 5 | typechain 6 | 7 | #Hardhat files 8 | cache 9 | artifacts 10 | -------------------------------------------------------------------------------- /contracts/test/LinkToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.4.24; 3 | 4 | import "@chainlink/token/contracts/v0.4/LinkToken.sol"; 5 | -------------------------------------------------------------------------------- /contracts/test/VRFCoordinatorMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.6.0; 3 | 4 | import "@chainlink/contracts/src/v0.6/tests/VRFCoordinatorMock.sol"; 5 | -------------------------------------------------------------------------------- /.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "solhint:recommended", 3 | "rules": { 4 | "compiler-version": ["error", "^0.8.0"], 5 | "func-visibility": ["warn", { "ignoreConstructors": true }] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1 2 | ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/ 3 | PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 4 | -------------------------------------------------------------------------------- /contracts/test/MockUFO.sol: -------------------------------------------------------------------------------- 1 | // contracts/GLDToken.sol 2 | // SPDX-License-Identifier: MIT 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | 7 | contract MockUFO is ERC20 { 8 | constructor(uint256 initial_supply) ERC20("UFO", "UFO") { 9 | _mint(msg.sender, initial_supply); // 5000 UFOs 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: false, 4 | es2021: true, 5 | mocha: true, 6 | node: true, 7 | }, 8 | plugins: ["@typescript-eslint"], 9 | extends: [ 10 | "standard", 11 | "plugin:prettier/recommended", 12 | "plugin:node/recommended", 13 | ], 14 | "prettier/prettier": ["error", {}, { 15 | "usePrettierrc": true 16 | }], 17 | parser: "@typescript-eslint/parser", 18 | parserOptions: { 19 | ecmaVersion: 12, 20 | }, 21 | rules: { 22 | "node/no-unsupported-features/es-syntax": [ 23 | "error", 24 | { ignores: ["modules"] }, 25 | ], 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /hardhat-helper-config.js: -------------------------------------------------------------------------------- 1 | const networkConfig = { 2 | hardhat: { 3 | id: 31337, 4 | linkToken: "0xa36085F69e2889c224210F603D836748e7dC0088", 5 | oracle: "0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8", 6 | jobId: "d5270d1c311941d0b08bead21fea7747", 7 | fundAmount: "1000000000000000000", 8 | keyHash: '0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4', 9 | fee: '100000000000000000', 10 | battleFee: '100000000000000000', 11 | ufoInitialSupply: '5000000000000000000000' 12 | } 13 | } 14 | 15 | const developmentChains = ["hardhat", "localhost"] 16 | 17 | module.exports = { 18 | networkConfig, 19 | developmentChains 20 | } 21 | -------------------------------------------------------------------------------- /deploy/01_deploy_champion_quest_token.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable node/no-unpublished-import */ 2 | // eslint-disable-next-line node/no-missing-import 3 | 4 | const hre = require("hardhat") 5 | 6 | const deployMocks = async function (hre) { 7 | const { deployments, getNamedAccounts, getChainId } = hre 8 | const { deploy, log, get } = deployments 9 | const { deployer } = await getNamedAccounts() 10 | const chainId = await getChainId() 11 | const ufoToken = await get("MockUFO") 12 | const championQuestToken = await deploy("ChampionQuestToken", { 13 | from: deployer, 14 | log: true, 15 | args: [ufoToken.address], 16 | }) 17 | } 18 | module.exports = deployMocks 19 | deployMocks.tags = ["all", "token"] 20 | -------------------------------------------------------------------------------- /contracts/ChampionQuestToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | // inspired by woofy: https://etherscan.io/address/0xd0660cd418a64a1d44e9214ad8e459324d8157f1#code 5 | 6 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 7 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 8 | 9 | contract ChampionQuestToken is ERC20 { 10 | IERC20 public immutable s_ufoToken; 11 | 12 | constructor(address ufoTokenAddress) ERC20("ChampionQuestToken", "CQT") { 13 | s_ufoToken = IERC20(ufoTokenAddress); 14 | } 15 | 16 | function decimals() public view virtual override returns (uint8) { 17 | return 12; 18 | } 19 | 20 | function swapUFOForCQT(uint256 amount) public { 21 | s_ufoToken.transferFrom(msg.sender, address(this), amount); 22 | _mint(msg.sender, amount); 23 | } 24 | 25 | function swapCQTForUFO(uint256 amount) public { 26 | _burn(msg.sender, amount); 27 | s_ufoToken.transfer(msg.sender, amount); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "devDependencies": { 4 | "@nomiclabs/hardhat-ethers": "^2.0.2", 5 | "@nomiclabs/hardhat-etherscan": "^2.1.7", 6 | "@nomiclabs/hardhat-waffle": "^2.0.1", 7 | "chai": "^4.3.4", 8 | "dotenv": "^10.0.0", 9 | "eslint": "^7.32.0", 10 | "eslint-config-prettier": "^8.3.0", 11 | "eslint-config-standard": "^16.0.3", 12 | "eslint-plugin-import": "^2.25.3", 13 | "eslint-plugin-node": "^11.1.0", 14 | "eslint-plugin-prettier": "^3.4.1", 15 | "eslint-plugin-promise": "^5.1.1", 16 | "ethereum-waffle": "^3.4.0", 17 | "ethers": "^5.5.1", 18 | "hardhat": "^2.6.8", 19 | "hardhat-gas-reporter": "^1.0.4", 20 | "prettier": "^2.4.1", 21 | "prettier-plugin-solidity": "^1.0.0-beta.13", 22 | "solhint": "^3.3.6", 23 | "solidity-coverage": "^0.7.17" 24 | }, 25 | "dependencies": { 26 | "@appliedblockchain/chainlink-plugins-fund-link": "^0.0.3", 27 | "@chainlink/contracts": "^0.2.2", 28 | "@chainlink/token": "^1.1.0", 29 | "@openzeppelin/contracts": "^4.3.3", 30 | "hardhat-deploy": "^0.9.13" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | // We require the Hardhat Runtime Environment explicitly here. This is optional 2 | // but useful for running the script in a standalone fashion through `node