# Using Remix

Hello World style starter project. Deploys a smart contract with a message, and renders it in the front-end. You can change the message using the interact panel!

This dapp implements a "Hello World" style application that echoes a message passed to the contract to the front end. This tutorial is intended to be followed using the online IDE available at [Remix IDE](https://remix.ethereum.org/).

**Setting up** [**Remix IDE**](https://remix.ethereum.org/)

* **Remix IDE** is an online IDE to develop smart contracts.
* If you’re new to Remix, You’ll first need to activate two modules: **Solidity Compiler** and **Deploy & Run Transactions**.
* Search for '**Solidity Compiler**' and '**Deploy & Run Transactions**' plugins in the plugin tab in Remix.

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2FMubrkXCtcMAN7ixCiHyC%2Fimage.jfif?alt=media&#x26;token=ff4979bd-c065-455a-b35c-a8fe5541603a" alt=""><figcaption></figcaption></figure>

* Activate the two plugins

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2FuMbuR1F9Ag7ay2MrUv3T%2Fimage%20(1).jfif?alt=media&#x26;token=58ef0deb-57ae-496e-a452-db350292822b" alt=""><figcaption></figcaption></figure>

* Select **Solidity** Environment

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2Fi2fPluxoMDdAtEjbUMIu%2Fimage%20(3).avif?alt=media&#x26;token=39fef20e-54be-4fa4-97d9-ac0ccf39ef1a" alt=""><figcaption></figcaption></figure>

* Go to **File Explorers**, and Create a new file ![](https://ignitechain.gitbook.io/~gitbook/image?url=https:%2F%2Fdocs.polygon.technology%2Fimg%2Fhelloworld%2FScreenshot_2020-02-14_at_12.51.59_PM.png\&width=300\&dpr=4\&quality=100\&sign=0a4d78a6af2f100d2b9962c9b53a934f3681e28db468c77385625d102af14dec), Name it HelloIgnite.sol
* Copy/Paste the Smart contract below into the newly created file `HelloIgnite.sol`

#### **The smart contract** <a href="#the-smart-contract" id="the-smart-contract"></a>

Copy

```
Explainpragma solidity ^0.8.10
contract helloWorld { 

  string public hello = "Hello World!"
}
```

The first line, `pragma solidity ^0.8.10` specifies that the source code is for a Solidity version greater than 0.8.10. [Pragmas](https://solidity.readthedocs.io/en/latest/layout-of-source-files.html#pragma) are common instructions for compilers about how to treat the source code (e.g., pragma once).

#### Compile Smart Contract <a href="#compile-smart-contract" id="compile-smart-contract"></a>

* Go to Solidity Compiler.
* Select Compiler Version to 0.8.10.
* Now, Compile **`HelloCtex.sol`**

Now, We have to deploy our smart contract on **CTEX Chain** network. For that, we have to connect to web3 world, this can be done by using **Metamask**.

Please follow this tutorial to setup a **Metamask** Account.

* Open **Metamask** and select Add Network from the networks dropdown.

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2F63WuXlghy5neTd3bc2Uv%2Fimage%20(5).png?alt=media&#x26;token=f6a5163e-edf2-49ec-ab9b-547056872780" alt=""><figcaption></figcaption></figure>

* Put in a Network name - “CTEX Testnet”
* In URL field you can add the URL as <https://testnet-rpc.ctexscan.com>
* Enter the Chain ID: 72152

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2F9umJvZfY7aCp1GAlY7SY%2FUsing-Remix-Image-01.png?alt=media&#x26;token=5e10eeae-e360-4e12-9f26-8b0d5f2e7398" alt=""><figcaption></figcaption></figure>

* (Optional Fields) Symbol: "CTEX" and Block Explorer URL: "<https://testnet-rpc.ctexscan.com>["](https://mumbai.polygonscan.com/%22)
* Go ahead and click save
* Copy your address from Metamask

<figure><img src="broken-reference" alt=""><figcaption></figcaption></figure>

Head over to [CTEX **Faucet**](https://faucet.ctexscan.com/) and request test CTEX - you will need this pay for gas on **CTEX Chain**.

Now, let's Deploy the Smart Contract on **CTEX Chain**:

* Select Injected Web3 in the Environment dropdown and your contract

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2FWTm2C0duMyiryNfF8d6T%2FUsing-Remix-Image-03.png?alt=media&#x26;token=2afe6b7d-d355-414a-aded-fa65be9f938a" alt=""><figcaption></figcaption></figure>

* Accept the Connection Request!

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2FDs8zJmsAu605oPC6JHsa%2Fimage%20(6).png?alt=media&#x26;token=711c2e21-c39a-4ac8-b220-ce825a08bc52" alt=""><figcaption></figcaption></figure>

* Once **Metamask** is connected to Remix, the ‘Deploy’ transaction would generate another **Metamask** popup that requires transaction confirmation.

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2F72jy6Rajg3yhBmTsFH0p%2FUsing-Remix-Image-04.png?alt=media&#x26;token=97dc8df3-63f9-4e24-9532-15d4319e49d2" alt=""><figcaption></figcaption></figure>

**Congratulations!** You have successfully deployed **HelloIgnite** Smart Contract. Now you can interact with the Smart Contract.

Check the deployment status here: [.](https://test.ignitescan.com/)<https://testnet-rpc.ctexscan.com>

<figure><img src="https://1586350757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQShakAkJI9WvYz6HjKl0%2Fuploads%2F3hyFv49LLuwsVydzRedo%2FUsing-Remix-Image-05%20(1).png?alt=media&#x26;token=04426b22-6282-4b98-a765-7bb5ef3357c6" alt=""><figcaption></figcaption></figure>

#### **Verifying your Contracts on IgniteScan** <a href="#verifying-your-contracts-on-ignitescan" id="verifying-your-contracts-on-ignitescan"></a>

The first and foremost step is to flatten the solidity contract into a single file.

**Flatten your solidity contract**

* Install [truffle-flattener](https://github.com/nomiclabs/truffle-flattener) or [sol-merger](https://github.com/RyuuGan/sol-merger)
* Flatten using command

`sol-merger \"./contracts/*.sol\" ./build`

**Verifying Contract on CTEXscan**

* Navigate to your contract's <https://testnet-rpc.ctexscan.com> page and then click verify and publish

* Select `Solidity (Single File)` in compiler type

* Select appropriate compiler version

* Choose the license type of your contract

Onto the next section, paste your flattened contract here.

If you had enabled optimization then adjust the `optimization` section accordingly.

Constructor arguments should have been filled in automatically, if not, they can be retrieved from the trailing bytes of the deployment transaction, they resemble something like `0000000000000000076172d1a6fa476172d1fb5f76172d178d61b04b0ecd319c`

If you have followed the process successfully, the contract would be verified.
