-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Sourcify docs from otterscan repo (#3)
* Import Sourcify contents from otterscan README * Split sourcify docs into proper sections
- Loading branch information
Showing
11 changed files
with
211 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Alternative Sourcify sources | ||
|
||
Rather than using the default `ipfs.io` and `repo.sourcify.dev` sites for accessing Sourcify, you may specify your own Sourcify root URLs in the configuration file by adding the `sourcifySources` key and changing the URLs accordingly: | ||
|
||
```json | ||
"sourcifySources": { | ||
"ipfs": "https://ipfs.io/ipns/repo.sourcify.dev", | ||
"central_server": "https://repo.sourcify.dev" | ||
} | ||
``` | ||
|
||
This is useful if you have your own Sourcify repository hosted locally, in which case all of your Otterscan activity will be private. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Contract verification | ||
|
||
In this chapter we explain how contract verification works in Otterscan. | ||
|
||
> 💡 If you are not interested in how contract verification works under the hood, you can skip this chapter. | ||
We use Sourcify and the next section explains how the integration works. | ||
|
||
- [Sourcify](./sourcify/) | ||
|
||
In case you want to run Sourcify against a devnet or a custom chain not enabled in Sourcify's official hosted service, you can run your own instance of Sourcify and point Otterscan to it. | ||
|
||
- [Self-hosted Sourcify](./self-hosted-sourcify/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Self-hosted Sourcify | ||
|
||
This section presents a short guide to self-host a local Sourcify instance. | ||
|
||
Set up a local Sourcify instance. | ||
|
||
- [Set up local Sourcify](./setup.md) | ||
|
||
Verify a contract on a Sourcify instance. | ||
|
||
- [Verify](./verification.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Setup | ||
|
||
## Run a local Sourcify instance on your dev network | ||
|
||
### Launch a local chain | ||
|
||
Launch an Otterscan-compatible local Ethereum RPC node hosting your development server. | ||
|
||
- Erigon: | ||
- `./erigon --chain=dev --datadir=dev --http.api eth,erigon,trace,ots,ots2 --http.corsdomain "*" --http.vhosts "*" --mine --fakepow` | ||
- Note: The Erigon devnet only supports a pre-Shanghai (pre-Merge) version of Ethereum. When compiling your contracts, you'll have to set the `evmTarget` to `london` for them to run at all on the devnet. | ||
- You'll have to create a full-fledged Ethereum test network in Erigon if you want to run a modern version of the EVM. | ||
- Foundry's [Anvil](https://book.getfoundry.sh/reference/anvil/): | ||
- `anvil` | ||
- Note: Anvil does not support ots2 RPC methods, so make sure `experimental` is set to `false` in your Otterscan config. | ||
|
||
### Sourcify | ||
|
||
1. Clone the Sourcify repository: | ||
|
||
```shell | ||
git clone https://github.com/ethereum/sourcify.git | ||
``` | ||
|
||
2. To add support for your local blockchain, create a JSON file `services/server/src/sourcify-chains.json`: | ||
|
||
```json | ||
{ | ||
"1337": { | ||
"sourcifyName": "Local chain", | ||
"supported": true, | ||
"rpc": [ | ||
"http://localhost:8545" | ||
] | ||
} | ||
} | ||
``` | ||
|
||
You can adjust the chain ID `1337` and the RPC host `http://localhost:8545` as needed. The default chain ID for the Erigon devnet is 1337, and the default for Anvil is 31337. | ||
|
||
3. Adjust the repository URL in `ui/.env.development` since for simplicity we aren't using Sourcify's h5ai-nginx file viewer: | ||
|
||
```shell | ||
REACT_APP_REPOSITORY_SERVER_URL=http://localhost:5555/repository | ||
``` | ||
|
||
4. Build all necessary Sourcify components, notably the server and the UI: | ||
|
||
```shell | ||
npm run build:clean | ||
``` | ||
|
||
5. Start the Sourcify server: | ||
|
||
```shell | ||
NODE_ENV=development npm run server:start | ||
``` | ||
|
||
6. Start the Sourcify UI: | ||
|
||
```shell | ||
npm run ui:start | ||
``` | ||
|
||
### Otterscan configuration | ||
|
||
To use the local Sourcify instance, you need to point to it in Otterscan's configuration file. | ||
In your Otterscan configuration JSON, specify your local Sourcify repository as the Sourcify source: | ||
|
||
```json | ||
"sourcifySources": { | ||
"ipfs": "http://localhost:5555/repository", | ||
"central_server": "http://localhost:5555/repository" | ||
} | ||
``` |
27 changes: 27 additions & 0 deletions
27
src/contract-verification/self-hosted-sourcify/verification.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Verification | ||
|
||
## Verifying through the Sourcify UI | ||
|
||
You can verify contracts using the Sourcify UI by going to <http://localhost:3000/#/verifier> in your browser. | ||
|
||
## Verifying with Forge | ||
|
||
1. If you deploy using a [Forge script](https://book.getfoundry.sh/reference/forge/forge-script), you should add the following contract verification arguments to the command: | ||
|
||
```shell | ||
forge script Deploy.s.sol .... --verify --verifier sourcify --verifier-url http://localhost:5555 | ||
``` | ||
|
||
2. If you want to deploy a contract without a script, you can use `forge create` to create the deployment transaction. Create a folder named `contracts` and put your contract files in there. | ||
|
||
Here is how you would deploy a smart contract called `MyContract` with constructor arguments `0x67b1d87101671b127f5f8714789C7192f7ad340e` and `123456`: | ||
|
||
```shell | ||
./forge create --verify --verifier sourcify --verifier-url http://localhost:5555/ --interactive --optimize --rpc-url http://localhost:8545/ MyContract --constructor-args 0x67b1d87101671b127f5f8714789C7192f7ad340e 123456 | ||
``` | ||
|
||
3. To verify a contract that already has been deployed, you can use `forge verify-contract`. Here is an example of a verification of the above `MyContract` contract example to address `0xADC11306fcD68F47698D66047d923a52816Ee44F`. Forge can usually infer constructor arguments automatically: | ||
|
||
```shell | ||
./forge verify-contract --verifier sourcify --verifier-url http://localhost:5555/ --optimizer-runs 200 --rpc-url http://localhost:8545/ 0xADC11306fcD68F47698D66047d923a52816Ee44F MyContract | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Sourcify | ||
|
||
Otterscan consumes verified smart contract source code and metadata from [Sourcify](https://sourcify.dev/). | ||
|
||
> Sourcify is open source, their data is public and they host a public instance of the verifier. | ||
Otterscan supports multiple ways to consume verified contract data. | ||
|
||
- [Integration modes](./integration-modes.md) | ||
|
||
To learn how to verify a smart contract on Sourcify, take a look at the Sourcify docs: | ||
|
||
- [How to verify contracts on Sourcify](https://docs.sourcify.dev/docs/how-to-verify/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Integration modes | ||
|
||
Otterscan supports multiple ways to consume Sourcify data, each one with pros and cons: | ||
|
||
## Direct HTTP connection to Sourcify's repository | ||
|
||
Standard HTTP connection to the official Sourcify repository at <https://repo.sourcify.dev/> | ||
|
||
Fast access to freshly verified data. On the other hand, it is centralized and leaks all addresses you visit in Otterscan to the Sourcify server. | ||
|
||
> 💡 This is the default method Otterscan uses out of the box. | ||
## IPFS | ||
|
||
We resolve the public Sourcify IPNS to get the latest known IPFS root hash of their repository. | ||
|
||
The downside is that recently verified contracts may not have been added yet to the root hash and republished into IPNS. | ||
|
||
It uses the public gateway at <https://ipfs.io> by default. | ||
|
||
Please see our [ipfs integration docs](./ipfs.md) for more info about how we handle all IPFS integrations and privacy concerns. | ||
|
||
## Local snapshot *(deprecated; soon to be removed)* | ||
|
||
> ☠️ This method is deprecated and will be removed in the future. The repository is outdated and kept only for historical reasons. | ||
As a midterm solution, we are making available a snapshot docker image of their repository, containing only mainnet full verified contracts. | ||
|
||
This would allow you to play with existing contracts up to the snapshot date/time locally, not depending on their service or IPFS connectivity availability. | ||
|
||
The Sourcify snapshot is provided as a nginx image at: <https://hub.docker.com/repository/docker/otterscan/sourcify-snapshot> | ||
|
||
You can run it with: | ||
|
||
```shell | ||
docker run --rm -d -p 3006:80 --name sourcify-snapshot otterscan/sourcify-snapshot:2021-09 | ||
``` | ||
|
||
Stop it with: | ||
|
||
``` | ||
docker stop sourcify-snapshot | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Contract Verification | ||
|
||
We display verified contracts using information from [Sourcify](https://sourcify.dev/). | ||
|
||
For more details on how the integration works, please check the [Contract verification](../contract-verification/) chapter. |
This file was deleted.
Oops, something went wrong.