The Easy way to develop, test, and deploying Smart Contracts

Photo by Yancy Min on Unsplash

The Easy way to develop, test, and deploying Smart Contracts

TLDR; JUST USE REMIX

ยท

3 min read

Many people think developing smart contracts is complex and requires multiple tools like Truffle, Ganache, or any smart contract development frameworks. While that may be true for specific use cases, creating smart contracts to get started is pretty straightforward - thanks to tools like Remix.

Remix is an online IDE (Integrated Development Environment) that makes developing, testing and deploying basic Ethereum smart contracts very accessible. It provides features like:

  • A Solidity compiler with syntax checking

  • An embedded testing framework

  • Built-in Ganache support for local deployment and testing

  • An interface to interact with deployed contracts

All of this is available in your browser for free. No complex toolchains or dependencies to install. You can get started in just a few minutes.

In this post, we'll see how easy it is to develop, test and deploy a basic smart contract using Remix.

Let's build a Todo List smart contract:

pragma solidity ^0.4.25;

contract TodoList {

    struct Todo {
        uint id;
        string content;  
        bool completed; 
    }

    Todo[] public todos;

    function createTodo(string memory _content) public {
        todos.push(Todo(todos.length + 1, _content, false));
    }
}

This simple contract has:

  • A Todo struct to represent each todo item

  • An array todos to store all todo items

  • A createTodo() function to add new todos

Now in the Remix "Test" tab, we'll write tests for our contract:

contract TodoListTest {

    TodoList todoList;

    function beforeEach() public {
        todoList = new TodoList();
    }

    function testCreateTodo() public {
        todoList.createTodo("First todo");
        assert(todoList.todos.length == 1, "Todo not created");
        assert(todoList.todos[0].content == "First todo", "Content incorrect");
    }
}

This test contract:

  • Creates a new TodoList contract in beforeEach()

  • Checks that createTodo() works as intended

Running these tests in Remix will identify any issues in our contract before deployment.

Now under "Environments", select Ganache. This allows us to deploy to a local blockchain for testing.

Compile our TodoList contract and deploy it. It will automatically be deployed to our Ganache network.

Now under the "Contract" tab, we can interact with our deployed contract:

todoList.createTodo("My first todo");
todoList.createTodo("Learn Solidity");

We can see our todo items have been successfully added!

With Remix we can develop, test and iteratively deploy updated contract versions - all from a simple browser interface.

Remix also integrates with Metamask so we can deploy our contracts to public networks like Ropsten or Kovan for end-to-end testing.

To summarize, Remix makes developing basic smart contracts very accessible by providing:

  • A Solidity compiler

  • Testing capabilities

  • Built-in deployment to local and public networks

  • An interactive interface to call contracts

So the next time someone says developing smart contracts is complex, just point them to Remix! With its simple yet powerful features, anyone can write their first smart contract in minutes.

Did you find this article valuable?

Support Lexy Thinks by becoming a sponsor. Any amount is appreciated!

ย