Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cli/verify): initial version #2744

Merged
merged 18 commits into from
Apr 27, 2024
1 change: 1 addition & 0 deletions docs/pages/cli/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
worldgen: "mud worldgen",
test: "mud test",
deploy: "mud deploy",
verify: "mud verify",
"dev-contracts": "mud dev-contracts",
"abi-ts": "mud abi-ts",
faucet: "mud faucet",
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/cli/deploy.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Callout } from "nextra/components";

# mud deploy

This command deploys a MUD app to a blockchain.
Expand Down Expand Up @@ -52,6 +54,12 @@ These are the command line options you can specify on `mud deploy`:

(1) The hostname `localhost` may not work. If that is the case, use `127.0.0.1` instead.

<Callout type="info" emoji="ℹ️">
If you want to [verify](./verify) the contracts that make up the `World`, do it right after deployment. Verification
only works with the original source code, compiler options, and compiled artifacts. Otherwise, the generated bytecode
is different and therefore verification fails.
</Callout>

## Examples

### New `World`
Expand Down
54 changes: 54 additions & 0 deletions docs/pages/cli/verify.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# mud verify

This command uploads the source code for the deployed contracts to a public repository, such as a block explorer.
The repository then compiles the source code and verifies that the compiled version is identical to what is deployed onchain.

The best time to perform verification is immediately after [deployment](./deploy).
Verification only works with the original source code, compiler options, and compiled artifacts.
Otherwise, the generated bytecode is different and therefore verification fails.

## Using the command

1. If using Blockscout, you need to specify the API key:

```sh copy
export ETHERSCAN_API_KEY=<value goes here>
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually think blockscout doesn't require an api key (but it might be that forge expects something to be provided as an an api key)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no blockscout API key afaik, only need to provide an etherscan API key if you use --verifier etherscan or no --verifier (forge defaults to etherscan)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We (@yonadaaa and me) decided not to document Etherscan verification at this time because neither of us managed to get it working.

  2. If I understand https://docs.blockscout.com/for-users/api#api-keys correctly, it means that Blockscout will serve up to 50 calls without a key every second. Yours may or may not be one of them. But with an API key you get 10 calls a second for yourself.


1. Run the command.
qbzzt marked this conversation as resolved.
Show resolved Hide resolved

```sh copy
pnpm mud verify --worldAddress <address here> --verifier <verifier> --rpc <RPC to the blockchain>
```

These are the command line options you can specify on `mud verify`:

| Option | Meaning | Type | Default value |
| ---------------- | ------------------------------------------------------ | ------- | ---------------------------- |
| `--worldAddress` | Verify the contracts of the World at the given address | string | none, error if unspecified |
| `--configPath` | Path to the config file | string | `mud.config.ts` |
| `--verifier` | The verifier to use (`sourcify`, or `blockscout`) | string | |
yonadaa marked this conversation as resolved.
Show resolved Hide resolved
| `--verifierUrl` | URL to use to access the verifier's API | string | depends on the verifier used |
| `--profile` | The foundry profile to use | string | `local` |
| `--srcDir` | Source directory | string | Foundry `src` directory |
| `--version` | Show version number | boolean | `false` |

Note that it takes block explorers some time to process new contracts.
You should wait 5-10 minutes past deployment before you verify the contract on Etherscan and/or Blockscout.

## Examples

- To verify the world at that address on Holesky on [sourcify](https://sourcify.dev/):

```sh
WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2
pnpm mud verify --rpc https://ethereum-holesky.publicnode.com --worldAddress $WORLD_ADDRESS --verifier sourcify
```

- To verify on Holesky on [Blockscout](https://www.blockscout.com/):
qbzzt marked this conversation as resolved.
Show resolved Hide resolved

```sh
WORLD_ADDRESS=0x816038e244ff78b86a5e7dec9bf281634fb6d2a2
export ETHERSCAN_API_KEY= ** blockscout API key goes here **
pnpm mud verify --rpc https://ethereum-holesky.publicnode.com --worldAddress $WORLD_ADDRESS --verifier blockscout --verifier-url 'https://eth-holesky.blockscout.com/api?'
```
Loading