# Write Smart Contract

***

### Configure Hardhat for SupraEVM

Update `hardhat.config.js` to define the **SupraEVM network**, specifying the RPC URL, chain ID, and private key to enable seamless contract deployment and interaction.

* Change your hardhat.config.js file and add the following configuration:

```
require("@nomicfoundation/hardhat-toolbox");

module.exports = {
  solidity: "0.8.4",
  networks: {
    supra: {
      url: "https://rpc-evmstaging.supra.com/rpc/v1/eth",
      chainId: 119,
      accounts: [`0xPRIVATE_KEY`]
    }
  }
};

```

### Create a Smart Contract File

Define a **Solidity smart contract** in `SimpleStorage.sol` to store and retrieve a `uint256` value, providing a basic example for deployment on **SupraEVM**.

* Create a `SimpleStorage.sol` File

```
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract SimpleStorage {
    uint256 public storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}

```

### Create a Deployment Script

Write a **deployment script** in `deploy.js` to automate smart contract deployment on **SupraEVM** using **Hardhat**, enabling seamless contract execution and interaction.

* Create a `scripts` directory and a file named `deploy.js`:

```
const { ethers } = require("hardhat");

async function main() {
    const [deployer] = await ethers.getSigners();
    console.log("Deploying contracts with the account:", deployer.address);

    const SimpleStorage = await ethers.getContractFactory("SimpleStorage");
    
    console.log("Deploying SimpleStorage...");
    const simpleStorage = await SimpleStorage.deploy();

    // Directly access the target property
    console.log("Contract Address from target property:", simpleStorage.target);
}

main().catch((error) => {
    console.error("Error:", error);
    process.exitCode = 1;
});

```


---

# 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://supraoracles.gitbook.io/supra/network/evm/getting-started/hardhat/write-smart-contract.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.
