# Remix - A First Glance

For aspiring blockchain developers, the first question one might have on their mind is the following: where do I write my smart contracts? For this, we turn to [Remix](https://remix.ethereum.org), an interactive development environment that allows us to both *write* smart contracts and *deploy* our code to EVM-compatible blockchains. For the purposes of this lesson, we will focus on the process of creating and deploying a smart contract.

## Understanding The Structure of Remix

When first loading Remix, you will see a home screen similar to the following:

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2F3VW4UOT1NDR0fSch6Dg7%2FScreenshot%20from%202023-05-10%2019-48-01.png?alt=media&#x26;token=f834b9c6-ec2e-45ba-beb2-24febe2028bc" alt=""><figcaption><p>Remix Home Screen</p></figcaption></figure>

For right now, what we are interested in is the **Workspaces** column. Remix allows us to create workspaces as a way to separate our projects - imagine putting the smart contracts of hundreds of projects into a single workspace! When first using Remix, we are given a default workspace called *default\_workspace*.&#x20;

Within *default\_workspace*, we are particularly interested in the **contracts** folder. If you click on the **contracts** folder, the following content should drop down from the folder:

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2F5UNDvdaF0VBZ0xaeTD3w%2FScreenshot%20from%202023-05-21%2011-16-48.png?alt=media&#x26;token=4f37dd55-926e-4a3d-bdee-68197bd60a97" alt=""><figcaption><p>Contents of the Contracts Folder</p></figcaption></figure>

As the name might suggest, the **contracts** folder is where smart contracts live. This is made evident by the three starter smart contracts that Remix provides us with: *1\_Storage.sol*, *2\_Owner.sol*, *3\_Ballot.sol*. For the purposes of this lesson, however, we will be adding a smart contract to the **contracts** folder.

## Creating Your First Contract

To create a new smart contract in the **contracts** folder, right-click on the contracts folder and the following drop-down menu will appear:

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2FTTSTmFfSc10KZls1C2F0%2FScreenshot%20from%202023-05-21%2011-25-41.png?alt=media&#x26;token=01a2fc05-599a-4520-97d3-a83da6c5f646" alt=""><figcaption><p>Right-Clicking the Contracts Folder</p></figcaption></figure>

Click on "New File" and you will now be able to define the name of your smart contract file. ***Solidity files have the file extension .sol*****&#x20;.** For the purposes of this lesson, name your file **HelloWorld.sol** .&#x20;

{% hint style="info" %}
How do I know if Remix recognizes my file as being a Solidity file? Any file that is interpreted as a Solidity file has the Solidity logo to the left of it.

![](https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2FC8YlkzCAdac1ponsR0aP%2FScreenshot%20from%202023-05-21%2011-33-18.png?alt=media\&token=42bd59db-cca0-422b-8981-c5ecefd74cb7)
{% endhint %}

Listed below is the source code of **HelloWorld.sol** ; copy-and-paste this into your **HelloWorld.sol** file.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HelloWorld {

    function print() public pure returns(string memory) {
        return "Hello World";
    }

}
```

## Compiling Your First Contract

Solidity is a compiled programming language and thus, we must compile our smart contracts before deploying them. On the left-hand sidebar in Remix, you will find a button with the Solidity logo on it. Upon clicking the button, you will come across the Solidity compiler that Remix provides to compile our smart contracts.

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2F7DwKOSJkAfMJDCGBqTCi%2FScreenshot%20from%202023-05-21%2011-51-12.png?alt=media&#x26;token=b9845b31-39df-48f7-ad04-686900933231" alt=""><figcaption><p>Remix Solidity Compiler</p></figcaption></figure>

To compile **HelloWorld**, simply just click the *Compile HelloWorld.sol* button; if your contract is defined correctly, this will result in a green checkmark appearing next to the Solidity logo. If your contract is not defined correctly, you will not be able to compile your contracts and an error message will appear below the compiler tool.

## Deploying Your First Contract

We've now come to the perhaps the most exciting part - deploying **HelloWorld**! Looking again to the lefthand sidebar, click the button represented by the Ethereum logo which will open up the Remix deployment tool.&#x20;

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2FrDzmSBaAwJ1Bq789lgVl%2FScreenshot%20from%202023-05-21%2012-08-09.png?alt=media&#x26;token=31b4d77c-df4d-45ea-a858-13a560b6f5e1" alt=""><figcaption><p>Remix Deployment Tab</p></figcaption></figure>

Assuming **HelloWorld** compiled correctly, this is the tool that we will use to deploy **HelloWorld**. Make sure to select **HelloWorld** as the contract to deploy in the Deployer tool. To deploy **HelloWorld**, simply click the *Deploy* button. For this lesson, you will be deploying to a local blockchain that Remix provides us with (Remix VM).&#x20;

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2FFqttNX3DKeqJ05CO6Bag%2FScreenshot%20from%202023-05-21%2012-12-38.png?alt=media&#x26;token=b363481b-80e2-4acf-a999-d1660f7b60ea" alt=""><figcaption><p>HelloWorld Deployed</p></figcaption></figure>

Congratulations, you have deployed your first smart contract!

## Interacting With Your First Contract

Now that **HelloWorld** lives on your local blockchain, you can use Remix to interact with **HelloWorld**! We will be calling the *print()* function via Remix. Focusing on the Deployer tool, you will see that under the *Deployed Contracts* section, our **HelloWorld** contract has its own tab. Clicking on the tab, you will see the following:&#x20;

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2Fw74fVpw7QbGpyuZtQhOg%2FScreenshot%20from%202023-05-21%2012-20-53.png?alt=media&#x26;token=177d0bfe-2810-4e2c-bfd5-8a0d158f0e9c" alt=""><figcaption><p>HelloWorld Tab</p></figcaption></figure>

Rather than having to write complicated code to call *print*, Remix allows us to call the function simply by clicking a button. Click on the *print* button and you will see the following:

<figure><img src="https://1721697361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWHVPQr823FtMTmO54igG%2Fuploads%2FuJXqOUwhsetsvfIffteF%2FScreenshot%20from%202023-05-21%2012-23-51.png?alt=media&#x26;token=eba2074c-5fd8-42da-b338-fc8aab7ad084" alt=""><figcaption><p>Calling print</p></figcaption></figure>

Congratulations, you have interacted with your first smart contract!

## Sources

Remix Documenation: <https://remix-ide.readthedocs.io/en/latest/index.html>
