How to port a dApp to Reef Part 2: Verify Smart Contract

How to port a dApp to Reef Part 2: Verify Smart Contract

Briefing - What is this tutorial all about?

If you're new to developing solutions on Reef, you will definitely come across Reefs EVM compatibility, which offers you easy deployment, interaction and porting of your legacy Ethereum Solidity smart contracts. In this tutorial, we will explain the process of verifying a Solidity smart contract on Reef's affordable & efficient layer1 blockchain.

Relevance - Why do I need this tutorial?

We will explain the most important steps to verify a smart contract on Reef. This will ensure users that your project is well developed and secure. At the same time, you will enjoy full Reef community benefits, low fees and fast transactions.

See our blockchain comparison chart below:

Prerequisites - What do I need to get started?

  1. Existing smart contract
  2. Reef chain extension
  3. Reef extension account

How to get REEF tokens for testnet?

  1. Join Reef’s Discord server
  2. Verify
  3. Select the Builder role in #start-here
  4. Go to the #faucet channel
  5. Type /faucet [wallet address] and hit Enter

The bot will help you with auto-complete!

🚀 Getting started - we are ready to go!

Step0: Visit

The contract we are going to deploy again today is the following called Flipper.sol :

// Specifies the version of Solidity, using semantic versioning.
// Learn more:
pragma solidity ^0.8.4;

contract Flipper {
	bool private value;

	/// Constructor that initializes the `bool` value to the given `init_value`.
	constructor(bool initvalue) public {
		value = initvalue;

	/// A message that can be called on instantiated contracts.
	/// This one flips the value of the stored `bool` from `true`
	/// to `false` and vice versa.
	function flip() public {
		value = !value;

	/// Simply returns the current value of our `bool`.
	function get() public view returns (bool) {
		return value;

Use the following command to deploy it:

yarn hadrhat run scripts/deploy.js --network reef_testnet

Now that you successfully deployed the contract, please copy the contract_address.

Step1: Visit and go to “Contracts”. Lets paste the contract address

We can see that our contract is not verified yet. If we click on it, we can get some additional information, so let's do that.

Step2: Let us go to our IDE and have a look at the script “deploy_and_verify.js”

Now let's go into this javascript a little deeper. We can see the deployment of Flipper.sol that we already know by now.

In addition, we are using the method verifyContract (see line 19).

const hre = require("hardhat");

async function main() {
  // define your testnet_account in hardhat.config.js
  const alice = await hre.reef.getSignerByName("testnet_account");
  await alice.claimDefaultAccount();

  const Flipper = await hre.reef.getContractFactory("Flipper", alice);
  const args = [false];
  const flipper = await Flipper.deploy(...args);
  await flipper.deployed();
  console.log("Deploy done");
  console.log("Save the address to change the values in existing contract");
    flipper_contract_address: flipper.address,
    deploy_hash: flipper.deployTransaction,

  await hre.reef.verifyContract(flipper.address, "Flipper", args);

  console.log("Initial value:", await flipper.get());

  // Flip value
  console.log("Flipping value ...");
  await flipper.flip();

  // Check new value
  console.log("New value:", await flipper.get());

  .then(() => process.exit(0))
  .catch((error) => {

We can use this method via hardhat to call the reefscan-api. Let us check the resources there in the next step.

Step3: Have a look at the API to understand the verification process better. Visit

We can now get deeper into the functionality of the API and also the information used for verification purposes. The following parameters are needed to submit a verification:

Submit verification

URL : /verification/submit

Method : POST

We can POST them to get verified using hardhat-reef as shown in the code. You can find additional information on how to use verifyContract here:

  await hre.reef.verifyContract(flipper.address, "Flipper", args);

Step4: Now let us deploy the Flipper.sol contract and also call verifyContract using the deploy_and_verify.js script for instant verification of the contract

yarn hardhat run scripts/deploy_and_verify.js --network reef_testnet

You can now see that the contract got deployed and verified at the same time! Nice one.

Let us copy the address and check if the contract actually got verified.

There we go! See "Verified source" in green.

Step5: Click on "Developer" and see the different options there

We can see different arguments here that are submitted via API call by default. You could also define them manually yourself, as for example:

  await hre.reef.verifyContract(
      runs: 200, // We are still placing runs event tho optimization is set to false
      target: 'london', // Default target version
      optimization: false, // We are not using contract optimization
      compilerVersion: "v0.8.4+commit.c7e474f2", // Examples project uses 0.8.4 solidity compiler version

Here we specify those arguments individually.

Step6: Click on "Execute" and see the different options there

Users can test the contracts functions here using the Reefscan UI.

Step7: Click on "Verified Source" and see the different options there

The source code can be looked at here.

Step8: Click on "ABI" and see the different options there

You can also look at the Application Binary Interface and copy it.

Step9: You can also see "Transactions"

Transactions can be spotted and individually analyzed.

Step10: Let us now go back to our unverified source and click on "Submit Source" to see another possible approach

Here you can complete the whole process manually using the provided interface.

And you can also add your code source here.

Debriefing - What are the most important takeaways from this tutorial?

What's next?

Check out more tutorials about the Reef ecosystem here on this blog. Learn how to claim your EVM address or code a simple smart contract from scratch. In the next videos, we are going to look into smart contract verification, wallet integration & UI-examples.