feat: migrate deployment to Hardhat Ignition
Replace the imperative deploy scripts with Hardhat Ignition modules:
- ignition/modules/{MockToken,Reputation,P2PIX}.ts orchestrate the full
deployment graph; P2PIX.ts wires MockToken + Reputation and deploys
P2PIX via its constructor
- ignition/parameters/localhost.json holds per-network values
(defaultBlocks, validSigners, MockToken supply)
- swap hardhat-toolbox for the individual plugins that Ignition needs;
add hardhat-verify (v2) and bump hardhat/hardhat-tracer accordingly
- delete scripts/1-deploy-mockToken.ts and scripts/2-deploy-p2pix.ts
- add deploy:{localhost,goerli,sepolia,mumbai} npm scripts
- include ignition/**/* in tsconfig.json
- gitignore ignition/deployments/chain-31337/ (ephemeral local state)
This branch carries the deployment-tooling migration only — the contract
is still the original constructor-based P2PIX. Proxy / UUPS deploy
support will land alongside the upgradeable contract change.
This commit is contained in:
52
README.md
52
README.md
@@ -125,36 +125,52 @@ To grab deployment addresses you can just grab from deploys folder:
|
||||
import localhostDeploys from "p2pix-smart-contracts/deploys/localhost.json";
|
||||
```
|
||||
|
||||
## Deploying to local environment
|
||||
## Deployment (Hardhat Ignition)
|
||||
|
||||
On the first teminal, use the following command and import some wallets to your Metamask, then connect to the network pointed:
|
||||
Deployments are orchestrated by
|
||||
[Hardhat Ignition](https://hardhat.org/ignition). Each module declares its
|
||||
contracts; Ignition handles ordering, idempotency, and per-network state
|
||||
under `ignition/deployments/`.
|
||||
|
||||
### Modules
|
||||
|
||||
- `ignition/modules/MockToken.ts` — ERC20 mock used in dev / testnets.
|
||||
- `ignition/modules/Reputation.ts` — Reputation + Multicall.
|
||||
- `ignition/modules/P2PIX.ts` — wires Reputation + MockToken and deploys
|
||||
P2PIX via its constructor, returning the full set of addresses.
|
||||
|
||||
### Per-network parameters
|
||||
|
||||
Network-specific values (e.g. `defaultBlocks`, `validSigners`, MockToken
|
||||
`supply`) live in `ignition/parameters/<network>.json`. Only
|
||||
`localhost.json` is checked in; copy it to e.g. `goerli.json` and set the
|
||||
network values before running the matching `deploy:*` script.
|
||||
|
||||
### Local environment
|
||||
|
||||
On the first terminal:
|
||||
|
||||
```sh
|
||||
yarn hardhat node
|
||||
```
|
||||
|
||||
On the second teminal, run the following commands:
|
||||
On the second terminal:
|
||||
|
||||
```sh
|
||||
yarn deploy1:localhost
|
||||
yarn deploy2:localhost
|
||||
yarn deploy:localhost
|
||||
```
|
||||
|
||||
**_NOTE_:** The second script transfers 2M tokens to the first wallet of the node.
|
||||
To use the P2Pix smart contract first transfer some of the tokens to other wallets.
|
||||
Addresses for every deployed contract are written to
|
||||
`ignition/deployments/chain-31337/deployed_addresses.json` (this path is
|
||||
gitignored — local-only state).
|
||||
|
||||
## Deploying to testnets
|
||||
|
||||
Deploy to Ethereum's Goerli testnet:
|
||||
### Testnets
|
||||
|
||||
```sh
|
||||
yarn deploy1:goerli
|
||||
yarn deploy2:goerli
|
||||
yarn deploy:goerli
|
||||
yarn deploy:sepolia
|
||||
yarn deploy:mumbai
|
||||
```
|
||||
|
||||
Deploy to Polygon's Mumbai testnet:
|
||||
|
||||
```sh
|
||||
yarn deploy1:mumbai
|
||||
yarn deploy2:mumbai
|
||||
```
|
||||
Each command requires the matching `ignition/parameters/<network>.json`
|
||||
and the relevant API keys in `.env`.
|
||||
|
||||
Reference in New Issue
Block a user