# Deploy with Remix

## Getting started with Remix IDE

To start building a smart contract, click on **New File** and name it `HelloWorld.sol`.<br>

<figure><img src="https://13370880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkSNqP0Gff8h2fXgaMlEL%2Fuploads%2FzuUsoWex0aGEeSXobTDy%2FScreen%20Shot%202023-10-03%20at%2009.36.11.png?alt=media&#x26;token=f56a03e7-a6ce-4e6e-bf0f-2989277c17c5" alt=""><figcaption></figcaption></figure>

## Smart contract

Copy and paste the Smart Contract code provided below into the newly created `HelloWorld.sol` file.

```solidity
// Specifies that the source code is for a version
// of Solidity greater than 0.5.10
pragma solidity ^0.5.10;

// A contract is a collection of functions and data (its state)
// that resides at a specific address on the Ethereum blockchain.
contract HelloWorld {

    // The keyword "public" makes variables accessible from outside a contract
    // and creates a function that other contracts or SDKs can call to access the value
    string public message;

    // A special function only run during the creation of the contract
    constructor(string memory initMessage) public {
        // Takes a string value and stores the value in the memory data storage area,
        // setting `message` to that value
        message = initMessage;
    }

    // A publicly accessible function that takes a string as a parameter
    // and updates `message`
    function update(string memory newMessage) public {
        message = newMessage;
    }
}
```

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

* Go to the **Solidity Compiler** tab (below the search button)
* Select compiler version to **0.5.10**
* Now, compile `HelloWorld.sol`
* After successful compilation, it will show a green tick mark on the **Compiler** tab button

<figure><img src="https://13370880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkSNqP0Gff8h2fXgaMlEL%2Fuploads%2FDgPZaD5mVSaGYn6E8HaJ%2FScreen%20Shot%202023-10-03%20at%2009.38.16.png?alt=media&#x26;token=730d6397-fb82-4028-a443-73fe9b7b2c94" alt="" width="371"><figcaption></figcaption></figure>

### Network configuration <a href="#deploying-to-the-mumbai-testnet" id="deploying-to-the-mumbai-testnet"></a>

To deploy to the U2U Solaris mainnet or U2U Nebulas testnet with Remix, we have to connect to the Web3 world which can be accomplished by using any of the services like Metamask, Brave, Portis, etc. We will be using MetaMask in this tutorial. Please follow this [guide to set up a MetaMask Account](https://docs.u2u.xyz/services/wallets/metamask).

### U2U Solaris Mainnet

* Open Metamask. Click on the network dropdown menu (set to **Ethereum Mainnet** by default) and click on the **Add Network** button and fill in network info:
  * **Network Name:** Solaris Mainnet
    * **New RPC URL:** <https://rpc-mainnet.u2u.xyz>
    * **ChainID:** 39
    * **Symbol:** U2U
    * **Block Explorer URL:** <https://u2uscan.xyz>
* Go ahead and click **Save**
* Copy your wallet address from MetaMask by clicking over your account name
* Make sure you have enough U2U token on U2U Solaris mainnet. You can head over to [U2OTC.com](https://u2otc.com/vi/trading/sell/U2USM) to buy some U2U token.
* Finally, to deploy to U2U Solaris, refer to the instructions in the "Remix deployment" section below.

### U2U Nebulas Testnet <a href="#deploying-to-the-mumbai-testnet" id="deploying-to-the-mumbai-testnet"></a>

* Open Metamask. Click on the network dropdown menu (set to **Ethereum Mainnet** by default) and click on the **Add Network** button and fill in network info:
  * **Network Name:** Nebulas Testnet
  * **New RPC URL:** <https://rpc-nebulas-testnet.u2u.xyz>
  * **ChainID:** 2484
  * **Symbol:** U2U
  * **Block Explorer URL:** <https://testnet.u2uscan.xyz>
* Go ahead and click **Save**
* Copy your wallet address from MetaMask by clicking over your account name
* Head over to [Faucet](https://faucet.uniultra.xyz) and request test U2U - you will need this to pay for gas on the U2U network. Select **U2U Nebulas Testnet** as the network and **U2U Token** as the token in the faucet.
* Finally, to deploy to U2U Nebulas, refer to the instructions in the "Remix deployment" section below.

### Remix Deployment <a href="#remix-deployment" id="remix-deployment"></a>

In both U2U Testnet and Mainnet, you do the below to deploy your smart contract using Remix. The below step will use the connect MetaMask API keys you set up in the previous steps.

* Select **Injected Provider** MetaMask in the **Environment** dropdown and your contract

<figure><img src="https://13370880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkSNqP0Gff8h2fXgaMlEL%2Fuploads%2FHeEpbRMFNCqtgt2KPiYm%2FScreen%20Shot%202023-10-03%20at%2009.39.24.png?alt=media&#x26;token=2ca2cebc-ad3b-4137-9947-d83dc9661e78" alt="" width="371"><figcaption></figcaption></figure>

* Accept the **Connect** request received in MetaMask. If the popup doesn't open by default, you can also try manually launching the MetaMask extension
* Once MetaMask is connected to Remix, the `Deploy` transaction would generate another MetaMask popup that requires transaction confirmation. Simply confirm the transaction!

<figure><img src="https://13370880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkSNqP0Gff8h2fXgaMlEL%2Fuploads%2FhRFBFlmjkkqhxeEN1XnS%2Fimage.png?alt=media&#x26;token=031c239f-bce1-4fb3-86a6-d4f28694aad2" alt=""><figcaption></figcaption></figure>

* Voila!!! Your contract has been deployed.

<figure><img src="https://13370880-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkSNqP0Gff8h2fXgaMlEL%2Fuploads%2FBuX5DHMTMrlNS95DSF9M%2FScreen%20Shot%202023-10-03%20at%2009.43.31.png?alt=media&#x26;token=7b741914-17fa-4f20-be54-1a56f342c2f3" alt="" width="375"><figcaption></figcaption></figure>
