# 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 **Ancient8 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 **Ancient8 Mainnet** as the network rather than **Ancient8 Testnet**.
{% endhint %}

If you're already familiar with Remix, you probably want to jump down to [here](#prepare-for-deployment).

### Objectives[​](https://docs.base.org/guides/deploy-with-remix#objectives) <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 Ancient8 Testnet and interact with it in Etherscan

### Remix Window Overview[​](https://docs.base.org/guides/deploy-with-remix#remix-window-overview) <a href="#remix-window-overview" id="remix-window-overview"></a>

Begin by opening a browser window and navigating to \[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://docs.base.org/guides/deploy-with-remix#editor-pane) <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://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2Fn2EXt2LiB7i4TdZS2RVp%2Fimage.png?alt=media&#x26;token=9e488781-631e-4e99-be34-04aba09a7174" 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 underlines. 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://docs.base.org/guides/deploy-with-remix#terminaloutput)

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

![Remix Terminal](https://docs.base.org/assets/images/remix-terminal-59afbcb6f80c3eb12d7da4183bfca293.png)

You'll primarily use this panel to observe transaction logs from your smart contracts. It's also one way to access Remix's powerful debugging tools.

#### Left Panel[​](https://docs.base.org/guides/deploy-with-remix#left-panel) <a href="#left-panel" id="left-panel"></a>

As with many other editors, the left panel in Remix has a number of vertical tabs that allow you to switch between different tools and functions. You can explore the files in your current workspace, create and switch between workspaces, search your code, and access a number of plugins.

### Plugins[​](https://docs.base.org/guides/deploy-with-remix#plugins)

Most of the features in Remix are plugins and the ones you'll use the most are active by default. You can view and manage plugins by clicking the plug button in the lower-left corner, right above the settings gear. You can turn them off and on by clicking activate/deactivate, and some, such as the *Debug* plugin will be automatically activated through other parts of the editor.

#### Solidity Compiler[​](https://docs.base.org/guides/deploy-with-remix#solidity-compiler) <a href="#solidity-compiler" id="solidity-compiler"></a>

The first default plugin (after the search function) is the *Solidity Compiler*. Be sure to check the `Auto compile` option. Smart contracts are almost always in very small files, so this shouldn't ever cause a performance problem while editing code.

The `Compile and Run script` button in this plugin is a little misleading. This is **not** how you will usually run your contract through testing. You can click the `I` button for more information on this feature.

Finally, if you have errors in your contracts, the complete text for each error will appear at the bottom of the pane. Try it out by introducing some typos to `1_Storage.sol`.

#### Deploy & Run Transactions[​](https://docs.base.org/guides/deploy-with-remix#deploy--run-transactions) <a href="#deploy--run-transactions" id="deploy--run-transactions"></a>

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="warning" %}
**CAUTION**\
There are a couple 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://docs.base.org/guides/deploy-with-remix#prepare-for-deployment) <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://docs.base.org/guides/deploy-with-remix#set-up-a-wallet) <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!

{% hint style="danger" %}
**DANGER**

It is very dangerous to use a wallet with valuable assets for development. You could easily write code with a bug that transfers the wrong amount of the wrong token to the wrong address. Transactions cannot be reversed once sent!

Be safe and use separate wallets for separate purposes.
{% endhint %}

First, add the [Metamask](https://metamask.io/) wallet to your browser, and set up 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.

#### Add the Ancient8 Testnet to your Wallet[​](https://docs.base.org/guides/deploy-with-remix#add-the-base-goerli-network-to-your-wallet) <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 Ancient8 Testnet. You can fund your wallet with Ancient8 Testnet Sepolia ETH using the following options:

* [Bridging Sepolia ETH from Ethereum Sepolia ](#bridging-sepolia-eth-from-ethereum-sepolia)
* Ancient8 Testnet Faucet: Coming soon

#### Bridging Sepolia ETH from Ethereum Sepolia

1. Get Sepolia ETH via [Sepolia Faucets](https://sepoliafaucet.com) to your wallet address
2. Connect wallet to [Ancient8 Testnet Bridge](https://bridgev2-testnet.ancient8.gg/)
3. Deposit **Sepolia ETH** to **Ancient8 Testnet**

<div align="left"><figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FFlC5DIQCTbryDAaMGfvU%2FScreenshot%202023-08-15%20at%2009.58.43.png?alt=media&#x26;token=4d399bcc-9cac-4ef1-a929-0130f839501f" alt="" width="375"><figcaption></figcaption></figure></div>

#### Get Testnet Ether[​](https://docs.base.org/guides/deploy-with-remix#get-testnet-ether) <a href="#get-testnet-ether" id="get-testnet-ether"></a>

Testnet tokens have no real value, but the supply is not unlimited. You can use a faucet to get a small amount of Sepolia Ether to pay gas fees for testing. Most faucets allow you to ask for a small amount each day, and some won't send you more if your balance is too high.

You can find many faucets by searching, and it's good to keep a few bookmarked because they have a tendency to go down from time to time. Faucet providers are constantly combating bad actors and sometimes need to disable their faucets while doing so.

{% hint style="info" %}
INFO

Remember to bridge the Ethereum (Layer 1) Sepolia Ether to Ancient8 Testnet via our [bridge](https://bridge-testnet.ancient8.gg/).
{% endhint %}

Once you have Ancient8 Testnet Sepolia Ether, you can view your balance by selecting the Ancient8 Testnet from the network dropdown in Metamask.&#x20;

### Deploying to Testnet[​](https://docs.base.org/guides/deploy-with-remix#deploying-to-testnet)

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

#### Selecting the Environment[​](https://docs.base.org/guides/deploy-with-remix#selecting-the-environment) <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.

<div align="left"><figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FrwtmLPIZE18OgNsrYV27%2FScreenshot%202023-08-14%20at%2022.59.57.png?alt=media&#x26;token=bc0d6f21-0431-409d-b521-15636e9a62bd" alt="" width="301"><figcaption></figcaption></figure></div>

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.

<div align="left"><figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FGhrRh5DKB7OjBgr26R1U%2FScreenshot%202023-08-14%20at%2023.03.20.png?alt=media&#x26;token=457f1ecc-4369-47f0-9d16-58e717bb713a" alt="" width="297"><figcaption></figcaption></figure></div>

For **Ancient8 Testnet**, you should see `Custom (2863311531) network`&#x20;

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

### Deploy the Contract[​](https://docs.base.org/guides/deploy-with-remix#deploy-the-contract)

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

<div align="left"><figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FPGN4nCsMmOoKeqHyKIV2%2FScreenshot%202023-08-14%20at%2023.17.23.png?alt=media&#x26;token=ad21eb1d-b387-4f49-9746-1b425bc6004d" alt="" width="358"><figcaption></figcaption></figure></div>

{% hint style="danger" %}
**DANGER**

Always carefully review all transactions, confirming the transaction cost, assets transferred, and network. As a developer, you'll get used to approving transactions regularly. Do the best you can to avoid getting into the habit of clicking *Confirm* without reviewing the transaction carefully. If you feel pressured to *Confirm* before you run out of time, it is almost certainly a scam.
{% endhint %}

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

### Verify the Contract[​](https://docs.base.org/guides/deploy-with-remix#verify-the-contract)

{% hint style="info" %}
**INFO**

You don't need to verify the contract if you've deployed one identical to a contract that has already been verified.
{% endhint %}

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.

<div align="left"><figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FTBUrnpTMeU1grN2iXX9C%2Fverify-and-publish-937d8f1fd6626a36862dd12e8946995f.png?alt=media&#x26;token=5662de25-ab56-424e-8687-0f99f769651b" alt=""><figcaption></figcaption></figure></div>

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.18+commit.87f61d96*.

For *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.

<figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FNuBuOkqswcUzN05349Dp%2FScreenshot%202023-08-14%20at%2023.30.35.png?alt=media&#x26;token=93272b92-6f69-4ced-8d9b-c96286e1adeb" alt=""><figcaption></figcaption></figure>

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

#### Interact with the Contract[​](https://docs.base.org/guides/deploy-with-remix#interact-with-the-contract) <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://docs.base.org/guides/deploy-with-remix#conclusion)

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!
