Environment Setup

Prerequisite

In this section, we list items needs to be complete before start building.

Start the Sight environment locally.

First, clone the pre-prepared example code repository to your local machine.

git clone https://github.com/sight-ai/sight-oracle-contract-example-hardhat
cd sight-oracle-contract-example-hardhat
npm install
cp -f .env.example .env

In these commands, we will clone the Sight Oracle example code locally, install the necessary dependencies using npm, and finally use the cp command to copy the contents of .env.example to a new .env file.

npm run sight:stop ;npm run sight:start

Next, let’s run this command to start Sight environment. It may take 3-5 minutes to complete.

Note: If you are using Docker Desktop, please make sure you have logged in and opened the Docker application in advance.

It will launch a complete Sight environment locally with a single command, including an EVM chain, an FHEVM chain, a backend service, and a database. Once everything is set up, you should see information from the backend service monitoring events on the chain being printed, similar to the output shown in the image below.

Deployment Config

To deploy the contract on the Sepolia test network, you first need to obtain some Sepolia test tokens and the Sepolia RPC URL.

If you don’t have a Sepolia RPC yet, you can click here to require one.

Note: You can get the private key through MetaMask by going to Account Details => Export Private Key (Please use a test wallet, as leaking the private key poses a risk of account theft!).

PRIVATE_KEY=<YOUR_PRIVATE_KEY>
SEPOLIA_RPC_URL=<YOUR_SEPOLIA_RPC_URL>
SEPOLIA_ORACLE_CONTRACT_ADDRESS=0xC5ac65f17Ce781E9F325634b6218Dc75a5CF9abF

Add these environment variables to the .env file. SEPOLIA_ORACLE_CONTRACT_ADDRESS is the Oracle address we have deployed on the Sepolia test network.

networks: {
    //other network
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL!,
      accounts: [process.env.PRIVATE_KEY!],
      chainId: 11155111
    }
  },

Add the Sepolia network configuration information to the hardhat.config.ts file

Wallet Installation

  • Install Metamask

  • Create a account

  • Add Ethereum-Sepolia Testnet to your MetaMask wallet (Click here)

    Check the box for "Include Testnets," then click "Add to MetaMask."

Get testnet token

Request ETH token from faucet below:

Enter your account address in the input box below, then click Receive 0.05 Sepolia ETH button. After waiting for a while, you can check your balance in Metamask.

Next Steps

You now have completed Prerequisite items, choose one of the development framework to get started:

Note: For any questions or suggestions related to the tutorial, please submit issues to github issue page here

Last updated