Via explorer

You could directly use U2U blockchain explorer to verify your contract's source code at u2uscan.xyz.

Contract details

At the contract details page, select Contract tab. If the contract has not verified, you will see the Verify & publish button as in below example:

Click on Verify & publish button to start verifying your contract source code. There are multiple methods for verification using the blockchain explorer UI - all are cataloged below:

Verification methods

Solidity (Flattened source code)

  1. Contract Address: The 0x address supplied on contract creation.

  2. Contract Name: Name of the class whose constructor was called in the .sol file. For example, in contract MyContract {.. MyContract is the contract name.

  3. Include Nightly Builds: Yes if you want to show nightly builds.

  4. Compiler: derived from the first line in the contract pragma solidity X.X.X. Use the corresponding compiler version rather than the nightly build.

  5. EVM Version: See evm-version-information.

  6. Optimization enabled: If you enabled optimization during compilation, check yes. 200 is the Solidity Compiler default value. Only change if you changed this value while compiling.

  7. Enter the Solidity Contract Code: You may need to flatten your solidity code if it utilizes a library or inherits dependencies from another contract. We recommend the or the .

  8. Try to fetch constructor arguments automatically: If similar contracts exist these may be available.

  9. ABI-encoded Constructor Arguments: .

  10. Add Contract Libraries: Enter the name and 0x address for any required libraries called in the called in the .sol file.

  11. Click the Verify & publish button.

If all goes well, you will see a checkmark (✅) next to Contract in the code tab, and an additional tab called Read Contract. The contract name will now appear in explorer with any transactions related to your contract.

Solidity (Standard JSON input)

  1. Contract Name. There are several options:

    1. Leave blank.

    2. Enter contract name: MyContract.

    3. Enter path to the contract and it's name: path/to/file.sol:MyContract (path should match what is written in your JSON file).

  2. Include nightly builds. You can select depending on your compiler.

  3. Compiler. Choose the compiler version used to compile your smart contract.

  4. Standard Input JSON. Attach your Standard Input JSON file. File should follows solidity and all the sources must be in Liternal Content format, not an URL.

After filling the form click the Verify & publish button and wait for the response.

Solidity (Multi-part files)

  1. Include nightly builds: Yes if you want to show nightly builds.

  2. Compiler: derived from the first line in the contract pragma solidity X.X.X. Use the corresponding compiler version rather than the nightly build.

  3. EVM Version: See evm-version-information.

  4. Optimization enabled: If you enabled optimization during compilation, check yes. 200 is the Solidity Compiler default value. Only change if you changed this value while compiling.

  5. Sources *.sol or *.yul files: Select your contract files.

  6. Add contract libraries: Enter the name and 0x address for any required libraries called in the called in the .sol file.

Troubleshooting

If you receive the dreaded There was an error compiling your contract message this means the bytecode doesn't match the supplied sourcecode. Unfortunately, there are many reasons this may be the case. Here are a few things to try:

1. Double check the compiler version is correct.

Check all version digits - for example 0.5.1 is different from 0.5.10

2) Check that an extra space has not been added to the end of the contract. When pasting in, an extra space may be added. Delete this and attempt to recompile.

3) Copy, paste and verify your source code in Remix. You may find some exceptions here.

Last updated