-
Notifications
You must be signed in to change notification settings - Fork 43
feat: add guide for verifying smart contracts using the RSK Explorer #431
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
carlos-rsk
wants to merge
3
commits into
main
Choose a base branch
from
feat/DV-1583-contract-verification-guide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
918c418
feat: add guide for verifying smart contracts using the Rootstock Exp…
carlos-rsk 5ceabd3
docs: enhance smart contract verification guide for Rootstock Explore…
carlos-rsk 3f01e77
docs: update smart contract verification guide to specify interaction…
carlos-rsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
...2-developers/05-smart-contracts/04-verify-smart-contracts/rootstock-explorer.md
This file contains hidden or 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,142 @@ | ||
| --- | ||
| sidebar_label: Verify a Smart Contract using the Rootstock Explorer | ||
| sidebar_position: 107 | ||
| title: Verify a Smart Contract using the Rootstock Explorer | ||
| description: "How to Verify a Smart Contract on the Rootstock Explore" | ||
| tags: [Explorer, tutorial, developers, quick starts, rsk, rootstock] | ||
| --- | ||
|
|
||
| Contract verification is essential in the Rootstock ecosystem. It allows Rootstock Explorer users to inspect and validate the source code of deployed smart contracts. | ||
|
|
||
| The Rootstock Explorer provides a transparent view of the Rootstock blockchain, showing transactions, blocks, and deployed contracts. This transparency, enabled by verification, builds trust and understanding in decentralized applications. | ||
|
|
||
| ## What does verification do?: | ||
carlos-rsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - Provides a `Verified` badge on the contract page, indicating that the source code corresponds to the deployed bytecode. | ||
| - Allows readable reading and writing of contract functions. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Allows downloading the contract's Application Binary Interface (ABI). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Address of the deployed contract on Rootstock. | ||
| - Complete source code of the contract. | ||
| - Compiler details: | ||
| - Solc (Solidity Compiler) version. | ||
| - Number of optimization runs. | ||
| - Constructor parameters (if applicable). | ||
| - Library addresses (if used). | ||
|
|
||
|
|
||
| > In summary, this guide will help you verify your smart contract, allowing you to leverage these benefits and contribute to a more transparent and trustworthy decentralized environment on Rootstock. | ||
|
|
||
| ## Visit the Rootstock Explorer | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - To start the verification process go to the Rootstock Explorer [Testnet](https://explorer.testnet.rootstock.io/) or [Mainnet](https://explorer.rootstock.io/), find your contract using the search field. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
|
|
||
| - Once you reach your contract's address view, navigate to the "Contract" tab and click the "Verify Contract" button. | ||
|
|
||
|  | ||
|
|
||
| # Choosing Verification Method | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Rootstock Explorer offers two main methods for contract verification: | ||
|
|
||
| - **Single File (Flattened)**: For simple contracts contained in a single file, where all imports have been "flattened" into a single file. | ||
| - **Multiple Files / Standard JSON** (Hardhat/Foundry/Truffle): For more complex projects with multiple files or those generated by development frameworks like Hardhat, Foundry. | ||
|
|
||
|  | ||
|
|
||
| | **Verification Method** | **When to Prefer** | **Pros** | **Cons** | | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| |---------------------------|--------------------|-----------|-----------| | ||
| | **Single File (Flattened)** | Small contracts, without complex imports or libraries. | Simple and fast for straightforward contracts. | Can be tedious to flatten large contracts or those with many dependencies. | | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | **Multiple Files / Standard JSON** | Large projects, with dependencies, libraries, or generated by development frameworks. | Automatically handles imports and dependencies. | Requires exporting the Standard JSON file from your development environment. | | ||
|
|
||
|
|
||
| ## Compiler Configuration | ||
|
|
||
| It is crucial that the compiler configuration in the explorer exactly matches that used during the compilation of your contract. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Select Solc version**: Choose the Solc version you used to compile your contract. | ||
|
|
||
|  | ||
|
|
||
| - **Optimization**: | ||
| - If you used optimization run when compiling/deploying, enable it during verification and set the same runs (default 200). | ||
| - If you didn’t use optimization, leave it disabled and don’t enter any runs. | ||
|
|
||
|  | ||
|
|
||
| - **EVM Version**: Choose the appropriate EVM version. | ||
|
|
||
|  | ||
|
|
||
| ## Source Code Input | ||
|
|
||
| Provide your contract's source code. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Contract Name**: | ||
| - Enter the exact name of the contract you deployed. This is required so the verifier can match the correct bytecode. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
|
|
||
| - **Paste/Upload source code**: | ||
| - Single File: upload the .sol file. | ||
|  | ||
| - Standard JSON: Upload the standard-json file generated by your development framework. | ||
|  | ||
|
|
||
| - **Constructor Arguments**: You must enter constructor arguments separate by comma if you have more than one. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
|
|
||
| - **Libraries**: | ||
| - If your contract uses libraries, provide their names and deployed addresses. | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
|
|
||
| ## Submit and Validate | ||
| Once you have entered all the details, click "Verify Contract". | ||
|
|
||
| - **Expected statuses**: The verification status will change from "Pending" to "Success" or "Failure". | ||
| - **In case of success**: | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| a. You will see the `Verified` badge on the contract page. | ||
|  | ||
|
|
||
| b. Source code tabs will be visible. | ||
|  | ||
|
|
||
| c. You will be able to download the contract ABI. | ||
|  | ||
|
|
||
| d. Contract read and write panels will be available. | ||
| - **Read Methods**: | ||
|  | ||
| - **Write Methods**: | ||
|  | ||
|
|
||
|
|
||
| ## Troubleshooting | ||
|
|
||
| Here are some common problems and their solutions: | ||
carlos-rsk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Compiler version mismatch**: | ||
| - Confirm the exact **Solc version** used to compile your contract. | ||
| - Retrieve the version from your compilation artifacts. | ||
|
|
||
| - **Invalid constructor arguments**: | ||
| - Verify the precise **encoding**, **order**, and **types** of your constructor arguments. | ||
|
|
||
| - **Library not found / address mismatch**: | ||
| - Ensure **library names** match bytecode placeholders. | ||
| - Add the correct **deployed addresses** for each library. | ||
|
|
||
| - **Optimization runs differ**: | ||
| - Align the number of **optimization runs** with your compilation settings. | ||
|
|
||
| - **Flattening / import issues**: | ||
| - Consider using the **Standard JSON** verification method to avoid path or flattening issues. | ||
|
|
||
| - **Proxy and Implementation**: | ||
| - Verify the **implementation contract**. | ||
| - Note any **proxy-aware UI** (if available) and how to link it. | ||
|
|
||
| > 💡 **Tip:** If verification keeps failing, try matching the compiler settings directly from your Hardhat or Foundry build artifacts. | ||
carlos-rsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Binary file added
BIN
+125 KB
static/img/developers/smart-contracts/rsk-explorer/contract-interaction.png
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.
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.
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.
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.
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.