Verify Your Smart Contract
Verify the deployed contract on the MELD block explorer
The first and foremost step is to flatten the solidity contract into a single file to be able to get it verified on MELD block explorer.
Flatten the Smart Contract Code
Copy and Paste your smart contract into a local file on your system named as
HelloWorld.sol
.Use a package installer to install Truffle Flattener (or your desired tool to perform the flattening)
For NMP run the command
npm install truffle-flattener
on your terminal or command prompt.For Homebrew run the command
brew install truffle
Flatten the contract by running the command in the
npx truffle-flattener HelloWorld.sol > FlatHelloWorld.sol
contracts directoryClean up the licensing information.
The flattened contract will have the same licensing note imported from each of the files.
Multiple licensing notes in one file break the verification process, so you have to leave one licensing note for the entirety of the flattened contract.
The easiest way to clean up is to search for the SPDX mentions in the file and remove all of them except for the very first one.
Using Flattened Code to Verify
At this point, you have your flattened and cleaned-up contract ready for the MELD block explorer verification.
Enter the address of the smart contract you want to verify
In Compiler Type, select Solidity Flattened.
In Compiler Version, select v0.8.15. This is the version this tutorial used to compile the contract.
In Open Source License Type, select MIT License (MIT).
Click Continue.
Keep the Optimization option set to No as Remix does not use optimization by default.
Important: if you used a different optimization configuration, adapt as needed
Paste the entirety of your flattened .sol contract in the Enter the Solidity Contract Code below field.
Click Verify and Publish.
MELD block explorer will take a few seconds to compile your contract, verify, and publish it.
Last updated