Solidity Remix IDE Quickstart

4.7/5 - (4 votes)

Solidity is one of the most popular languages for writing smart contracts on the Ethereum network. You can code Solidity online using the Remix IDE. This article will show you how! ๐Ÿ‘‡ 

Solidity Remix IDE Quickstart

Quick Intro to Remix

Remix is a free web-based integrated development environment (IDE) for developing Ethereum smart contracts. Remix allows developers to use Solidity as well as other programming languages to develop on the Ethereum network.

๐Ÿ‘‰ Recommended: Simply visit remix.ethereum.org to begin writing Solidity code.

There are three panes  or sections on the page; 

  1. left navigation/menu 
  2. the middle pane (dependent on menu selection) 
  3. code editor.

To get started, begin by selecting Solidity under the heading โ€œFeatured Pluginsโ€. This will open the Solidity Compiler.

Deploy First Smart Contract

To create a new file, select the โ€œFile Explorerโ€ icon from the menu, then click the โ€œCreate New Fileโ€ icon.

Name the file

Type in the name of the file. It is our first program so letโ€™s go with โ€œhelloworldโ€ once the file is named we can begin writing Solidity code in the code editor. Paste or type the code below into Remix.

To compile the program click the Solidity compiler icon on the left navigation and then click the compile button.

To deploy the smart contract click the deploy icon on the left navigation. Then click the deploy button.

After the contract has been deployed, it will appear, and the variable myString can be called by clicking the button to reveal the string value "hello world".

Using Microsoft VS Code to write a Solidity Smart Contract

Download and install the appropriate version of VS Code for your computer here: โ€‹โ€‹https://code.visualstudio.com/download

After installation, you will need to install a Remix plugin in your VS Code editor.

Click the extensions icon on the left navigation and search for Remix.

The top result will be โ€œEthereum Remixโ€ which is the most popular Remix plugin with the most star ratings.

Click install.

Create a new file and type in the code for our HelloWorld program as below.

Code Snippet:

pragma solidity ^0.8.17;
 
contract HelloWorld {
   string public myString = "Hello World!";
}
  • pragma solidity targets the compiler version of Solidity, in this case, it is version 0.8.17
  • contract defines the contract, in this case, HelloWorld.
  • string defines a string.
  • public means we have read access to the variable after the smart contract is deployed.
  • myString is the name of the string.
  • "Hello World!" is the value of the string myString.

Next click the remix icon in the left navigation, click โ€œCompileโ€ and then select the โ€œhelloworldโ€ file.

To deploy the smart contract click โ€œRun& Deployโ€ and then connect to โ€œRemixโ€

Next, visit remix.ethereum.org in your web browser and click โ€œconnect to localhostโ€.

You will be presented with an alert asking you to connect to localhost, click the โ€œconnectโ€ button.

After you are connected, Remix.ethereum.org will indicate in the file explorer localhost in the middle pane.

VS Code will indicate that you are now connected to remix.ethereum.org and you can proceed to click the โ€œCompileโ€ button, followed by the โ€œDeployโ€ button (you might have to scroll a little downward).

Getting Started with Hardhat Ethereum Development

Hardhat is a smart contract development framework for Ethereum. 

To begin, go to the terminal and create a directory, in the example the directory created is โ€œhello-hardhatโ€

  • mkdir hello-hardhat (mkdir = make directory)
  • cd hello-hardhat (cd = change directory)
  • ls (ls = list directory)

Next, install npm package

  • npm init (init = initializer, can be used to set up a new or existing npm package)

Accept the default settings

Next install hardhat 

Type โ€œnpm install hardhatโ€

When the installation is done, type โ€œnpx hardhatโ€. That will launch hardhat (see below)

Hit enter, and a configuration file will be created. Accept the prompts about directory and others

Type โ€œlsโ€ to see the files created.

Next we can open up the project with Visual Studio Code Editor and see the files

From here, you can create a new smart contract with the contracts folder.

๐Ÿ‘‰ Recommended Tutorials: For a complete Syllabus on Solidity, check out our overview guide here. If you only need a quick crash course on Solidity, start here.