# Deploying a Contract Using Remix-IDE

Remix Project is a development tool that provides developers with the necessary technologies and features for the entire smart contract development process. It also serves as an educational platform for learning and experimenting with Ethereum.

{% hint style="info" %}
When deploying a contract on any blockchain, the native token of that chain must be used to pay for deployment gas fees. This applies to dKargo Chain as well. Before deploying on the dKargo testnet (Warehouse), developers can obtain $DKA testnet tokens via the faucet.\
\
Remix interacts with the blockchain using the wallet registered in [MetaMask](https://docs.dkargo.io/docs2-eng/wallet-setup/creating-a-wallet).
{% endhint %}

## STEP 1 - Getting Started with Remix

1. Access [Remix](https://remix.ethereum.org/) and navigate to File Explorer, then click ≡ (menu icon). Select \[ + Create Blank ] to create a new Workspace.
2. Create a new file named <mark style="color:blue;">`counter.sol`</mark> and enter the contract code or use the provided sample code.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
 
contract Counter {
    uint256 public number;
 
    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }
 
    function increment() public {
        number++;
    }
}
```

3. Go to the **\[ Solidity Compile ]** sidebar option and select <mark style="color:blue;">`counter.sol`</mark> to compile the contract.

## STEP 2 - Deploying the Contract

1. Navigate to the **\[ Deploy & Run Transactions ]** sidebar option.
2. Change the ENVIRONMENT dropdown to "Injected Provider - MetaMask".
3. In MetaMask, click **\[ Connect ]** to grant Remix access.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/r9y17tJqAkgNOs86G8M9/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B31.png" alt="" width="563"><figcaption></figcaption></figure>

4. Once MetaMask is connected, click the **\[ Deploy ]** button to deploy the contract.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/dkxN3bkQ254yxGPxxt06/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B32.png" alt="" width="563"><figcaption></figcaption></figure>

5. The deployed contract can be verified in[ the Verified Contracts section of dScanner](https://warehouse.dscanner.io/contracts-verified).&#x20;

## STEP 3 - Interacting with the Contract

1. After deploying the contract, interaction is available in the bottom-left tab of Remix.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/W2XzwUeFfdumlXt9bqqn/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B33.png" alt="" width="563"><figcaption></figcaption></figure>

2. Click **\[ number ]** to retrieve the stored number in the contract. The default value after deployment is **0**.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/2N15yNDIyfjE5ImI4vNu/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B34.png" alt="" width="279"><figcaption></figcaption></figure>

3. Click **\[ increment ]** to send a transaction that increases the number by +1. Confirm the transaction in MetaMask, which will then be sent to the dKargo Chain.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/or51Y7yP9VSRkuicWraq/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B35.png" alt="" width="563"><figcaption></figcaption></figure>

4. Click **\[ number ]** again to verify that the stored number has increased by **1**.

<figure><img src="https://content.gitbook.com/content/im6M65ZKMXUcKE8zSRGC/blobs/1R05QMxNxaeIUopVg9Tm/%E1%84%85%E1%85%B5%E1%84%86%E1%85%B5%E1%86%A8%E1%84%89%E1%85%B36.png" alt="" width="280"><figcaption></figcaption></figure>
