Auto EVMRemix Guide

Remix IDE Guide

Remix is a tool that allows you to easily write, test and deploy smart contracts on any EVM-compatible blockchain.

EVM Version Compatibility

Auto EVM is compatible with most EVM versions but doesn’t support some features introduced in newer versions like “Paris” or “Shanghai”. When using development tools, you may need to specify an EVM version explicitly. Supported versions: “Istanbul”, “London”.

In Remix, set the EVM version in the Solidity compiler settings:

Go to the “Solidity compiler” tab Click on “Advanced Configurations” Set “EVM Version” to “london” or “istanbul”

Getting started

  1. Navigate to the Remix website. You will see a file explorer and interface for creating new workspaces, integrations with GitHub, Gist, IPFS, HTTPS, preloaded templates, and plugins. Create a new workspace by clicking on the + sign next to WORKSPACES.

Remix-1

  1. Choose the ERC20 template and enter any workspace name.

Remix-2

  1. After creating your workspace, you will see some folders created for you. Click on contracts and open MyToken.sol.

Remix-3

  1. Change the name of your contract (Counter), the name of the token (AutonomysTestToken), and the token symbol (AI3test). As an example, let’s add a simple smart contract that has three functions: setNumber(), increment() and decrement().
 // SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';

contract Counter is ERC20 {
    constructor() ERC20("AutonomysTestToken", "AI3test") {}

    uint256 public number;

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }

    function increment() public {
        number++;
    }

    function decrement() public {
        number--;
    }
 }

Remix-4

  1. Next, let’s compile the Counter contract. Click on SOLIDITY COMPILER (on the left), choose the compiler version that corresponds to the Solidity version of your contract (version 0.8.9 in the example), and click on Compile MyToken.sol. If it compiles correctly, you will see a green checkmark next to the compiler.

Remix-5

  1. Before proceeding with deployment, thoroughly test your smart contracts for correctness, as mistakes can lead to unforeseen gas costs. As an example, click on the tests folder and open MyToken.sol. Test the contract (without making changes) by selecting SOLIDITY UNIT TESTING (the two ticks in the bar on the left) and clicking Run.

Remix-6

Remix-7

  1. As expected, the test failed because we manually changed the token name and symbol. This is Test Driven Development (TDD) in action! In the test, we’re adding some assertions for the increment() and decrement() functions. To make the test pass, replace the internals of MyToken.sol with the code below. In this example, we will set the initial value of number to 2 and increment and then decrement it by 1. We would expect the number to increase to 3 and then decrease back to 2.
 pragma solidity >=0.7.0 <0.9.0;
 import "remix_tests.sol";
 import "../contracts/MyToken.sol";
 
 contract CounterTest is Counter {
 
    function testTokenInitialValues() public {
        Assert.equal(name(), "AutonomysTestToken", "token name did not match");
        Assert.equal(symbol(), "AI3test", "token symbol did not match");
        Assert.equal(decimals(), 18, "token decimals did not match");
        Assert.equal(totalSupply(), 0, "token supply should be zero");
    }
 
    Counter public counter;
 
    function setUp() public {
        counter = new Counter();
        counter.setNumber(2);
    }
 
    function testIncrement() public {
        counter.increment();
        Assert.equal(counter.number(), 3, "test increment did not match");
    }
 
    function testDecrement() public {
        counter.decrement();
        Assert.equal(counter.number(), 2, "test decrement did not match");
    }
 }

Remix-8

  1. All tests are now passing, meaning our smart contract Counter is working as expected. We’re now ready to deploy it!

Remix-9

  1. Click on the DEPLOY AND RUN TRANSACTIONS tab (on the left) to deploy. Remix allows you to use one of their existing EVMs or inject your own provider through its integration with MetaMask. Since we already have a MetaMask account set up, let’s use this option.

Remix-10

  1. After ensuring the network you’re connected to is the Autonomys EVM, confirm your MetaMask password when prompted.

Remix-11

  1. Adjust the gas limit and deploy your smart contract on the Autonomys EVM domain. Your transaction is now recorded and you can interact with your smart contract at the bottom of the page, meaning it’s possible to call the functions increment() and decrement(), as well as setNumber().

Note: Do not tip when submitting transactions in an attempt to accelerate them as this could result in dual charges for gas fees. When deploying smart contracts to our Auto EVM domain, you may encounter an error related to gas estimation, typically presenting as: "No manual gas limit set" or "Gas estimation failed". For more information and solutions, visit the Auto EVM Introduction.

Remix-12

Congratulations, you’ve successfully deployed your smart contract on the Auto EVM!