πŸ•Quick start

In this section we'll get you deploying a sample contract on Mode in less than 10 minutes. Let’s see how to deploy a smart contract on Mode using the Remix IDE for simplicity.

Get everything ready

Before getting started:

  1. Follow Using Mode Testnet for the step-by-step on how to add Mode testnet to Metamask.

  2. This guide assumes you have got Sepolia ETH and bridged to the Mode Testnet Network. Learn how to do that in Testnet Faucets

We are ready to get started!

Remix & Sample Code

Remix is a no-setup tool 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.

We added a few lines of code to register this contract on the SFS. You can copy and then paste this in Remix or use your own contract code. Here's the sample code:

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

pragma solidity ^0.8.20;

interface Sfs {
    function register(address _recipient) external returns (uint256 tokenId);
}

contract Storage {

    uint256 number;

    constructor(){
      // This address is the address of the SFS contract on testnet
      Sfs sfsContract = Sfs(0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6); 
      // Registers this contract and assigns the NFT to the deployer of this contract
      sfsContract.register(msg.sender); 
    }
    
    function store(uint256 num) public {
        number = num;
    }

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

If you know a little solidity, you must already notice something else in this contract. This contract is being registered to the SFS in the constructor. We won't go over this in depth in this tutorial, please go to SFS - Sequencer Fee Sharingif you want to know more about how it works.

This contract just let's you store a number and then read what that number is while also registering it in the SFS registry.

Steps to deploy

  1. Copy the sample code and paste it in one of the .sol files in Remix

  2. To compile your smart contract, go to the Solidity Compiler tab and select the contract you want to compile

  3. 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 this specification with all Optimism chains here.

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

  2. 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 Testnet as your selected network in Metamask before deploying.

  1. 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.

Or you can read more about the SFS - Sequencer Fee Sharing.

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

Last updated