Skip to content

Restructure smart contract verification documentation #2409

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
374 changes: 190 additions & 184 deletions SUMMARY.md

Large diffs are not rendered by default.

38 changes: 15 additions & 23 deletions smart-contracts/developing-contracts/foundry.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ The template repository contains submodules and remappings for ds-test assertion

You must have the following installed:

* [Git](https://git-scm.com/)
* [Yarn](https://yarnpkg.com/)
- [Git](https://git-scm.com/)
- [Yarn](https://yarnpkg.com/)

You should also have an address on the Filecoin Calibration testnet. See the [MetaMask setup page](../../basics/assets/metamask-setup.md) for information on how to get an address. You also need test `tFIL` in your wallet.

## Steps

1. Clone the `xBalbinus/fevm-foundry-kit` repository and move into the `fevm-foundry-kit` directory:
1. Clone the `filecoin-project/fevm-foundry-kit` repository and move into the `fevm-foundry-kit` directory:

```
git clone https://github.com/xBalbinus/fevm-foundry-kit/tree/main.git
git clone https://github.com/filecoin-project/fevm-foundry-kit/tree/main.git
cd fevm-foundry-kit
```

Expand All @@ -34,37 +34,29 @@ yarn install
```

3. Export your private key from MetaMask. See the [MetaMask documentation](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key) to find out how to export your private key.
4. In your `.env.example`, create an environment variable called `PRIVATE_KEY` and paste in the private key from MetaMask. Also, do the same for the `HYPERSPACE_RPC_URL`. Then rename the file to `.env`:

4. Create your env file by running

```
PRIVATE_KEY=eed8e9d727a647f7302bab440d405ea87d36726e7d9f233ab3ff88036cfbce9c
HYPERSPACE_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
cp .env.example .env
```

5. Inside the `src` folder in a contract called `SimpleCoin.sol`. Deploy this contract using Foundry:

```shell
forge build
forge script script/SimpleCoin.s.sol:MyScript --rpc-url https://api.calibration.node.glif.io/rpc/v1 --broadcast --verify -vvvv
5. In your newly created`.env` replace `PRIVATE_KEY` with the one gathered from MetaMask. Also, do the same for the `CALIBRATIONNET_RPC_URL`.:

# ...
#
# Script ran successfully.
# Gas used: 234642
```bash
PRIVATE_KEY=eed8e9d727a647f7302bab440d405ea87d36726e7d9f233ab3ff88036cfbce9c
CALIBRATIONNET_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
```

6. Alternatively, you can do the same using the `forge create` command:
6. Inside the `src` folder in a contract called `SimpleCoin.sol`. Deploy this contract using Foundry:

```
```shell
forge build

forge create --rpc-url https://api.calibration.node.glif.io/rpc/v1 --private-key $PRIVATE_KEY src/SimpleCoin.sol:SimpleCoin
forge create --rpc-url https://api.calibration.node.glif.io/rpc/v1 --private-key $PRIVATE_KEY src/SimpleCoin.sol:SimpleCoin --broadcast
```

7. You can now interact with your contract using the contract address given by Foundry.

Done! For more information, see the [Foundry book](https://book.getfoundry.sh/).



[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill\_Page+URL=https://docs.filecoin.io/smart-contracts/developing-contracts/foundry)
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/smart-contracts/developing-contracts/foundry)
79 changes: 0 additions & 79 deletions smart-contracts/developing-contracts/verify-a-contract.md

This file was deleted.

39 changes: 39 additions & 0 deletions smart-contracts/developing-contracts/verify-a-contract/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
description: >-
This section provides comprehensive guides for verifying smart contracts
on the Filecoin network using various tools and methods.
---

# Contract Verification

Contract verification is essential for transparency and trust in the Filecoin ecosystem. It allows users to inspect the source code of deployed contracts and ensures they function as intended.

## Available Verification Tools

The following FEVM-compatible chain explorers offer contract verification capabilities:

- [Blockscout](https://filecoin.blockscout.com/contract-verification) - Multi-chain explorer with advanced verification options
- [Filfox](https://filfox.info/en/contract) - Native Filecoin explorer with comprehensive verification features
- [Starboard](https://fvm.starboard.ventures/explorer/verifier) - FVM-focused verification platform
- [Beryx](https://beryx.zondax.ch/contract_verifier) - Developer-friendly verification interface
- [Sourcify](https://docs.sourcify.dev/docs/how-to-verify/) - Multi-chain contract repository with verification tools

## Verification Methods

There are two primary approaches to verify your smart contracts:

### Programmatic Verification

Automate contract verification directly from your development environment:

- [Hardhat verification guide](/smart-contracts/developing-contracts/verify-a-contract/programmatic/hardhat.md)
- [Foundry verification guide](/smart-contracts/developing-contracts/verify-a-contract/programmatic/foundry.md)

### Web Interface Verification

Verify contracts through explorer user interfaces:

- [Blockscout web interface guide](/smart-contracts/developing-contracts/verify-a-contract/web-interface/blockscout.md)
- [Filfox web interface guide](/smart-contracts/developing-contracts/verify-a-contract/web-interface/filfox.md)

[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/smart-contracts/developing-contracts/verify-a-contract)
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
description: >-
Learn how to verify smart contracts on the Filecoin network using Foundry
with various verification services including Blockscout, Sourcify, and Filfox.
---

# Contract Verification with Foundry

This guide shows you how to verify your smart contracts using Foundry on the Filecoin network.

## Prerequisites

- A Foundry project set up for Filecoin development
- If you don't have a Foundry project, check out the [FEVM Foundry Kit](/smart-contracts/developing-contracts/foundry.md)
- A deployed contract address
- Contract constructor arguments (if any)

## Verification Methods

### Blockscout Verification

Blockscout is a popular blockchain explorer that supports contract verification.

**Verify on Calibration Testnet:**

```bash
forge verify-contract \
--verifier blockscout \
--verifier-url 'https://filecoin-testnet.blockscout.com/api/' \
--force \
--skip-is-verified-check \
0xYourContractAddress \
src/MyContract.sol:MyContract
```

**Verify on Filecoin Mainnet:**

```bash
forge verify-contract \
--verifier blockscout \
--verifier-url 'https://filecoin.blockscout.com/api/' \
--force \
--skip-is-verified-check \
0xYourContractAddress \
src/MyContract.sol:MyContract
```

### Sourcify Verification

Sourceify provides decentralized contract verification.

**Verify on Filecoin Mainnet:**

```bash
forge verify-contract 0xYourContractAddress \
src/MyToken.sol:MyToken \
--chain-id 314 \
--verifier sourcify \
--verifier-url https://sourcify.dev/server/ \
--guess-constructor-args
```

**Verify on Calibration Testnet:**

```bash
forge verify-contract 0xYourContractAddress \
src/MyToken.sol:MyToken \
--chain-id 314159 \
--verifier sourcify \
--verifier-url https://sourcify.dev/server/ \
--guess-constructor-args
```

For more information, see the [Sourcify documentation](https://docs.sourcify.dev/docs/how-to-verify/).

### Filfox Verification

Filfox is the native Filecoin explorer with dedicated verification support.

**Installation:**

```bash
npm install -g @fil-b/filfox-verifier
```

**Usage:**

```bash
filfox-verifier forge <address> <contract-path> --chain <chainId>
```

**Examples:**

```bash
# Verify on Filecoin Mainnet
filfox-verifier forge 0xYourContractAddress src/MyContract.sol:MyContract --chain 314

# Verify on Calibration Testnet
filfox-verifier forge 0xYourContractAddress src/MyContract.sol:MyContract --chain 314159
```

For detailed information, see the [@fil-b/filfox-verifier documentation](https://www.npmjs.com/package/@fil-b/filfox-verifier).

[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/smart-contracts/developing-contracts/verify-a-contract/programmatic/foundry)
Loading
Loading