Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit c18039a

Browse files
committed
npx hardhat sample project
1 parent 0c3d17e commit c18039a

File tree

7 files changed

+23703
-3714
lines changed

7 files changed

+23703
-3714
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
1. `npm init --yes`
2+
3+
2. `npm install --save-dev hardhat`
4+
5+
3. add `node_modules` and `.env` to `.gitignore` file
6+
7+
4. `npx hardhat` -> sample project
8+
9+
5. in hardhat.config.js -> add mumbai network -> use alchemy rpc + metamask private key
10+
11+
6. get mumbai testnet eth from https://mumbaifaucet.com/
12+
13+
7.

contracts/Greeter.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
import "hardhat/console.sol";
5+
6+
contract Greeter {
7+
string private greeting;
8+
9+
constructor(string memory _greeting) {
10+
console.log("Deploying a Greeter with greeting:", _greeting);
11+
greeting = _greeting;
12+
}
13+
14+
function greet() public view returns (string memory) {
15+
return greeting;
16+
}
17+
18+
function setGreeting(string memory _greeting) public {
19+
console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
20+
greeting = _greeting;
21+
}
22+
}

hardhat.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require("@nomiclabs/hardhat-waffle");
2+
3+
// This is a sample Hardhat task. To learn how to create your own go to
4+
// https://hardhat.org/guides/create-task.html
5+
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
6+
const accounts = await hre.ethers.getSigners();
7+
8+
for (const account of accounts) {
9+
console.log(account.address);
10+
}
11+
});
12+
13+
// You need to export an object to set up your config
14+
// Go to https://hardhat.org/config/ to learn more
15+
16+
/**
17+
* @type import('hardhat/config').HardhatUserConfig
18+
*/
19+
module.exports = {
20+
solidity: "0.8.4"
21+
};

0 commit comments

Comments
 (0)