# Using Remix

[Remix](https://remix.ethereum.org/) is an online IDE that you can use to rapidly develop and deploy smart contracts. If you're new to smart contracts, it's a great tool that lets you jump right in without needing to configure a local editor or struggle through environment configuration issues before getting started.

Remix contains a simulation of a blockchain that you can use to rapidly deploy and test your contracts. This simulation only exists within your browser, so you can't share it with others or use external tools or a front end to interact with it. However, you can also deploy to a variety of testnets from within Remix. Doing so will allow you to share your contract with others, at the cost of making it public.

In this article, we'll give you an overview of Remix, and show you how to deploy a contract to **RACE Sepolia** testnet.

{% hint style="info" %}
INFO

For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've selected RACE™ (mainnet) as the network rather than RACE™`Sepolia` (testnet).
{% endhint %}

***

## Objectives[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#objectives" id="objectives"></a>

By the end of this lesson you should be able to:

* List the features, pros, and cons of using Remix as an IDE
* Deploy and test the `Storage.sol` demo contract in Remix
* Use Remix to deploy a contract to the Race @ Sepolia testnet and interact with it in Etherscan

***

## Remix Window Overview[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#remix-window-overview" id="remix-window-overview"></a>

Begin by opening a browser window and navigating to \[[remix.ethereum.org](https://remix.ethereum.org)]. Click through the introductory tips, then review the editor. It is divided into three areas, which should look familiar.

### Editor Pane[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#editor-pane" id="editor-pane"></a>

The editor pane loads with the Remix home screen, which contains news, helpful links, and warnings about common scams. You can close the home tab if you'd like, then open `1_Storage.sol`, located inside the `contracts` folder of the `default_workspace`.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2FaBuVFcDN3BMVEtoqpnwq%2Fimage.png?alt=media&#x26;token=990aa959-94f9-4d40-9b07-b5ab92f31a9c" alt=""><figcaption></figcaption></figure>

You'll edit your code in the editor pane. It also has most of the features you're expecting, such as syntax and error highlighting. Note that in Remix, errors are not underlined. Instead, you'll see an❗to the left of the line number where the error is present.

At the top, you'll see a big green arrow similar to the *Run* button in other editors. In Solidity, this compiles your code, but it does not run it because you must first deploy your code to the simulated blockchain.

### Terminal/Output[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#terminaloutput" id="terminaloutput"></a>

Below the editor pane, you'll find the terminal.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2Fwv3hjugEDBIUVpC1JWPI%2Fimage.png?alt=media&#x26;token=3b2cf5d6-0454-4c3c-8a5a-3f49029fdea7" alt=""><figcaption></figcaption></figure>

The *Deploy & Run Transactions* plugin is what you'll use to deploy your contracts and then interact with them. At the top are controls to select which virtual machine to use, mock user wallets with test Ether, and a drop-down menu to select the contract you wish to deploy and test.

Fix any errors you introduced to `1_Storage.sol` and click the orange `Deploy` button. You'll see your contract appear below as *STORAGE AT \\\<address>*.

{% hint style="danger" %}
CAUTION

There are a couple of gotchas that can be very confusing with deploying contracts in Remix.

First, every time you hit the Deploy button, a new copy of your contract is deployed, but the previous deployments remain. Unless you are comparing or debugging between different versions of a contract, or deploying multiple contracts at once, you should click the `Trash` button to erase old deployments before deploying again.

Second, if your code will not compile, **clicking the deploy button will not generate an error!** Instead, the last compiled version will be deployed. Visually check and confirm that there are no errors indicated by a number in a red circle on top of the Compiler plugin.
{% endhint %}

***

## Prepare for Deployment[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#prepare-for-deployment" id="prepare-for-deployment"></a>

Testnets operate in a similar, **but not exactly the same** manner as the main networks they shadow. You need a wallet with the appropriate token to interact with them by deploying a new contract or calling functions in a deployed contract.

### Set Up a Wallet[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#set-up-a-wallet" id="set-up-a-wallet"></a>

If you already have a wallet set up **exclusively for development**, you can skip to the next section. Otherwise, now is the time to jump in!

First, add the [Metamask](https://metamask.io/) wallet to your browser, and [set up](https://www.youtube.com/watch?v=CZDgLG6jpgw) a new wallet. As a developer, you need to be doubly careful about the security of your wallet! Many dApps grant special powers to the wallet address that is the owner of the contract, such as allowing the withdrawal of all the Ether that customers have paid to the contract, or changing critical settings.

Once you've completed the wallet setup, enable developer settings and turn on testnets ([Metamask Settings](https://support.metamask.io/hc/en-us/articles/13946422437147-How-to-view-testnets-in-MetaMask).

### Add the Race Sepolia Network to your Wallet[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#add-the-base-goerli-network-to-your-wallet" id="add-the-base-goerli-network-to-your-wallet"></a>

For this guide, you will be deploying a contract to the RACE™ Sepolia test network. You can fund your wallet with RACE™ Sepolia ETH using the following options:

* [RACE Faucet](https://faucet.racetestnet.io/)
* [RACE Bridge](https://testnet-bridge.raceconomy.com/)

***

## Deploying to Testnet[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#deploying-to-testnet" id="deploying-to-testnet"></a>

Once you have testnet Ether, you can deploy the `Storage` contract!

### Selecting the Environment[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#selecting-the-environment" id="selecting-the-environment"></a>

Open the *Deploy & Run Transactions* tab. Under *Environment*, select *Injected Provider*. It will list *Metamask* or any other wallet you have activated here.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2FMlsKY5jypoqaMhaLgM1o%2Fimage.png?alt=media&#x26;token=a4e4b9c2-a225-49ae-beb2-ccfbaa172f9b" alt=""><figcaption></figcaption></figure>

The first time you do this, your wallet will ask you to confirm that you want to connect this dApp (Remix) to your wallet.

Once you are connected, you'll see the name of the network below the *Environment* dropdown.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2FKVsJ6gvh0WSpawVWR0Xp%2Fimage.png?alt=media&#x26;token=f3edc4ec-c2c0-4b62-a90b-0e9cd8468930" alt=""><figcaption></figcaption></figure>

For Race Sepolia, you should see `Custom (6806) network.`&#x20;

If you don't see the correct network, change the active network in your wallet.

### Deploy the Contract[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#deploy-the-contract" id="deploy-the-contract"></a>

Click the orange *Deploy* button. Because it costs gas to deploy a contract, you'll be asked to review and confirm a transaction.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2F2Kc7I1Vdxfdwnc4ym3XN%2Fclipboard-image%20(1).png?alt=media&#x26;token=743b9fa7-317a-4497-bf70-c4b6813cc196" alt="" width="320"><figcaption></figcaption></figure>

After you click the *Confirm* button, return to Remix and wait for the transaction to deploy. Copy its address and navigate to[ ](https://testnet.racescan.io/)<https://testnet.racescan.io/>.&#x20;

### Verify the Contract[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#verify-the-contract" id="verify-the-contract"></a>

You can interact with your deployed contract using Remix, the same as before, but it's also possible to interact with it through Etherscan. Paste your address in the search field to find it.

On this page, you can review the balance, information about, and all the transactions that have ever occurred with your contract.

Click the *Contract* tab in the main panel. If you've deployed a unique contract, at the top is a message asking you to *Verify and Publish* your contract source code.

<figure><img src="https://705138094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpjeaIfU5LwUGNhi07DgH%2Fuploads%2FTCcydzyObCgtuA5QM0wJ%2Fimage.png?alt=media&#x26;token=53fc3b7b-33b9-4e8a-b274-965b0095be30" alt=""><figcaption></figcaption></figure>

Verifying your contract maps the names of your functions and variables to the compiled byte code, which makes it possible to interact with the contract using a human-readable interface.

Click the link. Your contract address is already entered.

Under *Please select Compiler Type* choose \_Solidity (Single file)

For *Please Select Compiler Version* select the version matching the `pragma` at the top of your source file. Our examples are currently using *v0.8.17+commit.8df45f5f*.

*Please select Open Source License Type* pick the license that matches what you selected for your contract as the `SPDX-License-Identifier`. Pick *None* if you followed the Solidity-recommended practice of using `UNLICENSED`.

On the next page, copy and paste your source code in the window. Verify that you are not a robot, and click *Verify and Publish*. You should see a success message.

Click the linked address to your contract to return to the contract page. You'll now see your code!

### Interact with the Contract[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#interact-with-the-contract" id="interact-with-the-contract"></a>

You can now interact with your contract using Etherscan. Click the *Read Contract* button. Both of your functions will be listed here and can be tested using the web interface.

You won't have anything under *Write Contract* because this contract doesn't have any functions that save data to state.

***

## Conclusion[​](https://raceecosystem.gitbook.io/docs/guides/deploying-a-smart-contract/broken-reference) <a href="#conclusion" id="conclusion"></a>

You now have the power to put smart contracts on the blockchain! You've only deployed to a test network, but the process for real networks is exactly the same - just more expensive!
