You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<AvailableOnlyForSolidityAdmonitiondescription="Vyper contracts are verifiable only using the dedicated /verify/vyper API enpoint. UI, frameworks and tools don't support Vyper verification via Sourcify yet."/>
15
+
There are multiple ways to verify a contract on Sourcify. Depending on your use case, you can choose the best way.
12
16
13
-
## Using the UI (legacy)
17
+
Some of these methods are using the legacy Sourcify API. This will be deprecated in the near future. Use Sourcify APIv2 instead (see [APIv2 docs](/docs/api)).
14
18
15
-
1. Drag and drop the folder containing your source files and metadata, or add them seperately.
16
-
2. Input the contract address you want to verify.
17
-
3. Select the chain the contract is deployed to.
18
-
4. Click "Verify".
19
+
With APIv2 when you submit a verification, this will create a verification job. You can then check the status of the job and get the verification result. See one example in the UI [here](https://verify.sourcify.dev/jobs/f4ed8a9b-c852-4ac6-ac99-bd71ffb01305).
You can verify using our new verification UI at https://verify.sourcify.dev. See the Github repo [here](https://github.com/sourcifyeth/verify.sourcify.dev).
24
+
25
+
First choose the chain you want to verify the contract on and provide the contract address.
<imgsrc={chainAddress}alt="Chain and address"style={{width: "100%", maxWidth: "600px"}} />
28
+
</div>
29
+
30
+
This will automatically check if the contract is verified on Sourcify on the same chain and all other supported chains.
31
+
32
+
### Importing a contract
33
+
34
+
You can import a verified contract from different sources:
35
+
36
+
-**Etherscan**: Enter the chain and contract address to import the contract. You need an Etherscan API key to use this feature. Open the "Settings" on top right to add your API key. API keys are used locally in the browser and are not sent to Sourcify servers.
For both Solidity and Vyper contracts you can choose between the following verification methods:
44
+
45
+
-**Single file**: Provide single .sol or .vy file, alongside compiler settings.
46
+
-**Multiple files**: Provide multiple .sol or .vy files, alongside compiler settings.
47
+
- (preferred) **Standard JSON**: Provide a [standard JSON input file](https://docs.soliditylang.org/en/v0.8.30/using-the-compiler.html#input-description).
48
+
49
+
Prefer using the standard JSON or framework commands directly (see below) to maintain the full compilation and avoid any changes. Different compiler settings can break the verification. Flattening the sources also breaks the metadata hashes and you won't be able to get an ["Exact Match"](/docs/exact-match-vs-match).
50
+
51
+
Additionally the following option is available for Solidity contracts:
52
+
-**Metadata.json**: Provide a [metadata.json file](/docs/metadata) to verify the contract in the first file input field. Provide all the source files in the second file input field. This option checks the source hashes in the metadata.json provided and compares them with the hashes of the source files provided before submitting the verification.
Foundry natively supports Sourcify verification. You can verify contracts with the additional verify flags in Forge:
59
+
### Contract Identifier
29
60
30
-
Deploy and verifya contract:
61
+
From the files and contracts provided, we will ask you to select the contract you want to verify. Ie. if you've written a contract called `MyContract.sol` using other contracts `Ownable.sol` and `ERC20.sol`, you will be asked to select `MyContract.sol` as the contract to verify.
31
62
63
+
The format of the contract identifier is path:contractName e.g.
32
64
```
65
+
path/to/contractName.sol:contractName
66
+
```
67
+
68
+
The verification UI will parse the files and give you a list of contracts to choose from. You can always input the contract identifier manually.
69
+
70
+
### (Optional) Creation Transaction Hash
71
+
72
+
Sourcify needs to find the transaction the contract was deployed in to get the creation bytecode. We get this information from different sources like block explorers (see [here](https://github.com/ethereum/sourcify/blob/staging/services/server/src/sourcify-chains-default.json)). You can still provide a creation transaction hash manually if you want to, or if Sourcify fails to verify via creation bytecode.
73
+
74
+
## Verification Job
75
+
76
+
Once you've provided all the information, you can submit the verification. This will create a verification job. You can see the job in the UI and get the verification result.
77
+
78
+
If the verification fails you can see the error message and why it failed.
The Hardhat plugin [@nomicfoundation/hardhat-verify](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#verifying-on-sourcify) has official Sourcify support.
126
+
The Hardhat plugin [@nomicfoundation/hardhat-verify](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#verifying-on-sourcify) has official Sourcify support.
127
+
128
+
(This is still using the legacy Sourcify API)
65
129
66
130
In order to enable Sourcify support, add this to `hardhat.config.js`:
67
131
68
-
```
132
+
```js title="hardhat.config.js"
69
133
sourcify: {
70
134
enabled:true,
71
135
// Optional: specify a different Sourcify server
@@ -77,80 +141,30 @@ sourcify: {
77
141
78
142
After deploying your contracts you can verify on Sourcify with:
Sourcify can parse the Hardhat `.json` output file under `artifacts/build-info` to verify contracts.
87
-
88
-
:::info
89
-
Only after Hardhat version v2.6.8 the metadata files were output by default. If you are using an earlier version, you need to add the metadata to compilation outputs manually as [described here](/docs/metadata/#hardhat---earlier-than-v268)
90
-
:::
91
-
92
-
1. Drag and drop the `.json` file at [sourcify.dev](https://sourcify.dev).
93
-
2. Select the main contract deployed at the address you want to verify.
94
-
3. Input the address and chain and click "Verify".
If you were using Truffle to compile contracts, you can use the output file at `build/contracts/<contract-name>.json` for the metadata file. Then add the source files as usual.
105
-
106
-
### truffle-verify-plugin
107
-
108
-
If you've deployed your contracts with Truffle, you can use the [truffle-plugin-verify](https://github.com/rkalis/truffle-plugin-verify) to verify contracts on Sourcify. The plugin verifies on Sourcify by default.
109
-
110
-
```bash
111
-
$ truffle run verify MyFirstContract MySecondContract --network goerli
112
-
```
113
-
114
-
## Remix Plugin
115
-
116
-
Remix has a plugin to aid with contract verification and lookup.
117
-
Please click this link to activate the plugin in Remix: [https://remix.ethereum.org/?#activate=contract-verification](https://remix.ethereum.org/?#activate=contract-verification)
118
-
119
-
### Verifying
148
+
## Remix
120
149
121
-
To verify:
150
+
You can use the "unified verification plugin" written by the Sourcify team to verify on multiple verifiers on Remix.
122
151
123
-
1.Select the contract you want to verify in the file explorer
124
-
2.Compile the contract
125
-
3. Click on the Contract Verification icon on the left sidebar
126
-
4. Enter the chain and the address of the contract you want to verify
127
-
5. Select the contract you just compiled
128
-
6. Make sure Sourcify is selected
129
-
7. Click on Verify
152
+
1.Click on the "Plugins" tab in bottom of the sidebar and search for "Contract Verification"
153
+
2.Enable the plugin "Contract Verification"
154
+
3. Click on the "Contract Verification" tab in the sidebar
155
+
5. Enter the contract address and select a chain
156
+
6. Select the contract to verify (you need to have compiled a contract on Remix first)
157
+
7. By default all verifiers are enabled. For Etherscan you need to add your API key in the "Settings" tab
158
+
8. You can see the verification result in the "Receipts" tab
0 commit comments