# Deploy & Run

The Deployment Module in Q-Remix IDE enables developers to **deploy**, **interact**, and **manage smart contracts** efficiently, both locally and on-chain. This module is crucial for testing contract behavior and pushing production-ready contracts to the blockchain.

#### Key Functionalities:

The Deployment section allows you to:

1. **Deploy Contracts**: Locally using a test VM or on blockchain networks via MetaMask
2. **Interact with Deployed Contracts**: Test and invoke smart contract functions
3. **Access Previously Deployed Contracts**: Use their addresses to continue interaction

You can access this module by clicking the **third icon on the far-left sidebar**.

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FgV5o2Xt5mBLbT2WdA61x%2Fimage.png?alt=media&#x26;token=65791e34-a5cf-48da-adc1-74d146ab9c27" alt=""><figcaption></figcaption></figure>

### Deploy & Run Interface Overview

There are three main sections in the ***deploy & run*** section&#x20;

1. **Environment**
2. **Account**
3. **Contract**

## 1. Environment

This section defines **where** your contract will be deployed. The current environments supported in Q-Remix IDE are:

**a. Q-Remix VM (Local Test Environment)**

* Powered by **Hardhat**.
* Simulates a local Ethereum environment.
* Automatically generates **20 test accounts**.
* Each account has **10,000 ETH** for simulation purposes.
* Persistent across browser refreshes (contract state is preserved).
* Resets to the original state if the browser tab is closed.

**b. Injected Provider - MetaMask**

* Connects your **MetaMask wallet** to the IDE.
* Supports deployment on:
  * Ethereum **Mainnet**
  * Various **Testnets** (e.g., Goerli, Sepolia)
* Requires MetaMask extension and authentication.
* After successful login, the selected MetaMask account appears in the **Accounts tab**.

> Make sure MetaMask is unlocked and the correct network is selected before proceeding.

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2F1wWVb8i7FdT7OgzghTvz%2Fimage.png?alt=media&#x26;token=409114db-1c15-4cf6-b896-353eb1586ed2" alt=""><figcaption></figcaption></figure>

For now Q-Remix IDE supports the first two options

1. **Q-Remix VM:** Uses Hardhat to generate 10 test addresses with 10,000 ETHs in each address. The user can switch the addresses anytime and test or deploy with them. The states of each of the contracts remain the same even after refreshing the entire page. This ensures that no progress made is lost during the session. However, if the session is closed all the accounts are reset to have the original 10,000 ETHs.
2. **Injected Provider MetaMask:** This connects the wallet metamask with the remix IDE allowing teh contracts to be deployed either Mainnet or in the Testnet.<br>

   <figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FBhVphHEb7dlBGTbTERFC%2Fimage.png?alt=media&#x26;token=140e45a1-6d37-4586-ad31-c0cf0e266bd5" alt=""><figcaption></figcaption></figure>

After giving your MetaMask password, the selected address or account will be reflected in the Account section of the Deploy & Run&#x20;

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FMBvHl1zJJo9pAyY1YUDT%2Fimage.png?alt=media&#x26;token=e063f58f-55c4-46e8-9c4e-d8b224e92882" alt=""><figcaption></figcaption></figure>

## 2. Accounts

The **Accounts section** reflects the currently available accounts based on the selected environment.

**In Q-Remix VM:**

* Displays **20 pre-funded test accounts**
* Users can switch between accounts using the dropdown
* Each account retains its state until the browser tab is closed

**In MetaMask (Injected Provider):**

* Displays the **connected MetaMask address**
* Reflects real token balances and actual network info

You can choose any available account for deploying or interacting with contracts.<br>

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FGdOrr9FjjwIQhrP4vTlh%2Fimage.png?alt=media&#x26;token=c04a5f65-6c3f-4489-82ad-cdd93317b123" alt=""><figcaption></figcaption></figure>

For deploying the selected contract one can use any of the accounts. In the above example one contract has been deployed using the first account.

## 3. Contracts&#x20;

This section lists:

* The **most recently compiled contract**
* All previously compiled contracts within the session

**To Deploy a Contract:**

1. Select the compiled contract from the dropdown.
2. Review the contract and verify any constructor parameters, if applicable.
3. Click **Deploy**.

Upon successful deployment:

* The contract will appear in the **Deployed Contracts list** below.
* Deployment logs (address, gas usage, etc.) are shown in the terminal.
* Each contract instance includes:
  * Public and external function buttons for interaction
  * Options to copy the contract address
  * Collapse/expand details

> Always **review your code** and **verify constructor arguments** before deploying on a live network.

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FLgOkcejlJdz4kersHlIW%2Fimage.png?alt=media&#x26;token=5ee1506a-f834-4106-b3dc-5e999a6d898e" alt=""><figcaption></figcaption></figure>

One must review the code or understand the code before completely deploying it on the chain.

Once the contracts has been selected, clicking on the deploy button would deploy the contract on the said chain or network. The details of the deployment including the contract address would be shown on the terminal&#x20;

<figure><img src="https://3633094706-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fj7rwyc4EeGqNoC2Ji4bS%2Fuploads%2FDDTMtNbNyT0X7itvJza3%2Fimage.png?alt=media&#x26;token=08d7600d-1f38-4d80-8d66-4a416de4e9fe" alt=""><figcaption></figcaption></figure>

### Interacting with Deployed Contracts

Once deployed, contracts can be interacted with directly from the Q-Remix interface:

* Input fields are automatically created for each public/external function
* Clickable buttons allow calling `view`, `pure`, `payable`, or state-changing functions
* All interactions and return values are shown in the terminal output

> This is a crucial step in debugging and testing your smart contract logic in a real-world simulation.

### Best Practices

* Use the **Q-Remix VM** for early development and rapid iteration.
* Switch to **MetaMask** when testing contract deployment on testnets.
* Always **compile your contract** before attempting deployment.
* Keep a copy of your **contract address** after deployment for reference or frontend integration.
