Skip to content

Commit

Permalink
Update contract verification page for etherscan and mainnet (#123)
Browse files Browse the repository at this point in the history
* update foundry verification for etherscan and mainnet

* update hardhat instructions

* fix: nits

---------

Co-authored-by: isabelle <[email protected]>
Co-authored-by: Daniel Helm <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent e0b08d1 commit a2fbe8c
Showing 1 changed file with 49 additions and 18 deletions.
67 changes: 49 additions & 18 deletions src/content/docs/en/developers/verifying-smart-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,34 @@ title: "Verifying Smart Contracts"
lang: "en"
permalink: "developers/verifying-smart-contracts"
whatsnext: { "Scroll Contracts": "/developers/scroll-contracts" }
excerpt: "Easily verify your smart contracts with Scroll-supported developer tooling or the Blockscout Web API"
excerpt: "Easily verify your smart contracts with Scroll-supported developer tooling"
---

import Aside from "../../../../components/Aside.astro"
import ClickToZoom from "../../../../components/ClickToZoom.astro"
import verify1 from "./_images/verify1.png"
import CodeSample from "../../../../components/CodeSample/CodeSample.astro"

After deploying your smart contracts, it's important to verify your code on [our block explorer](https://scrollscan.com/) or the [Sepolia block explorer](https://sepolia-blockscout.scroll.io).
After deploying your smart contracts, it's important to verify your code on a block explorer. This can be done in an automated way using your developer tooling or the Web UI.

This can be done in an automated way using your developer tooling or using Blockscout's Web UI.
## Using Developer Tools

<Aside type="tip" title="Blockscout vs Etherscan">
The below instructions for verifying on our Sepolia Blockscout instance will need to be altered to work with Etherscan
deployments. As additional services come online for mainnet, we'll update these instructions.
</Aside>
Most smart contract tooling has plugins for verifying your contracts easily on Etherscan. Blockscout supports Etherscan's contract verification APIs, so it's straightforward to use these tools using the APIs of either of these block explorers.

## Using Developer Tools
| Network | Scroll | Scroll Sepolia |
| ---------- | -------------------------------- | ---------------------------------------- |
| Scrollscan | https://api.scrollscan.com/api | https://api-sepolia.scrollscan.com/api |
| Blockscout | https://blockscout.scroll.io/api | https://sepolia-blockscout.scroll.io/api |

Most smart contract tooling has plugins for verifying your contracts easily on Etherscan. Blockscout supports Etherscan's contract verification APIs, and it's straightforward to use these tools with the Scroll Sepolia Testnet.
<Aside type="tip" title="Using the Scrollscan API">
When using Scrollscan, you will need to [register an account](https://scrollscan.com/register) and create an API key. The same key can be used for both Scroll Sepolia and mainnet. After creating your API key, please wait a few minutes before it comes into effect.
</Aside>

### Hardhat

First, modify `hardhat.config.ts` to point to Scroll's RPC and `sepolia-blockscout.scroll.io/api`. A dummy `apiKey` value is required, but anything works for its value.
Modify `hardhat.config.ts` to point to Scroll's RPC and block explorer API. For Blockscout, a dummy `apiKey` value is required, but anything works for its value. For Scrollscan, use your own API key.

For example, if you are using Scroll Sepolia on Blockscout, your config will look like this:
```javascript
...

Expand Down Expand Up @@ -82,18 +85,46 @@ npx hardhat verify --network scrollSepolia 0xD9880690bd717189cC3Fbe7B9020F27fae7

### Foundry

<Aside type="danger" title="Warning">
Our Blockscout instance currently has inconsistent behavior in verifying contracts with Foundry. We're working on a
fix, along with other stability improvements. Don't hesitate to come ask for help [on
Discord](https://discord.com/channels/853955156100907018/1028102371894624337) though.
When using Foundry, the `verify-contract` command helps automate the process of verifying contracts. If your contract has constructor arguments, you can specify these in ABI-encoded form with the `--constructor-args` option. For example, if your constructor takes two `uint256` variables:
```bash
--constructor-args $(cast abi-encode "constructor(uint256,uint256)" 0 7)
```

Refer to the [Foundry documentation](https://book.getfoundry.sh/reference/forge/forge-verify-contract) for further options you can specify.


#### Scrollscan

```bash
forge verify-contract <contract address> <contract name> \
--verifier-url https://api-sepolia.scrollscan.com/api \
--etherscan-api-key <your Scrollscan API key> \
--constructor-args <your constructor arguments>
```
<Aside type="caution" title="Caution">
Do not specify the chain ID.
</Aside>

When using Foundry, the `verify-contract` helps automate the process of verifying contracts.
#### Blockscout

Specify the verification provider as `blockscout`.

##### Scroll
```bash
forge verify-contract <Contract Address> <Space separated params> <Solidity file>:<Contract name> --chain-id 534351 --verifier-url https://sepolia-blockscout.scroll.io/api\? --verifier blockscout
forge verify-contract <contract address> <contract name> \
--verifier-url https://blockscout.scroll.io/api\? \
--verifier blockscout \
--constructor-args <your constructor arguments>
```

##### Scroll Sepolia
```bash
forge verify-contract <contract address> <contract name> \
--verifier-url https://sepolia-blockscout.scroll.io/api\? \
--verifier blockscout \
--constructor-args <your constructor arguments>
```

<Aside type="danger" title="Warning">
Notice we add `\?` at the end of the verifier URL or otherwise verification would fail. (Last tested on forge v0.2.0).
</Aside>
Notice we add `\?` at the end of the verifier URL otherwise verification would fail. (Last tested on forge v0.2.0).
</Aside>

0 comments on commit a2fbe8c

Please sign in to comment.