# Smart Contract Deployment

Here are the step-by-step instructions to deploy a smart contract on the Avalanche L1 Demo Network using Remix:

#### <mark style="color:green;">Deployment Steps-</mark>

#### 🧑‍💻 **Step 1: Connect MetaMask to the Avalanche L1 Demo Network**

Follow this link to complete this step - [Adding to MetaMask](https://docs.cogitus.io/demo-network/connect-to-metamask)

#### 🧱 **Step 2: Open Remix and Write Your Contract**

1. Visit Remix IDE.
2. In the File Explorer, create a new Solidity file (e.g., `MyContract.sol`).
3. Write or paste your smart contract code.

#### 🔨 **Step 3: Compile the Contract**

1. Go to the Solidity Compiler tab on the left.
2. Select the appropriate compiler version for your code.
3. Click Compile.

#### 🚀 **Step 4: Deploy Using Injected Web3 (MetaMask)**

1. Go to the **Deploy & Run Transactions** tab.
2. Under **Environment**, select **Injected Provider - MetaMask**.
   * MetaMask will prompt you to connect — approve it.
   * Ensure it's connected to the Avalanche L1 Demo Network.
3. Select the contract from the dropdown.
4. If your contract has constructor parameters, input them.
5. Click Deploy.
6. MetaMask will pop up to confirm the transaction, approve it.

#### 📍 **Step 5: Confirm Deployment**

* Once the transaction is mined, the contract will appear under Deployed Contracts in Remix.
* You can interact with the contract directly from here.
* Optionally, copy the contract address and check it on the [Tracehawk](https://explorer-cogitusdemonetwork.zeeve.net/) to verify.

#### <mark style="color:green;">Verify & publish contract via Explorer-</mark>

#### 🛠️ **Step 1:** Verify & publish contract via Explorer

1. Click on Others, and then choose **Verify Contract.**
2. Click it to open the verification form.

#### 🧾 **Step 2: Fill in Verification Details**

1. **Contract Address**:&#x20;
2. **Contract License Dropdown:** Choose MIT License
3. **Compiler Type**: Select **Solidity (Single File)** or **Multi-part** depending on your project.
4. **Compiler Version**: Must match what was used in Remix  (e.g., `0.8.22`).
5. **Optimization Enabled:** Yes / No (**indicates if optimization was enabled during contract deployment**)
6. **Enter Solidity Source Code** in the provided text box.

#### 💾 **Step 3: Submit**

* Click **"Verify and Publish"**.
* The explorer will compile and compare the code with the on-chain bytecode.

#### 🎉 **Step 4: Verification Complete**

Once verified:

* The contract’s source will be publicly visible on the explorer.
* A ✅ Verified badge will appear.
* You can now read/write to your contract directly from the explorer.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cogitus.io/demo-network/smart-contract-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
