From eca551ee3fa041e91c614b9d106a0515b6c7ab9a Mon Sep 17 00:00:00 2001 From: Ruidy Date: Thu, 7 Apr 2022 07:00:28 -0400 Subject: [PATCH] starter contract --- contracts/EpicNFT.sol | 10 ++++++++++ contracts/Greeter.sol | 22 ---------------------- hardhat.config.js | 5 ----- package.json | 2 +- scripts/run.js | 18 ++++++++++++++++++ scripts/sample-script.js | 32 -------------------------------- test/{sample-test.js => run.js} | 0 7 files changed, 29 insertions(+), 60 deletions(-) create mode 100644 contracts/EpicNFT.sol delete mode 100644 contracts/Greeter.sol create mode 100644 scripts/run.js delete mode 100644 scripts/sample-script.js rename test/{sample-test.js => run.js} (100%) diff --git a/contracts/EpicNFT.sol b/contracts/EpicNFT.sol new file mode 100644 index 0000000..45eac13 --- /dev/null +++ b/contracts/EpicNFT.sol @@ -0,0 +1,10 @@ +//SPDX-License-Identifier: Unlicensed +pragma solidity ^0.8.0; + +import "hardhat/console.sol"; + +contract EpicNFT { + constructor() { + console.log("My first NFT contract!"); + } +} diff --git a/contracts/Greeter.sol b/contracts/Greeter.sol deleted file mode 100644 index efffb8f..0000000 --- a/contracts/Greeter.sol +++ /dev/null @@ -1,22 +0,0 @@ -//SPDX-License-Identifier: Unlicense -pragma solidity ^0.8.0; - -import "hardhat/console.sol"; - -contract Greeter { - string private greeting; - - constructor(string memory _greeting) { - console.log("Deploying a Greeter with greeting:", _greeting); - greeting = _greeting; - } - - function greet() public view returns (string memory) { - return greeting; - } - - function setGreeting(string memory _greeting) public { - console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); - greeting = _greeting; - } -} diff --git a/hardhat.config.js b/hardhat.config.js index cfeed55..20a3341 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -1,7 +1,5 @@ require("@nomiclabs/hardhat-waffle"); -// This is a sample Hardhat task. To learn how to create your own go to -// https://hardhat.org/guides/create-task.html task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { const accounts = await hre.ethers.getSigners(); @@ -10,9 +8,6 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { } }); -// You need to export an object to set up your config -// Go to https://hardhat.org/config/ to learn more - /** * @type import('hardhat/config').HardhatUserConfig */ diff --git a/package.json b/package.json index 99c4df7..3adac09 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "license": "MIT", "scripts": { - "dev": "npx hardhat run scripts/sample-script.js" + "dev": "npx hardhat run scripts/run.js" }, "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.0", diff --git a/scripts/run.js b/scripts/run.js new file mode 100644 index 0000000..b601dd0 --- /dev/null +++ b/scripts/run.js @@ -0,0 +1,18 @@ +const hre = require("hardhat"); // this import is optional + +async function main() { + const EpicNFT = await hre.ethers.getContractFactory("EpicNFT"); + const contract = await EpicNFT.deploy(); + await contract.deployed(); + console.log("EpicNFT deployed to:", contract.address); +} + +(async () => { + try { + await main(); + process.exit(0); + } catch (err) { + console.error(err); + process.exit(1); + } +})(); diff --git a/scripts/sample-script.js b/scripts/sample-script.js deleted file mode 100644 index 90cd819..0000000 --- a/scripts/sample-script.js +++ /dev/null @@ -1,32 +0,0 @@ -// We require the Hardhat Runtime Environment explicitly here. This is optional -// but useful for running the script in a standalone fashion through `node