# Using Remix

Remix is the one of the commonly used development environments for smart contracts on Ethereum. In this doc, dapp developers will learn about how to kick off their deployment of smart contracts. A “Hello World” tutorial is also included.

## IDE Setting

**Remix version**：0.24.1

Open the [remix](https://remix.ethereum.org/), an online IDE for developing and deploying Solidity contracts.

[Solidity ](https://docs.soliditylang.org/en/v0.8.15/)is a contract-oriented, high-level programming language created for smart contracts. The language is influenced by C++, Python, and Javascript languages and is designed to run on the Ethereum Virtual Machine ([EVM](https://ethereum.org/en/developers/docs/evm/)).

If you are using Remix for the first time, follow these steps to activate Remix:

#### Step 1&#x20;

Open remix and select “Solidity” in the featured plugins to activate the editing interface.

![](https://lh5.googleusercontent.com/eKkJ5Spwf2ikggvfNprVouu03gxberdlnFfmArAdJ0eA_VPS2CSY3Ga_N2-_I5m4Z6fEY08t48RXjRM9o9P5_cTeGTSB1R2d3HbJaoQMlU9wY5b2uTGN9Vya9HAOWPK_iDp1vQ1pQ9MsmwJEQA2iaZQ)

#### Step 2&#x20;

Find and click on “file explorers”, create a new file or folder for yourself.

<div align="left"><img src="https://lh3.googleusercontent.com/5t5oXZ9ud6kVMoNAJ9CvnbxrzQEauqjfvGIVNlq35UvHK59YBT3npPp7QitoGmOVJ6wnyx0FV629CoyvVr8Gs987u2zbzLeriDFYGAOVO_kXSn8oNF3DTkfl4aUyI30KUtma3yAQahlV6ar48P9o-iw" alt=""></div>

#### Step 3&#x20;

Find the “solidity compiler”, click the "compile" button, and the .sol file will be compiled and checked for errors. Fix all errors, you can proceed to the next step after the compilation is successful.

<div align="left"><img src="https://lh3.googleusercontent.com/g7Isze6quNekbHG1cCso1iiz2pi4hovuPuP0XwvAaZoqLWeGnBQ-DWGDDNSsZ2fDr5BWKSpkq6r6ohv5RK3rUyD0KOgRkt6ymQsy6T2X6Ik1KvFKB0f9xSTdUery1HlZfNUpD85kqaG8Onksa6OqJf4" alt=""></div>

&#x20;“Solidity unit testing” is also a good option, if the smart contract in solidity needs to be debugged

<div align="left"><img src="https://lh6.googleusercontent.com/K9-WzmKemucDVOyc7YdVgnOvLCknWn04Yldw9FGyrGWkvn66iGI63V3RCTBlR223xe3_6I-ynnlqysSnPWtPBgjsCgCDti0Dcxg4ocJoKVzfgcAp9SJypAFHgDN6kykRKkfMzizsG9m0favDD0VbsA4" alt=""></div>

Step 4 To deploy the .sol file on the blockchain as a smart contract, find the "Deploy & Runtransactions" page and click the "Deploy" button.

<div align="left"><img src="https://lh4.googleusercontent.com/knlCsyAdG6v5oJWaxwe8SGkQ5RNwr3S6JSGHFxZyYhHDf8DorqogGUr6A9R4TSZUyAHC_im0uLxf0plto6eKilu5zDinAxrA2b-xBQb3l_yDEKZUXvaFD10o4CfPF1dxZo0VjrEcC8OR0vvXBIrH0DQ" alt=""></div>



## **Remix Instance**

Open remix, find and click on “file explorers”, create a new file or Folder for yourself, and start with the same steps you usually do in other IDEs. Copy the code below, paste it into a file in FILE EXPLORERS and name it “helloWorld”.

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract HelloWorld {
  // constructor() public {
  // }

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

{% hint style="info" %}
**Note**:&#x20;

* It contains the solidity version number, and the first line indicates that the source file uses a solidity version between 0.4.22 and 0.9.0. ‎&#x20;
* The constructor class is a class in object-oriented programming languages ​​such as Java and Typescript. It needs to be called when the instance is initial .&#x20;
* The function returns the string declared with the print method.The visibility is public, which means that everyone in the blockchain can access this string field, representing the data type returned by this function.
{% endhint %}

Now, compile helloWorld.sol and on success it will show![](https://lh4.googleusercontent.com/sjuXVkk3Bd88iaRRjtfFICw-gooWnSHnoIX0GRM5NHZKpnsQmVTaDiFD8wdwo5HUb9N_fV00iqAj_k34exJBpmw-IUEKwS3dZiOIAnfys5fnxqJ8RS0wHbfDyR0iPI5aL14VwWo2wBPcr2HE94SPSEs)



## **A Demo of Smart Contract Deployment on Rangers Protocol**

A more important step is the deployment of the smart contracts on Rangers Protocol. First of all, it is necessary to connect to the Web3 world and this can be done with any service such as Metamask, Brave, Portis,etc. We will use MetaMask as an example. If you don't have a MetaMask wallet account yet, you can refer to the MetaMask wallet setup doc.

#### Step 1&#x20;

In MetaMask, select the Rangers Protocol network, rangers mainnet for Rangers Protocol mainnet and robin for robin testnet. If rangers mainnet or robin is not present in the networks, please click on “add network”.

![rangers mainnet v&#x20;
Networks&#x20;
Ethereum Mainnet&#x20;
rangers mainnet&#x20;
Robin&#x20;
Ropsten Test Network&#x20;
Kovan Test Network&#x20;
Rinkeby Test Network&#x20;
Add Network&#x20;
Need help? Contact MetaMask Support](https://lh4.googleusercontent.com/EFH1ISrXqEnaBlwed97n7hmuC8WDMXjIp1j3225LZCqDZtEaE_1ETArmM6BfcH-ixpvtqZGJUv67081aDxBMvRMu8IiOEIbp8cp2GhXl_18QUJHfLz9PSr3cprq1_VB_C-TNvSQFeWE4uLDVMlfk3K0)

#### Step2

There are two methods to help you configure your network information inMetamask. The first method is automatic: enter[ RangersScan ](https://scan.rangersprotocol.com/)（or [robin-rangersscan](https://robin-rangersscan.rangersprotocol.com/)）, drag to the bottom of the page, then click the button and add rangers protocol（or robin） network configuration to metamask.

![](https://lh5.googleusercontent.com/MtoDWwr10Pw9ZtivUzndmlrauZvWvesSjxkRsq88nRvzXPBEW7RKL272p_VJwR7GQSNjnTSIP-BQeNqNli3gw5KKXehqLct4j6ckeOq4ZiaStf11bLlQWyj8cYYpgeLxLZ8LW43MkpcFt6t71bXy0TM)

The second method is to manually populate the MetaMask network configuration with the following information.

* Mainnet&#x20;
  * Network name is customized&#x20;
  * RPC URL : https://mainnet.rangersprotocol.com/api/jsonrpc&#x20;
  * Chain ID : 2025&#x20;
  * Currency Symbol : RPG&#x20;
  * Browser’s address: https://scan.rangersprotocol.com&#x20;
* Robin testnet&#x20;
  * Network name is customized&#x20;
  * RPC URL : https://robin.rangersprotocol.com/api/jsonrpc&#x20;
  * Chain ID : 9527&#x20;
  * Currency Symbol : RPG&#x20;
  * Browser’s address: https://robin-rangersscan.rangersprotocol.com/

![](https://lh4.googleusercontent.com/5KqYTQfdoGhMQven51mPmOYWoaH6Rs0czetTsoq020GNPX9BQpGUUR24dG9nMdNF4Uuf82uR7zyyOYFR9iPpf0uFjdlEwG7hRAsKFUZUifGEC0PdKTNyc6J9O5UJVeXzLWWLYPePmmmj6hZCNJeMg-A)

#### Step3&#x20;

Continue and click “Save”. In order for your contract to execute smoothly on the Rangers Protocol, you will also need to get RPG test tokens from Faucet. You will need this to pay for gas on Rangers Protocol.

#### Step 4&#x20;

Next, we can deploy the smart contract on the Rangers Protocol mainnet. In DEPLOY & RUN TRANSACTIONS, select “injected Web3” as the Environment and click Deploy.

<div align="left"><img src="https://lh4.googleusercontent.com/EO2OjTRa0KJjjRLlHviwzykg-fbujBxYAmfCZUWPAiXXkAh2-m1K9iJataXU8mfrF2FjG_7Z6pz1plfpBV1UX6cpG-AfutLkanxm-1uDaZ3Qxx7tjXNIjTYCxt0Fa4O1TX0M9e6kOwAz7HSQJizn9XA" alt=""></div>

#### Step 5&#x20;

After accepting the connection request, a pop-up window will appear with a MetaMask window to confirm the "deployment" of the transaction.

<div align="left"><img src="https://lh4.googleusercontent.com/Al68LosJ7Q-1pb9cmp8QFJPq-vevQr6j-PMxRL0HkyfCSQ8-HsNurP5XUJDj6rkw7IGZCEzt4pwHIZ58ZFl62vX4w7mCAl_iUsp1NU8S-OoSN4rU0EZNZ-lHSSTM0C4EBW-bZAUw3wItIZoSq538kY8" alt=""></div>

Once you click on “confirm”, you have successfully deployed the “helloworld” smart contract to the Rangers Protocol.

#### Step 6&#x20;

Verify the transaction and checking the status&#x20;

You can now interact with the smart contract. And you can check the deployment status in the [robin testnet scan](https://robin-rangersscan.rangersprotocol.com).

![](https://lh4.googleusercontent.com/zu_9_jvW69ceY1asayA2uhlH8EEQycdUChPyX8zf87c8mKd7EOAkHkuoV7DUeRWEfUAaGmIzSEWhB_eg9BHn0wDvpoPBGpOFiuc5U931WTKW8AGiFh92Twlf-kSWNi3PCaSe-PirkysHcLc9XUGCzW8)

Congratulations on completing your first remix deployment of a smart contract!

