Skip to main content

Remix IDE

Remix IDE guide


Remix is a great tool that allows you to easily write, test and deploy smart contracts on any EVM-compatible blockchain. Darüber hinaus ermöglicht die Integration mit MetaMask die Nutzung jedes RPCs, deshalb haben wir gerade einen Verweis auf Autonomys Core EVM in unserem MetaMask-Wallet eingerichtet!

Remix has amazing documentation, but this guide will cover everything required to get you started.

  1. Navigieren Sie mit dem Browser Ihrer Wahl zur Remix-Website. Sie sehen einen Datei-Explorer und eine Schnittstelle zum Erstellen neuer Arbeitsbereiche, Integrationen mit GitHub, Gist, IPFS, HTTPS, vorinstallierten Vorlagen und Plugins. Let’s create a new workspace by clicking on the + sign beside WORKSPACES.

Remix-1

  1. You can enter any name and use the ERC20 template.

Remix-2

  1. Right after you create your workspace, you will see a few folders created for you. Let’s click on contracts and have a look at MyToken.sol.

Remix-3

  1. Here, you can change the name of your contract (in the example, to Counter), the name of the token (in this example, we're calling it SubspaceTestToken) and the token symbol (we're using TSSCtest). 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", "TSSCtest") {}

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 a Counter contract. To compile, click on SOLIDITY COMPILER on the left and choose the compiler version that corresponds to the Solidity version of your contract. In our case, it’s version 0.8.9. Click on Compile MyToken.sol and check if it compiles correctly. If it does, you will see a green checkmark by the compiler.

Remix-5

  1. Deploying a smart contract could be an expensive procedure, based on the gas costs associated with the transaction. That is why it’s recommended that you thoroughly test the smart contracts for correctness before proceeding with deployment. To test the contract, let’s open the tests folder and have a look at MyToken.sol created for us.
    Let’s first try to run a test as is without making any changes.

Remix-6

  1. To run the tests, select SOLIDITY UNIT TESTING in the bar on the left and click Run.

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 order to make the test pass, replace the internals of MyToken.sol with the provided below code. In the test, we're adding a few assertions for the increment() and decrement() functions. In this example, we will set up an 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(), "TSSCtest", "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. Great, all tests are now passing which means our smart contract Counter is indeed working as we expect. We’re all set to deploy it now!

Remix-9

  1. To deploy click on the DEPLOY AND RUN TRANSACTIONS tab on the left. Remix allows you to use one of the 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. Sie werden aufgefordert, das Passwort mit MetaMask zu bestätigen. Stellen Sie lediglich sicher, dass das Netzwerk, mit dem Sie verbunden sind, Autonomys EVM ist.

Remix-11

  1. Passen Sie das Gaslimit an und stellen Sie Ihren Smart Contract auf Autonomys Core EVM bereit. Now your transaction is recorded and you can interact with your smart contract at the bottom of the page - it's possible to call the functions increment() and decrement() as well as setNumber()
caution

Versuchen Sie nicht, eine Transaktion zu beschleunigen (geben Sie zusätzlich zu den Gebühren kein Trinkgeld ein). To read more about this, please refer to this section.

caution

In einigen Fällen kann es bei der Bereitstellung des Skripts zu den Problemen „Kein manueller Gebührengrenzwert festgelegt“ oder „Schätzung der Gebühren fehlgeschlagen“ kommen. Please refer to this section for the solution.

Remix-12

Herzlichen Glückwunsch, Sie haben gerade Ihren Smart Contract auf Autonomys Core EVM bereitgestellt!