From 4a794cf718e61672b0713132bf7579af0e465d2d Mon Sep 17 00:00:00 2001 From: xBalbinus Date: Wed, 11 Sep 2024 08:39:59 -0700 Subject: [PATCH 1/2] feat: add verify-by-api documentation --- .../developing-contracts/verify-a-contract.md | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/smart-contracts/developing-contracts/verify-a-contract.md b/smart-contracts/developing-contracts/verify-a-contract.md index 012dc2899..9ffa5c7b2 100644 --- a/smart-contracts/developing-contracts/verify-a-contract.md +++ b/smart-contracts/developing-contracts/verify-a-contract.md @@ -25,6 +25,151 @@ The following guide walks you through the process of contract verification using * [Remix](https://remix.ethereum.org/) ### Procedure +#### Via. API (Recommended) + +This section provides detailed documentation for the Filfox Contract Verification API. The API allows you to verify your smart contracts programmatically, and is the recommended method for verifying contracts. Below, you will find information on how to use the API, including the available endpoints, request and response formats, and example code snippets. + +Please refer to the [documentation](https://filfox.info/api/v1/docs/static/index.html) for more information on how to verify contracts using the Filfox API. + +**API Endpoint** + +The Filfox Contract Verification API is available on both the mainnet and the calibration network. The endpoints for these networks are as follows: + +- Mainnet: `https://filfox.info/api/v1/tools/verifyContract` +- Calibration: `https://calibration.filfox.info/api/v1/tools/verifyContract` + +**Parameters** + +The API accepts several parameters that you need to provide in your request. These parameters are detailed in the table below: + +| Parameter | Type | Required | Default | Description | Example | +|-----------------|-------------|----------|-----------|-----------------------------------------------------------------------------|-------------------------------------------------------------------------| +| address | string | No | - | The contract address, supporting 0x, f0, and f4 addresses | '0xB4C47eD546Fc31E26470a186eC2C5F19eF09BA41' or 'f02804637' or 'f410fwtch5vkg7qy6ezdqugdoylc7dhxqtosbhvnbwmq' | +| language | string | Yes | 'Solidity'| The programming language used for the contract. Currently, only Solidity is supported | - | +| compiler | string | Yes | 'latest' | The compiler version used to compile the contract | 'v0.7.6+commit.7338295f' | +| optimize | boolean | Yes | false | Indicates whether optimization was used during compilation | - | +| optimizeRuns | number | Yes | 200 | The number of optimization runs if optimization was used | - | +| optimizerDetails| string | Yes | '' | A stringified JSON object detailing the optimizer components | '{"constantOptimizer":true,"cse":true,"deduplicate":true,"inliner":true,"jumpdestRemover":true,"orderLiterals":true,"peephole":true,"yul":false}' | +| sourceFiles | SourceFiles | No | - | The source files of the contract | - | +| license | string | Yes | 'No License (None)' | The license type of the contract | 'MIT License (MIT)' | +| evmVersion | string | Yes | 'default' | The version of the EVM to compile for | 'shanghai' | +| viaIR | boolean | Yes | false | Indicates whether to use the Yul intermediate representation during compilation | true | +| libraries | string | Yes | '' | A stringified JSON object for libraries used in the contract | '{"file_1.sol":{"library_1_name":"0x123..."}}' | +| metadata | string | Yes | '' | A stringified JSON object for metadata settings | '{"bytecodeHash":"none"}' | + +**Examples** + +Here is an example of how to use the API to verify a contract: + +```bash +curl --location --request POST 'https://filfox.info/api/v1/tools/verifyContract' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "address": "f02835916", + "language": "Solidity", + "compiler": "v0.8.17+commit.8df45f5f", + "optimize": true, + "optimizeRuns": 200, + "optimizerDetails": "", + "sourceFiles": { + "filename1.sol": { + "content": "contract A { function f() public { } }" + }, + "filename2.sol": { + "content": "contract B { function g() public { } }" + } + }, + "license": "", + "evmVersion": "default", + "viaIR": false, + "libraries": "", + "metadata": "" +}' +``` + +**Common Return Values** + +See below for a list of common success and error codes (and their meanings): + + +**Verify ok** + +```json +{ + "success": true, + "errorCode": 0, + "contractName": "xxx", + "initCode": "xxx", + "abi": "xxx" +} +``` + +Your contract is now verified. +​ +**Source files not found** + +```json +{ + "success": false, + "errorCode": 1, +} +``` + +No source file was provided. +​ +**Contract initcode not found** +{ + "success": false, + "errorCode": 2, +} + +Please contact Filfox on Telegram/Slack if you encounter this error. +​ +**Load remote compiler failed** +{ + "success": false, + "errorCode": 3, +} + +The compiler version string must be in the long format. For example, if you would like to use version v0.7.6, you need to include the commit hash of the release like this: `v0.7.6+commit.7338295f`. Please try again later with the correct compiler version string if you encounter this error. +​ +**Verify failed** +{ + "success": false, + "errorCode": 4, + "contractName": "xxx", + "initCode": "6080604052348015610010...", + "byteCode": "6080604052348015610010..." +} + +Compiled bytecode doesn't match the contract's initcode, please make sure all source files and compiler configs are correct. +​ +**Unsupported language** +{ + "success": false, + "errorCode": 5, +} + +Only support Solidity for now. +​ +**Contract already verified** +{ + "success": false, + "errorCode": 6, +} + +The contract you are trying to verify has already been verified before. +​ +**Compilation error** +{ + "success": false, + "errorCode": 7, + "errorMsg": "DeclarationError: Identifier not found or not unique..." +} + +There is something wrong with your source files, please fix it and try again. +​ +#### Via. UI 1. Open Remix: From 456ac96743e750099b4bf4ab648362f0e4bd5805 Mon Sep 17 00:00:00 2001 From: xBalbinus Date: Thu, 12 Sep 2024 08:02:03 -0700 Subject: [PATCH 2/2] Fix: formatting errors --- .../developing-contracts/verify-a-contract.md | 93 ++++++++++++++----- 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/smart-contracts/developing-contracts/verify-a-contract.md b/smart-contracts/developing-contracts/verify-a-contract.md index 9ffa5c7b2..3d8cc56c5 100644 --- a/smart-contracts/developing-contracts/verify-a-contract.md +++ b/smart-contracts/developing-contracts/verify-a-contract.md @@ -91,8 +91,11 @@ curl --location --request POST 'https://filfox.info/api/v1/tools/verifyContract' See below for a list of common success and error codes (and their meanings): +Here is the list of common success and error codes, formatted for clarity: -**Verify ok** +--- + +### **Verify ok** ```json { @@ -104,36 +107,56 @@ See below for a list of common success and error codes (and their meanings): } ``` +**Description:** Your contract is now verified. -​ -**Source files not found** + +--- + +### **Source files not found** ```json { "success": false, - "errorCode": 1, + "errorCode": 1 } ``` +**Description:** No source file was provided. -​ -**Contract initcode not found** + +--- + +### **Contract initcode not found** + +```json { "success": false, - "errorCode": 2, + "errorCode": 2 } +``` +**Description:** Please contact Filfox on Telegram/Slack if you encounter this error. -​ -**Load remote compiler failed** + +--- + +### **Load remote compiler failed** + +```json { "success": false, - "errorCode": 3, + "errorCode": 3 } +``` +**Description:** The compiler version string must be in the long format. For example, if you would like to use version v0.7.6, you need to include the commit hash of the release like this: `v0.7.6+commit.7338295f`. Please try again later with the correct compiler version string if you encounter this error. -​ -**Verify failed** + +--- + +### **Verify failed** + +```json { "success": false, "errorCode": 4, @@ -141,34 +164,56 @@ The compiler version string must be in the long format. For example, if you woul "initCode": "6080604052348015610010...", "byteCode": "6080604052348015610010..." } +``` + +**Description:** +Compiled bytecode doesn't match the contract's initcode. Please make sure all source files and compiler configs are correct. + +--- + +### **Unsupported language** -Compiled bytecode doesn't match the contract's initcode, please make sure all source files and compiler configs are correct. -​ -**Unsupported language** +```json { "success": false, - "errorCode": 5, + "errorCode": 5 } +``` + +**Description:** +Only Solidity is supported for now. + +--- + +### **Contract already verified** -Only support Solidity for now. -​ -**Contract already verified** +```json { "success": false, - "errorCode": 6, + "errorCode": 6 } +``` +**Description:** The contract you are trying to verify has already been verified before. -​ -**Compilation error** + +--- + +### **Compilation error** + +```json { "success": false, "errorCode": 7, "errorMsg": "DeclarationError: Identifier not found or not unique..." } +``` + +**Description:** +There is something wrong with your source files. Please fix the issue and try again. + +--- -There is something wrong with your source files, please fix it and try again. -​ #### Via. UI 1. Open Remix: