Skip to content

Commit 612fa49

Browse files
updated readme
1 parent e31dfe9 commit 612fa49

File tree

1 file changed

+77
-99
lines changed

1 file changed

+77
-99
lines changed

README.md

Lines changed: 77 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -15,148 +15,124 @@ privately push contracts to [Tenderly](https://tenderly.co).
1515
npm install --save-dev @tenderly/hardhat-tenderly
1616
```
1717

18-
And add the following statement to your `hardhat.config.js`:
18+
And add the following statement to your `hardhat.config.js` or `hardhat.config.ts`:
1919

2020
```js
21-
require("@tenderly/hardhat-tenderly");
21+
const tdly = require("@tenderly/hardhat-tenderly");
22+
tdly.setup();
2223
```
2324

2425
Or, if you are using typescript:
2526

2627
```ts
27-
import "@tenderly/hardhat-tenderly"
28+
import * as tdly from "@tenderly/hardhat-tenderly";
29+
tdly.setup();
2830
```
2931

30-
## Tasks
32+
# Verification options
3133

32-
This plugin adds the `tenderly:verify` task to Hardhat:
34+
## Automatic verification
3335

34-
```
35-
Usage: hardhat [GLOBAL OPTIONS] tenderly:verify ...contracts
36-
37-
POSITIONAL ARGUMENTS:
38-
39-
contracts Addresses and names of contracts that will be verified formatted ContractName=Address
40-
41-
tenderly-verify: Verifies contracts on Tenderly
42-
```
43-
44-
And the `tenderly:push` task:
45-
```
46-
Usage: hardhat [GLOBAL OPTIONS] tenderly:push ...contracts
47-
48-
POSITIONAL ARGUMENTS:
49-
50-
contracts Addresses and names of contracts that will be verified formatted ContractName=Address
51-
52-
tenderly-push: Privately pushes contracts to Tenderly
53-
```
54-
55-
## How to set up HardHat with Tenderly CLI
56-
57-
For Tenderly CLI to work you need to have a `deployments` directory inside your project. You can generate that
58-
one in next steps:
59-
60-
1. First install hardhat-tenderly.
61-
62-
```bash
63-
npm install --save-dev @tenderly/hardhat-tenderly
64-
```
65-
66-
2. Add the following statement to your `hardhat.config.js`:
67-
68-
```js
69-
require("@tenderly/hardhat-tenderly");
70-
```
36+
Contract verification works out-of-the box if contracts is deployed via ethers provided in HRE object.
7137

72-
Or, if you are using typescript:
38+
## Manual contract verification - Environment extensions
7339

74-
```js
75-
import "@tenderly/hardhat-tenderly"
76-
```
40+
This plugin extends the Hardhat Runtime Environment by adding a `tenderly` field
41+
whose type is `Tenderly`.
7742

78-
3. Then you need to call it from your scripts (using ethers to deploy a contract):
43+
This field has the `verify` and `push` methods, and you can use to trigger manual contract verification.
7944

80-
```js
45+
This is an example on how you can call it from your scripts (using ethers to deploy a contract):
46+
```ts
8147
const Greeter = await ethers.getContractFactory("Greeter");
8248
const greeter = await Greeter.deploy("Hello, Hardhat!");
8349

8450
await greeter.deployed()
8551

86-
await hre.tenderly.persistArtifacts({
52+
// public contract verification
53+
await hre.tenderly.verify({
8754
name: "Greeter",
8855
address: greeter.address,
8956
})
9057
```
9158

92-
`persistArtifacts` accept variadic parameters:
93-
94-
```js
59+
Both functions accept variadic parameters:
60+
```ts
9561
const contracts = [
96-
{
97-
name: "Greeter",
98-
address: "123"
99-
},
100-
{
101-
name: "Greeter2",
102-
address: "456"
103-
}
104-
]
62+
{
63+
name: "Greeter",
64+
address: "123"
65+
},
66+
{
67+
name: "Greeter2",
68+
address: "456"
69+
}]
10570

106-
await hre.tenderly.persistArtifacts(...contracts)
71+
// private contract verification
72+
await hre.tenderly.push(...contracts)
10773
```
10874

109-
4. Run: `npx hardhat compile` to compile contracts
110-
5. Run: `npx hardhat node --network hardhat` to start a local node
111-
6. Run: `npx hardhat run scripts/sample-script.js --network localhost` to run a script
112-
7. And at the end now when `deployments` directory was built you can run `tenderly init`
75+
## Manual contract verification - HRE Tasks
11376

114-
## Environment extensions
77+
This plugin adds the _`tenderly:verify`_ task to Hardhat:
78+
```
79+
Usage: hardhat [GLOBAL OPTIONS] tenderly:verify ...contracts
11580
116-
This plugin extends the Hardhat Runtime Environment by adding a `tenderly` field
117-
whose type is `Tenderly`.
81+
POSITIONAL ARGUMENTS:
11882
119-
This field has the `verify` and `push` methods.
83+
contracts Addresses and names of contracts that will be verified formatted ContractName=Address
12084
121-
This is an example on how you can call it from your scripts (using ethers to deploy a contract):
85+
tenderly-verify: Verifies contracts on Tenderly
86+
```
12287

123-
```js
124-
const Greeter = await ethers.getContractFactory("Greeter");
125-
const greeter = await Greeter.deploy("Hello, Hardhat!");
88+
And the `tenderly:push` task:
89+
```
90+
Usage: hardhat [GLOBAL OPTIONS] tenderly:push ...contracts
12691
127-
await greeter.deployed()
92+
POSITIONAL ARGUMENTS:
12893
129-
await hre.tenderly.persistArtifacts({
130-
name: "Greeter",
131-
address: greeter.address,
132-
})
94+
contracts Addresses and names of contracts that will be verified formatted ContractName=Address
13395
134-
await hre.tenderly.verify({
135-
name: "Greeter",
136-
address: greeter.address,
137-
})
96+
tenderly-push: Privately pushes contracts to Tenderly
13897
```
13998

140-
Both functions accept variadic parameters:
99+
## Manual contract verification - Source & compiler config manually provided
141100

142-
```js
143-
const contracts = [
144-
{
145-
name: "Greeter",
146-
address: "123"
147-
},
148-
{
149-
name: "Greeter2",
150-
address: "456"
151-
}]
101+
In order to offer the most flexibility we have exposed our internal API interface in the plugin interface.
152102

153-
await hre.tenderly.verify(...contracts)
103+
There are `verifyAPI` and `pushAPI` functions with all necessary data for verification.
104+
105+
Here is the types example that are needed in order for verification to be successful.
106+
```typescript
107+
export interface TenderlyContractConfig {
108+
compiler_version?: string;
109+
optimizations_used?: boolean;
110+
optimizations_count?: number;
111+
evm_version?: string;
112+
debug?: CompilerDebugInput;
113+
}
114+
115+
export interface TenderlyContract {
116+
contractName: string;
117+
source: string;
118+
sourcePath: string;
119+
compiler?: ContractCompiler;
120+
networks?: Record<string, ContractNetwork>;
121+
}
122+
123+
export interface TenderlyContractUploadRequest {
124+
config: TenderlyContractConfig;
125+
contracts: TenderlyContract[];
126+
tag?: string;
127+
}
128+
129+
public async verifyAPI(request: TenderlyContractUploadRequest)
154130
```
155131

156132
## Configuration
157133

158-
This plugin extends the `HardhatConfig` object with optional
159-
`project` and `username` fields.
134+
This plugin extends the `HardhatConfig` object with
135+
`project`, `username`, `forkNetwork` and `privateVerification` fields.
160136

161137
This is an example of how to set it:
162138

@@ -165,15 +141,17 @@ module.exports = {
165141
tenderly: {
166142
project: "",
167143
username: "",
144+
forkNetwork: "",
145+
// privateVerification: false,
146+
// deploymentsDir: "deployments"
168147
}
169148
};
170149
```
171150

172151
## Usage
173152

174-
For this plugin to function you need to create a `config.yaml` file at
153+
For this plugin to function you need to create a `config.yaml` file at
175154
`$HOME/.tenderly/config.yaml` or `%HOMEPATH%\.tenderly\config.yaml` and add an `access_key` field to it:
176-
177155
```yaml
178156
access_key: super_secret_access_key
179157
```

0 commit comments

Comments
 (0)