-
Notifications
You must be signed in to change notification settings - Fork 297
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
feat: add verify-by-api documentation for FILFOX #2313
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,196 @@ The following guide walks you through the process of contract verification using | |
* [Remix](https://remix.ethereum.org/) | ||
|
||
### Procedure | ||
#### Via. API (Recommended) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it is the recommended way of verifying the contract? |
||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This documentation links to Filfox API Documents which does not include verifyContract API. Is it a wrong link? Or maybe we can just remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xBalbinus can you address the comments, so we can get this merged? |
||
|
||
**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): | ||
|
||
Here is the list of common success and error codes, formatted for clarity: | ||
|
||
--- | ||
|
||
### **Verify ok** | ||
|
||
```json | ||
{ | ||
"success": true, | ||
"errorCode": 0, | ||
"contractName": "xxx", | ||
"initCode": "xxx", | ||
"abi": "xxx" | ||
} | ||
``` | ||
|
||
**Description:** | ||
Your contract is now verified. | ||
|
||
--- | ||
|
||
### **Source files not found** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"errorCode": 1 | ||
} | ||
``` | ||
|
||
**Description:** | ||
No source file was provided. | ||
|
||
--- | ||
|
||
### **Contract initcode not found** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"errorCode": 2 | ||
} | ||
``` | ||
|
||
**Description:** | ||
Please contact Filfox on Telegram/Slack if you encounter this error. | ||
|
||
--- | ||
|
||
### **Load remote compiler failed** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"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** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"errorCode": 4, | ||
"contractName": "xxx", | ||
"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** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"errorCode": 5 | ||
} | ||
``` | ||
|
||
**Description:** | ||
Only Solidity is supported for now. | ||
|
||
--- | ||
|
||
### **Contract already verified** | ||
|
||
```json | ||
{ | ||
"success": false, | ||
"errorCode": 6 | ||
} | ||
``` | ||
|
||
**Description:** | ||
The contract you are trying to verify has already been verified before. | ||
|
||
--- | ||
|
||
### **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. | ||
|
||
--- | ||
|
||
#### Via. UI | ||
|
||
1. Open Remix: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same content as Filfox docs. I am wondering if this is necessary to have the same content here in Filecoin docs to bring the extra work of maintaining here comparing with just providing a link to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @longfeiWan9, I think a better option would be to list the different platforms that do contract verification, like at the top of this document, and then under each platform list links to their tutorials.