Skip to content

Commit

Permalink
updated changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanProgrammer committed Oct 20, 2023
1 parent 7eed6ad commit 84bd781
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 50 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## 2.0.0

### Deployer
### Deployer

* Added support for EthersV5, EthersV6 and TruffleV5 through Adapters
* Added types support for EthersV5 and EthersV6 only (constructor arguments validation is included)
* Add a library linking during contract deployment
* Enhanced reporting during contract deployment
* Added recoverability of contract deployments
* Added better error reporting during contract deployment
* Enhanced the contract deployment via proxy deployment
* Added special user storage for between deployments
* Provided a variety of verification options for contract deployments

...
85 changes: 36 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

## What

This plugin helps you deploy and automatically verify the source code for your Solidity contracts on [Etherscan](https://etherscan.io).
This plugin helps you deploy and automatically verify the source code for your Solidity contracts on [Etherscan](https://etherscan.io)-based explorers and explorers compatible with its API like [Blockscout](https://www.blockscout.com/).

This is a fairly simple and rather straightforward Hardhat plugin:

- For deployment, it uses [@truffle/deployer](https://www.npmjs.com/package/@truffle/deployer) and
[@truffle/reporters](https://www.npmjs.com/package/@truffle/reporters) to report on the deployment process.
- For deployment, it uses [@ethers](https://www.npmjs.com/package/ethers).

- For verification, it uses [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan)
- For verification, it uses [@nomicfoundation/hardhat-verify](https://www.npmjs.com/package/@nomicfoundation/hardhat-verify).

## Installation

Expand All @@ -24,46 +23,36 @@ npm install --save-dev @solarity/hardhat-migrate
And add the following statement to your `hardhat.config.js`:

```js
require("@nomiclabs/hardhat-web3");
require("@nomiclabs/hardhat-truffle5");
require("@solarity/hardhat-migrate");
```

Or, if you are using TypeScript, add this to your `hardhat.config.ts`:

```ts
import "@nomiclabs/hardhat-web3";
import "@nomiclabs/hardhat-truffle5";
import "@solarity/hardhat-migrate";
```

> **Important**.
The `@nomiclabs/hardhat-web3` and `@nomiclabs/hardhat-truffle5` are necessary,
as these plugins are used to work with migration files.

See [How it works](https://github.com/dl-solarity/hardhat-migrate#how-it-works) for further information.

## Naming convention

It is also **mandatory** to specify the naming convention for migrations such as this one:

> X_migration_name.migration.js
> X_migration_name.migration.[js|ts]
- Where **X** is an ordinal number of the migration in which it will be applied.
- migration_name is simply the name of the migration.
- **migration_name** is simply the name of the migration.

## Tasks

- `migrate` task, which allows you to deploy and automatically verify contracts.
- `migrate:verify` task, which helps you verify already deployed contracts.

Under the hood, for verification process, it uses [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan)
plugin.

> :warning: **Hardhat Config**: Make sure they are follow the docs from `@nomiclabs/hardhat-etherscan`.
> :warning: **Hardhat Config**: Make sure they are follow the docs from `@nomicfoundation/hardhat-verify`.
Do not import `@solarity/hardhat-migrate` and `@nomiclabs/hardhat-etherscan` together, the etherscan plugin is already included in the migrate plugin.
Do not import `@solarity/hardhat-migrate` and `@nomicfoundation/hardhat-verify`, `@nomicfoundation/hardhat-ethers` together, the etherscan plugin is already included in the migrate plugin.

To view the available options, run the command (help command):

Expand All @@ -73,7 +62,10 @@ npx hardhat help migrate

## Environment extensions

This plugin does not extend the environment.
This plugin extends the Hardhat Runtime Environment by adding the following fields:

- `deployer` - The deployer object that is used to deploy contracts.
- `verifier` - The verifier object that is used to verify contracts.

## Usage

Expand All @@ -82,15 +74,18 @@ You may add the following `migrate` config to your _hardhat config_ file:
```js
module.exports = {
migrate: {
from: 1,
to: 5,
only: 2,
skip: 1,
verify: true,
attempts: 2,
confirmations: 5,
pathToMigrations: "./deploy/",
from: -1,
to: -1,
only: -1,
skip: -1,
txConfirmations: 1,
verifyConfirmations: 0,
verify: VerifyStrategy.AtTheEnd,
attempts: 0,
pathToMigrations: "./deploy",
skipVerificationErrors: ["already verified"],
force: false,
continuePreviousDeployment: false,
},
};
```
Expand All @@ -101,15 +96,16 @@ module.exports = {
- `to` : The migration number up to which the migration will be applied.
- `only` : The number of the migration that will be applied. **Overrides from and to parameters.**
- `skip`: The number of migration to skip. **Overrides only parameter.**
- `confirmations` : The number defining after how many blocks the verification should start.
- `txConfirmations` : The number of confirmations to wait for after the transaction is mined.
- `verifyConfirmations` : The number of confirmations to wait for before sending a request to etherscan.
- `verify` : The strategy of verification. The user can choose between `immediately`, `at-the-end` and `none`.
- `attempts`: The number of attempts to verify the contract.
- `pathToMigrations` : The path to the folder with the specified migrations.
- `skipVerificationErrors` : The user can specify custom verification errors that will be omitted and just be printed
to the log instead of stopping the program completely.
By default, if this parameter is not specified, the `already verified` error is omitted.

* `verify` : The flag indicating whether the verification of the contract is needed.
* `force` : The flag indicating whether the contracts compilation is forced.
- `force` : The flag indicating whether the contracts compilation is forced.
- `continuePreviousDeployment` : The flag indicating whether the deployment should restore the state from the previous deployment.

### Deploying

Expand All @@ -118,15 +114,15 @@ You can set your own migrations and deploy the contracts to the network you want
#### With only parameter

```console
$ npx hardhat migrate --network goerli --verify --only 2
npx hardhat migrate --network goerli --verify immediately --only 2
```

In this case, only the migration that begins with digit 2 will be applied. The plugin will also try to automatically verify the deployed contracts.

#### Or with from/to parameters

```console
$ npx hardhat migrate --network sepolia --from 1 --to 2
npx hardhat migrate --network sepolia --from 1 --to 2
```

In this case, migrations 1 through 2 (both) will be applied without the automatic verification.
Expand All @@ -135,23 +131,22 @@ In this case, migrations 1 through 2 (both) will be applied without the automati

> _This plugin has a `migrate:verify` task, to learn how to use it, see the example project._
#### You can manually verify contracts:
#### You can manually verify contracts

```console
$ npx hardhat verify --network goerli DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"
npx hardhat verify --network goerli DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"
```

Other examples of manual contract verification can be found here [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan)
Other examples of manual contract verification can be found here [@nomicfoundation/hardhat-verify](https://www.npmjs.com/package/@nomicfoundation/hardhat-verify)

## How it works

The plugin includes the following packages to perform the deployment and verification process:

- For deployment
- [@nomiclabs/hardhat-web3](https://www.npmjs.com/package/@nomiclabs/hardhat-web3)
- [@nomiclabs/hardhat-truffle5](https://www.npmjs.com/package/@nomiclabs/hardhat-truffle5)
- [@ethers](https://www.npmjs.com/package/ethers)
- For verification:
- [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan)
- [@nomicfoundation/hardhat-verify](https://www.npmjs.com/package/@nomicfoundation/hardhat-verify)

The core of this plugin is migration files, you can specify the migration route that suits you best.

Expand All @@ -169,11 +164,10 @@ Deployer contains two functions that are used to deploy contracts:

- **Deployment function**

Under the hood, it uses `TruffleDeployer` from [@truffle/deployer](https://www.npmjs.com/package/@truffle/deployer)
and `TruffleReporter` from [@truffle/reporters](https://www.npmjs.com/package/@truffle/reporters) to deploy the contracts and log their statuses during the deployment process.
Under the hood, it uses `ContractFactory` from [@ethers](https://www.npmjs.com/package/ethers) to deploy the contracts.

After that, if the user had set the `verify` flag, the contract would be automatically verified. However,
the execution will wait `confirmations` number of blocks before sending a request to etherscan.
the execution will wait `verifyConfirmations` number of blocks before sending a request to etherscan.

- **Link function**

Expand All @@ -189,13 +183,6 @@ If verification fails, the `attempts` parameter indicates how many additional re

The user can also define which verification errors are irrelevant and have to be ignored using the `skipVerificationErrors` parameter. By default, the `already verified` error is omitted.

### Logger

Logger provides two functions:

- `logTransaction` - logs data about the transaction after its confirmation.
- `logContracts` - logs contract addresses in an assembled table.

## Known limitations

- This plugin, as well as the [Hardhat Toolbox](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox) plugin, use the [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) plugin internally, so both of these plugins cannot be imported at the same time. A quick fix is to manually import the needed plugins that ToolBox imports.
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { extendConfig, extendEnvironment, task, types } from "hardhat/config";
import { lazyObject } from "hardhat/plugins";
import { ActionType } from "hardhat/types";

import "./type-extensions";

import { mergeConfigs, migrateConfigExtender } from "./config";
import { TASK_MIGRATE } from "./constants";

Expand Down

0 comments on commit 84bd781

Please sign in to comment.