Initial commit
This commit is contained in:
26
hardhat/.gitignore
vendored
Normal file
26
hardhat/.gitignore
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# Node modules
|
||||
/node_modules
|
||||
|
||||
# Compilation output
|
||||
/dist
|
||||
|
||||
# pnpm deploy output
|
||||
/bundle
|
||||
|
||||
# Hardhat Build Artifacts
|
||||
/artifacts
|
||||
|
||||
# Deployments by students
|
||||
/ignition/deployments
|
||||
|
||||
# Hardhat compilation (v2) support directory
|
||||
/cache
|
||||
|
||||
# Typechain output
|
||||
/types
|
||||
|
||||
# Hardhat coverage reports
|
||||
/coverage
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
41
hardhat/README.md
Normal file
41
hardhat/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Hardhat 3 Project
|
||||
|
||||
This is a Hardhat 3 project, which uses the native Node.js test runner (`node:test`) and the `viem` library for Ethereum interactions.
|
||||
|
||||
|
||||
|
||||
## Building
|
||||
|
||||
To build, run:
|
||||
|
||||
```shell
|
||||
npx hardhat build
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Running Tests
|
||||
|
||||
To run all the tests in the project, execute the following command:
|
||||
|
||||
```shell
|
||||
npx hardhat test
|
||||
```
|
||||
|
||||
You can also selectively run the `node:test` tests:
|
||||
|
||||
```shell
|
||||
npx hardhat test nodejs
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Make a deployment to Next Testnet
|
||||
|
||||
This project includes an example Ignition module to deploy a contract to our testnet.
|
||||
|
||||
To run the deployment to Next Testnet, set your mnemonics in an .env file (MNEMONICS=...) and run:
|
||||
|
||||
```shell
|
||||
npx hardhat ignition deploy --network next ignition/modules/PowersOfTwo.ts
|
||||
```
|
||||
16
hardhat/chains/next.ts
Normal file
16
hardhat/chains/next.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { defineChain } from 'viem';
|
||||
|
||||
export const nextChain = defineChain({
|
||||
id: 1337,
|
||||
name: 'Next',
|
||||
nativeCurrency: {
|
||||
name: 'Ether',
|
||||
symbol: 'ETH',
|
||||
decimals: 18
|
||||
},
|
||||
rpcUrls: {
|
||||
default: {
|
||||
http: ['https://eth.code-camp.org']
|
||||
}
|
||||
}
|
||||
});
|
||||
7
hardhat/contracts/PowersOfTwo.sol
Normal file
7
hardhat/contracts/PowersOfTwo.sol
Normal file
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.28;
|
||||
|
||||
contract PowersOfTwo {
|
||||
|
||||
// your code goes here...
|
||||
}
|
||||
49
hardhat/hardhat.config.ts
Normal file
49
hardhat/hardhat.config.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import "dotenv/config";
|
||||
|
||||
import hardhatToolboxViemPlugin from "@nomicfoundation/hardhat-toolbox-viem";
|
||||
import { configVariable, defineConfig } from "hardhat/config";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [hardhatToolboxViemPlugin],
|
||||
solidity: {
|
||||
profiles: {
|
||||
default: {
|
||||
version: "0.8.28",
|
||||
},
|
||||
production: {
|
||||
version: "0.8.28",
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
networks: {
|
||||
hardhatMainnet: {
|
||||
type: "edr-simulated",
|
||||
chainType: "l1",
|
||||
},
|
||||
hardhatOp: {
|
||||
type: "edr-simulated",
|
||||
chainType: "op",
|
||||
},
|
||||
sepolia: {
|
||||
type: "http",
|
||||
chainType: "l1",
|
||||
url: configVariable("SEPOLIA_RPC_URL"),
|
||||
accounts: [configVariable("SEPOLIA_PRIVATE_KEY")],
|
||||
},
|
||||
next: {
|
||||
type: "http",
|
||||
chainId: 1337,
|
||||
chainType: "l1",
|
||||
url: "https://eth.code-camp.org",
|
||||
accounts: {
|
||||
mnemonic: configVariable("MNEMONICS"),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
6
hardhat/ignition/modules/PowersOfTwo.ts
Normal file
6
hardhat/ignition/modules/PowersOfTwo.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
|
||||
|
||||
export default buildModule("PowersOfTwoModule", (m) => {
|
||||
const powersOfTwo = m.contract("PowersOfTwo");
|
||||
return { powersOfTwo };
|
||||
});
|
||||
17
hardhat/install-deps.js
Normal file
17
hardhat/install-deps.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import fs from 'fs';
|
||||
import { execSync } from 'child_process';
|
||||
import path from 'path';
|
||||
|
||||
const parentDirectory = process.cwd();
|
||||
if (parentDirectory.includes('hardhat') && !fs.existsSync(path.join(parentDirectory, 'hardhat'))) {
|
||||
parentDirectory = path.join(parentDirectory, '..');
|
||||
}
|
||||
|
||||
const hardhatDirectory = path.join(parentDirectory, 'hardhat');
|
||||
|
||||
if (!fs.existsSync(path.join(hardhatDirectory, 'node_modules'))) {
|
||||
console.log('Hardhat directory node_modules not found. Installing...');
|
||||
execSync('npm install', { stdio: 'inherit', cwd: hardhatDirectory });
|
||||
} else {
|
||||
console.log('Hardhat directory node_modules already exists. Skipping.');
|
||||
}
|
||||
2948
hardhat/package-lock.json
generated
Normal file
2948
hardhat/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
hardhat/package.json
Normal file
17
hardhat/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "hardhat-code",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@nomicfoundation/hardhat-ignition": "^3.0.7",
|
||||
"@nomicfoundation/hardhat-toolbox-viem": "^5.0.2",
|
||||
"@types/node": "^22.19.11",
|
||||
"forge-std": "github:foundry-rs/forge-std#v1.9.4",
|
||||
"hardhat": "^3.1.8",
|
||||
"typescript": "~5.8.0",
|
||||
"viem": "^2.46.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.3.1"
|
||||
}
|
||||
}
|
||||
17
hardhat/test/PowersOfTwo.ts
Normal file
17
hardhat/test/PowersOfTwo.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
|
||||
import { network } from "hardhat";
|
||||
|
||||
describe("PowersOfTwo", async function () {
|
||||
const { viem } = await network.connect();
|
||||
const publicClient = await viem.getPublicClient();
|
||||
|
||||
it("The test name goes here...", async function () {
|
||||
const contract = await viem.deployContract("PowersOfTwo");
|
||||
|
||||
// you can write commands/asserts/etc here
|
||||
// ...
|
||||
// ...
|
||||
});
|
||||
});
|
||||
13
hardhat/tsconfig.json
Normal file
13
hardhat/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
/* Based on https://github.com/tsconfig/bases/blob/501da2bcd640cf95c95805783e1012b992338f28/bases/node22.json */
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2023"],
|
||||
"module": "node16",
|
||||
"target": "es2022",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node16",
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user