Skip to content

Commit f175e21

Browse files
committed
Move deploy to tasks
1 parent 7419953 commit f175e21

File tree

5 files changed

+28
-36
lines changed

5 files changed

+28
-36
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ yarn hardhat coverage
2525
Deploy to Alfajores (Celo Testnet):
2626

2727
```shell
28-
yarn hardhat run scripts/deploy.ts --network alfajores
28+
yarn hardhat deploy --network alfajores
2929
```
3030

3131
Deploy to Celo Mainnet:
3232

3333
```shell
34-
yarn hardhat run scripts/deploy.ts --network celo
34+
yarn hardhat deploy --network celo
3535
```
3636

3737
Deploy to Mumbai (Polygon Testnet):
3838

3939
```shell
40-
yarn hardhat run scripts/deploy.ts --network mumbai
40+
yarn hardhat deploy --network mumbai
4141
```
4242

4343
Deploy to Polygon Mainnet:
4444

4545
```shell
46-
yarn hardhat run scripts/deploy.ts --network polygon
46+
yarn hardhat deploy --network polygon
4747
```
4848

4949
Then, copy the deployment address and start using it in your client application!

hardhat.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ import "@nomiclabs/hardhat-waffle";
66
import "@typechain/hardhat";
77
import "hardhat-gas-reporter";
88
import "solidity-coverage";
9+
import glob from 'glob';
10+
import path from 'path';
911

1012
dotenv.config();
1113

14+
glob.sync('./tasks/**/*.ts').forEach(function (file) {
15+
require(path.resolve(file));
16+
});
17+
1218
// This is a sample Hardhat task. To learn how to create your own go to
1319
// https://hardhat.org/guides/create-task.html
1420
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {

scripts/deploy.ts

-31
This file was deleted.

tasks/deploy.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { task } from "hardhat/config";
2+
3+
task("deploy", "Full contract deploy", async (taskArgs, hre) => {
4+
5+
// Call compile manually to make sure everything is compiled
6+
await hre.run('compile');
7+
8+
// We get the contract to deploy
9+
const Contract = await hre.ethers.getContractFactory("Traceability");
10+
11+
const contract = await Contract.deploy();
12+
13+
await contract.deployed();
14+
15+
console.info("Traceability contract deployed to:", contract.address);
16+
17+
});

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"outDir": "dist",
88
"declaration": true
99
},
10-
"include": ["./scripts", "./test", "./typechain"],
10+
"include": ["./tasks", "./test", "./typechain"],
1111
"files": ["./hardhat.config.ts"]
1212
}

0 commit comments

Comments
 (0)