Remix
Last updated
Last updated
Remix is a Solidity IDE that’s used to write, compile and debug Solidity code. Solidity is a high-level, contract-oriented programming language for writing smart contracts. It was influenced by popular languages such as C++, Python and JavaScript.
IDE stands for Integrated Development Environment and is an application with a set of tools designed to help programmers execute different tasks related to software development such as writing, compiling, executing and debugging code.
Before you begin using Remix to develop smart contracts, make sure you’re familiar with some basic concepts. In particular, give these articles about blockchain and Ethereum a read.
A smart contract is a trust-less agreement between two parties that makes use of blockchain technology, to enforce the parties to adhere to the terms, rather than relying on the traditional ways such as trusting a middleman or using laws to handle disputes.
Using the Ethereum blockchain, you can create smart contracts with the Solidity language (among others). Ethereum is not the only platform that can be used to create smart contacts, but it’s the most popular choice, as it was designed from the start to support building them.
Dapp stands for decentralized application and is a web3 application that can have a front-end written in traditional languages such as JavaScript, HTML, CSS and a smart contract (as back-end code) which runs on the blockchain. So you can simply think of a Dapp as the front end plus the associated blockchain smart contract(s).
Unlike the smart contract deployed on the blockchain itself, the front end of a Dapp can be either hosted on a centralized server like a CDN or on decentralized storage like Swarm.
You can access the Remix IDE in different ways: online, via a web browser like Chrome, from a locally installed copy, or from Mist (the Ethereum Dapp browser).
You can access the Remix IDE from your web browser without any special installation. Visit https://remix.ethereum.org/ and you’ll be presented with a complete IDE with a code editor and various panels for compiling, running and debugging your smart contracts. You’ll have a default example Ballot contract that you can play with. Beside you should refer Remix document if need more detail.
After seeing how to open the Remix IDE, let’s now see the various panels composing the IDE.
The file explorer provides a view with the created files stored in the browser’s storage. You can rename or delete any file by right-clicking on it, then choosing the right operation from the context menu.
Please note that the file explorer uses the browser’s local storage by default, which means you can lose all your files if you clear or the operating system automatically clears the storage. For advanced work, it’s recommended to use Remixd - a Node.js tool (available from npm npm install -g remixd
) which allows the Remix IDE to access your computer’s file system.
Creating/Opening Files in Remix
You can create a new file in the browser local storage using the first button file on the top left. You can then provide a name and press Enter.
Using the second button from top left, you can open an existing Solidity file from your computer file system into the Remix IDE. The file will also be stored in the browser’s local storage.
Publishing Explorer Files as GitHub Gists
Using the third and fourth buttons from top left, you can publish files from the IDE as a public GitHub gist.
Copying Files to Another Instance of Remix IDE
Using the fifth button from top left, you can copy files from the local storage to another instance of Remix by providing the URL of the instance.
Connecting to the Local File System
the last button can be used to connect the Remix IDE to your local file system if you’re running the Remixd tool.
The Solidity code editor provides the interface where you can write your code with many features such as syntax highlighting, auto-recompling, auto-saving etc. You can open multiple tabs and also increase/decrease the font size using the +/- button in the top-left corner.
The terminal window below the editor integrates a JavaScript interpreter and the web3
object. You can execute JavaScript code in the current context, visualize the actions performed from the IDE, visualize all network transactions or transactions created from the Remix IDE etc. You can also search for data in the terminal and clear the logs.
The Tabs panel provides many tabs for working with the IDE:
the Compile tab: used for compiling a smart contract and publishing on Swarm and used for updating settings like the compiler version and many general settings for the editor.
the Run and Deploy tab: used for sending transactions to the configured environment.
the Settings tab: used for updating settings like the compiler version and many general settings for the editor.
the Plugin tab: used for install local plugin in Remix.
the Search tab: used for search file which locates in Remix.
the File Explorer tab: used for display all files and folders in Remix.
the Debug tab: used for debug when execute contract.
The Remix IDE provides many environments for executing the transactions:
JavaScript VM: a sandbox blockchain implemented with JavaScript in the browser to emulate a real blockchain.
Injected Web3: a provider that injects web3 such as Metamask
, allow you to connect to real blockchain.
Web3 Provider: a remote node with geth, parity or any Ethereum client. Can be used to connect to the real network, or to your private blockchain directly without MetaMask in the middle.
For the sake of demonstrating what we can achieve using Remix IDE, we’ll use an example contract, and we’ll see how we can:
Compile the contract in Remix IDE.
See some warnings emitted by the compiler when best practices aren’t followed.
Deploy the contract on the JavaScript EVM (Ethereum Virtual Machine).
Make transactions on the deployed contract.
See example reads and writes in the terminal IDE.
We’ll use the following example contract from this tutorial which implements a simple contract to store variable on blockchain:
Now, go ahead and open the Remix IDE from remix.ethereum.org.
Next, create a new file by clicking on the button with the + icon.
And then you must enter a name , then press Enter:
A new tab will be opened in the code editor where you can start writing your contract. So just copy and paste the previous contract code in there.
Next, let’s deploy the contract with our RemixVM. Switch to the Deploy and Run Transaction tab, and select Remix VM from the dropdown menu.
Next, click the Deploy button below the contract name.
Once the contract is deployed successfully on the Remix VM, a box will be opened on the bottom as below.
Under the name and address of the deployed contract, we have some buttons with red and blue colors. Red buttons refer to actions that cause a write to the blockchain, where blue buttons refer to reading from blockchain.
The Remix VM provides 15 fake accounts with 100 ether each, which we can use to test the contract. You can select a current account from the dropdown menu with the name Account below the Environment dropdown.
You can see we have 2 functions, therefore we interact with smart contract easily. As below, we just called function store to change global variable number of contract.
After call a function in smart contract, you can check log in terminal as below:
When compile contract, we might run into several errors. Therefore , Remix support developer by using ChatGPT, as you can see below:
There are many alternatives for easy development and deployment of smart contracts, such as:
Hardhat: Hardhat is a development environment for Ethereum software. It consists of different components for editing, compiling, debugging and deploying your smart contracts and dApps, all of which work together to create a complete development environment.
Embark: a framework that allows you to easily develop and deploy Decentralized Applications (DApps).
Dapp: Dapp is a simple command line tool for smart contract development.
different plugins for adding Solidity support to popular IDEs such as this Visual Code plugin and this Atom plugin etc.
We’ve introduced you to the Remix IDE for developing smart contracts for the Ethereum blockchain. You can find more detailed information in the docs.
With a basic introduction behind you, feel free to dive in deeper and experiment with changing the code and exploring the different functions and tabs the editor offers.