Using Remix

How to deploy with Remix IDE on MODE

Mode is an OP Stack Layer-2 designed for hyper-growth. Since MODE is built with the OP Stack, it is EVM compatible, allowing you to easily port your existing Ethereum-based smart contracts without modifying the code.

Let’s see how to deploy a smart contract on MODE using the Remix IDE.

This guide assumes you have got Sepolia ETH and bridged to the Mode Testnet Network.

1. Deploy using Remix

First of all you will need to have Mode network added to your Metamask. Follow Using Mode Testnet for the step-by-step on how to add Mode testnet to Metamask.

We are ready to get started!

Remix is a no-setup tool with a graphical interface for developing smart contracts. It’s easy to get started allowing a simple deployment process, debugging, interacting with smart contracts, and more. It’s a great tool to test quick changes and interact with deployed smart contracts.

For the sake of this tutorial, we will be deploying the ‘1_Storage.sol’ smart contract that comes as an example in Remix, but you can use any of your code. Here is the sample code, you can paste this in any .sol file:

1_Storage.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.8.2 <0.9.0;

contract Storage {

    uint256 number;
    
    function store(uint256 num) public {
        number = num;
    }

    function retrieve() public view returns (uint256){
        return number;
    }
}

To compile your smart contract, go to the Solidity Compiler tab and select the contract you want to compile. Click on "Compile", you can also enable "Auto Compile" for automatic compilation whenever you change the contract code.

Make sure to open the advanced configurations and setting the EVM version to London. This is to avoid an issue with the PUSH0 opcode. You can read more on the issue with all the Optimism chains here.

Once the smart contract is compiled successfully, switch to the "Deploy & Run Transactions" tab.

In the "Environment" dropdown menu, select "Injected Provider - MetaMask"; this will connect your MetaMask to Remix and will allow you to make transactions from that connected wallet.

Make sure to have Mode as your selected network in Metamask before deploying

Select the compiled contract you want to deploy and click ‘Deploy.’

Now, MetaMask should pop up and ask you to confirm the transaction with super low fees.

CONGRATULATIONS! You just deployed your first smart contract to Mode.


2. How to explore and interact with your deployed smart contract?

Now that you have deployed your first smart contract to Mode let’s see how to interact with it.

You will see your deployed smart contract below in the ‘Deploy & Run Transactions’ tab. You can use the Remix interface to call the methods defined in your smart contract and access it’s public variables.

We can also find our deployed smart contract in Blockscout, the Mode block scanner. Copy the contract address from Remix, go to Blockscout, and paste it into the search bar.

The screenshot below shows our deployed smart contract, where you can see all transactions, the creator wallet, balance, and more!

Notice that if you call one of the smart contract methods in Remix, you should see the transaction pop up in this explorer. You can directly interact with your deployed smart contract with Remix.

You now have learned how to deploy a smart contract on Mode using Remix online IDE!

In this tutorial, we also went through the Mode bridge, block explorer, and how to interact with your contract.

To learn more about Mode and how to turn your code into a business, join our Discord and say hello 👋

If you want the next challenge, you can try registering a contract for the SFS following this guide: SFS - Registering a contract with Remix

Last updated