Skip to content

Commit 4a794cf

Browse files
committed
feat: add verify-by-api documentation
1 parent 88c1d83 commit 4a794cf

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

smart-contracts/developing-contracts/verify-a-contract.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,151 @@ The following guide walks you through the process of contract verification using
2525
* [Remix](https://remix.ethereum.org/)
2626

2727
### Procedure
28+
#### Via. API (Recommended)
29+
30+
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.
31+
32+
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.
33+
34+
**API Endpoint**
35+
36+
The Filfox Contract Verification API is available on both the mainnet and the calibration network. The endpoints for these networks are as follows:
37+
38+
- Mainnet: `https://filfox.info/api/v1/tools/verifyContract`
39+
- Calibration: `https://calibration.filfox.info/api/v1/tools/verifyContract`
40+
41+
**Parameters**
42+
43+
The API accepts several parameters that you need to provide in your request. These parameters are detailed in the table below:
44+
45+
| Parameter | Type | Required | Default | Description | Example |
46+
|-----------------|-------------|----------|-----------|-----------------------------------------------------------------------------|-------------------------------------------------------------------------|
47+
| address | string | No | - | The contract address, supporting 0x, f0, and f4 addresses | '0xB4C47eD546Fc31E26470a186eC2C5F19eF09BA41' or 'f02804637' or 'f410fwtch5vkg7qy6ezdqugdoylc7dhxqtosbhvnbwmq' |
48+
| language | string | Yes | 'Solidity'| The programming language used for the contract. Currently, only Solidity is supported | - |
49+
| compiler | string | Yes | 'latest' | The compiler version used to compile the contract | 'v0.7.6+commit.7338295f' |
50+
| optimize | boolean | Yes | false | Indicates whether optimization was used during compilation | - |
51+
| optimizeRuns | number | Yes | 200 | The number of optimization runs if optimization was used | - |
52+
| 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}' |
53+
| sourceFiles | SourceFiles | No | - | The source files of the contract | - |
54+
| license | string | Yes | 'No License (None)' | The license type of the contract | 'MIT License (MIT)' |
55+
| evmVersion | string | Yes | 'default' | The version of the EVM to compile for | 'shanghai' |
56+
| viaIR | boolean | Yes | false | Indicates whether to use the Yul intermediate representation during compilation | true |
57+
| libraries | string | Yes | '' | A stringified JSON object for libraries used in the contract | '{"file_1.sol":{"library_1_name":"0x123..."}}' |
58+
| metadata | string | Yes | '' | A stringified JSON object for metadata settings | '{"bytecodeHash":"none"}' |
59+
60+
**Examples**
61+
62+
Here is an example of how to use the API to verify a contract:
63+
64+
```bash
65+
curl --location --request POST 'https://filfox.info/api/v1/tools/verifyContract' \
66+
--header 'Content-Type: application/json' \
67+
--data-raw '{
68+
"address": "f02835916",
69+
"language": "Solidity",
70+
"compiler": "v0.8.17+commit.8df45f5f",
71+
"optimize": true,
72+
"optimizeRuns": 200,
73+
"optimizerDetails": "",
74+
"sourceFiles": {
75+
"filename1.sol": {
76+
"content": "contract A { function f() public { } }"
77+
},
78+
"filename2.sol": {
79+
"content": "contract B { function g() public { } }"
80+
}
81+
},
82+
"license": "",
83+
"evmVersion": "default",
84+
"viaIR": false,
85+
"libraries": "",
86+
"metadata": ""
87+
}'
88+
```
89+
90+
**Common Return Values**
91+
92+
See below for a list of common success and error codes (and their meanings):
93+
94+
95+
**Verify ok**
96+
97+
```json
98+
{
99+
"success": true,
100+
"errorCode": 0,
101+
"contractName": "xxx",
102+
"initCode": "xxx",
103+
"abi": "xxx"
104+
}
105+
```
106+
107+
Your contract is now verified.
108+
109+
**Source files not found**
110+
111+
```json
112+
{
113+
"success": false,
114+
"errorCode": 1,
115+
}
116+
```
117+
118+
No source file was provided.
119+
120+
**Contract initcode not found**
121+
{
122+
"success": false,
123+
"errorCode": 2,
124+
}
125+
126+
Please contact Filfox on Telegram/Slack if you encounter this error.
127+
128+
**Load remote compiler failed**
129+
{
130+
"success": false,
131+
"errorCode": 3,
132+
}
133+
134+
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.
135+
136+
**Verify failed**
137+
{
138+
"success": false,
139+
"errorCode": 4,
140+
"contractName": "xxx",
141+
"initCode": "6080604052348015610010...",
142+
"byteCode": "6080604052348015610010..."
143+
}
144+
145+
Compiled bytecode doesn't match the contract's initcode, please make sure all source files and compiler configs are correct.
146+
147+
**Unsupported language**
148+
{
149+
"success": false,
150+
"errorCode": 5,
151+
}
152+
153+
Only support Solidity for now.
154+
155+
**Contract already verified**
156+
{
157+
"success": false,
158+
"errorCode": 6,
159+
}
160+
161+
The contract you are trying to verify has already been verified before.
162+
163+
**Compilation error**
164+
{
165+
"success": false,
166+
"errorCode": 7,
167+
"errorMsg": "DeclarationError: Identifier not found or not unique..."
168+
}
169+
170+
There is something wrong with your source files, please fix it and try again.
171+
172+
#### Via. UI
28173

29174
1. Open Remix:
30175

0 commit comments

Comments
 (0)