@@ -15,148 +15,124 @@ privately push contracts to [Tenderly](https://tenderly.co).
15
15
npm install --save-dev @tenderly/hardhat-tenderly
16
16
```
17
17
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 ` :
19
19
20
20
``` js
21
- require (" @tenderly/hardhat-tenderly" );
21
+ const tdly = require (" @tenderly/hardhat-tenderly" );
22
+ tdly .setup ();
22
23
```
23
24
24
25
Or, if you are using typescript:
25
26
26
27
``` ts
27
- import " @tenderly/hardhat-tenderly"
28
+ import * as tdly from " @tenderly/hardhat-tenderly" ;
29
+ tdly .setup ();
28
30
```
29
31
30
- ## Tasks
32
+ # Verification options
31
33
32
- This plugin adds the ` tenderly:verify ` task to Hardhat:
34
+ ## Automatic verification
33
35
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.
71
37
72
- Or, if you are using typescript:
38
+ ## Manual contract verification - Environment extensions
73
39
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 ` .
77
42
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.
79
44
80
- ``` js
45
+ This is an example on how you can call it from your scripts (using ethers to deploy a contract):
46
+ ``` ts
81
47
const Greeter = await ethers .getContractFactory (" Greeter" );
82
48
const greeter = await Greeter .deploy (" Hello, Hardhat!" );
83
49
84
50
await greeter .deployed ()
85
51
86
- await hre .tenderly .persistArtifacts ({
52
+ // public contract verification
53
+ await hre .tenderly .verify ({
87
54
name: " Greeter" ,
88
55
address: greeter .address ,
89
56
})
90
57
```
91
58
92
- ` persistArtifacts ` accept variadic parameters:
93
-
94
- ``` js
59
+ Both functions accept variadic parameters:
60
+ ``` ts
95
61
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
+ }]
105
70
106
- await hre .tenderly .persistArtifacts (... contracts)
71
+ // private contract verification
72
+ await hre .tenderly .push (... contracts )
107
73
```
108
74
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
113
76
114
- ## Environment extensions
77
+ This plugin adds the _ ` tenderly:verify ` _ task to Hardhat:
78
+ ```
79
+ Usage: hardhat [GLOBAL OPTIONS] tenderly:verify ...contracts
115
80
116
- This plugin extends the Hardhat Runtime Environment by adding a ` tenderly ` field
117
- whose type is ` Tenderly ` .
81
+ POSITIONAL ARGUMENTS:
118
82
119
- This field has the ` verify ` and ` push ` methods.
83
+ contracts Addresses and names of contracts that will be verified formatted ContractName=Address
120
84
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
+ ```
122
87
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
126
91
127
- await greeter . deployed ()
92
+ POSITIONAL ARGUMENTS:
128
93
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
133
95
134
- await hre .tenderly .verify ({
135
- name: " Greeter" ,
136
- address: greeter .address ,
137
- })
96
+ tenderly-push: Privately pushes contracts to Tenderly
138
97
```
139
98
140
- Both functions accept variadic parameters:
99
+ ## Manual contract verification - Source & compiler config manually provided
141
100
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.
152
102
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 )
154
130
```
155
131
156
132
## Configuration
157
133
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.
160
136
161
137
This is an example of how to set it:
162
138
@@ -165,15 +141,17 @@ module.exports = {
165
141
tenderly: {
166
142
project: " " ,
167
143
username: " " ,
144
+ forkNetwork: " " ,
145
+ // privateVerification: false,
146
+ // deploymentsDir: "deployments"
168
147
}
169
148
};
170
149
```
171
150
172
151
## Usage
173
152
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
175
154
` $HOME/.tenderly/config.yaml ` or ` %HOMEPATH%\.tenderly\config.yaml ` and add an ` access_key ` field to it:
176
-
177
155
``` yaml
178
156
access_key : super_secret_access_key
179
157
` ` `
0 commit comments