Verify & Publish Contract Source Code
Last updated
Last updated
In web3 development, the smart contract runs as a program on the blockchain and its source code is publicly available to anyone. Source code verification guarantees that a smart contract’s source code files match the assembly code, therefore, the security of users’ transactions could be assured.
In Rangers Protocol, developers can conduct the smart contract verification process by entering Rangers Scan Verify.
Note:
Blockchains under the Rangers Protocol ecosystem only support smart contracts that are coded with Solidity programming language.
The developer needs to deploy the smart contract first before beginning the verification procedure. Navigate to Remix IDE and establish a new file with the name "exampleModifier.sol". Paste the subsequent code:
It is essential for the developers to take notes of the Solidity compiler version and the license information for the contract above, which is available at the head of the file as "SPDX-License-Identifier".
Start the verification process by entering Rangers Scan Verify.
Input the smart contract address, which would be checked by Rangers Scan after the contract is deployed.
Select the “Solidity (Single file)” and the corresponding compiler version number.
Click the “Continue” button and proceed to the next step.
Fill in the following fields:
Contract Address (required)
Compiler Version Number (required)
Solidity Contract Code (required)
Enabled Optimizer (default false): must be consistent with the file compilation parameters
Runs (Optimizer, default 200): (Applicable when Optimization = Yes) Optimize for the number of times you intend to run the code. A lower value will optimize more for initial deployment cost, a higher value will optimize more for high-frequency usage.
EVM Version to target (default compilers): When you compile your contract code you can specify the Ethereum virtual machine version to compile to avoid particular features or behaviors.
Click the “Verify and Publish” button and proceed to the next step.
Now the smart contract and source code are verified and public to other developers.
Once you meet the error situation or warnings, please check the below reference for your information.
Common Error Types for Compiling
JSONError: JSON input does not match the required format, e.g. input is not a JSON object, language is not supported, etc.
IOError: IO and import processing errors, such as unresolvable URLs or hash mismatches in the provided source
ParserError: Source code does not match the language rules
DocstringParsingError: Unable to parse NatSpec tag in the comment block
SyntaxErrorcontinuefor: Syntax error, e.g. used outside of a loop
DeclarationErrorIdentifier not found: Invalid, unresolvable, or conflicting identifier name
TypeError: Errors within the type system, such as invalid type conversions, invalid assignments, etc.
UnimplementedFeatureError: The compiler does not support this feature
InternalCompilerError: Internal error triggered in the compiler
Exception: Unknown fault during compilation
CompilerError: Compiler stack use is invalid
FatalError: Error not handled correctly
Common Error Types for Submission
A contract address is required
Invalid Length
Please provide a valid Contract Address
InvalId_Field
Incomplete Input
Rangers Scan Verify also considers the complex scenario in that one smart contract calls multiple smart contracts for running smoothly.
As mentioned above, developers need to deploy the smart contract first before beginning the verification procedure.
If you need to verify more than one smart contract at once, select “Solidity (Multi-Part files)”.
Start the verification process by entering Rangers Scan Verify.
Input the smart contract addresses, which would be checked by Rangers Scan after the contracts are deployed.
Select “Solidity (Single file)” and the corresponding compiler version number.
Click the “Continue” button and proceed to the next step.
Click the “Verify and Publish” button and proceed to the next step.
Now the smart contracts and source code are verified and open to the public.
Once you meet the error situation or warnings, please check the below reference for your information.
Common Error Types for Compiling
JSONError: JSON input does not match the required format, e.g. input is not a JSON object, language is not supported, etc.
IOError: IO and import processing errors, such as unresolvable URLs or hash mismatches in the provided source
ParserError: Source code does not match the language rules
DocstringParsingError: Unable to parse NatSpec tag in the comment block
SyntaxErrorcontinuefor: Syntax error, e.g. used outside of a loop
DeclarationErrorIdentifier not found: Invalid, unresolvable, or conflicting identifier name
TypeError: Errors within the type system, such as invalid type conversions, invalid assignments, etc.
UnimplementedFeatureError: The compiler does not support this feature
InternalCompilerError: Internal error triggered in the compiler
Exception: Unknown fault during compilation
CompilerError: Compiler stack use is invalid
FatalError: Error not handled correctly
Common Error Types for Submission
A contract address is required
Invalid Length
Please provide a valid Contract Address
InvalId_Field
Incomplete Input