Price Feed Contract Deployment

Deploying and testing your contract using Hardhat is a straightforward process, especially with the deployment scripts provided in the SEDA Starter Kit. We've implemented a deployment script using Hardhat Ignition to simplify the steps.

Step 1: Set Up the Environment

Before deploying, ensure that your environment is configured correctly with the required .env, hardhat.config.ts, and seda.config.ts files. These files contain important variables and settings for the deployment process.

.env

The .env file holds sensitive data such as private keys and contract IDs. Ensure that you fill in the required values:

ORACLE_PROGRAM_ID=YOUR_ORACLE_PROGRAM_ID
EVM_PRIVATE_KEY=YOUR_EVM_PRIVATE_KEY

# Optional
BASE_SEPOLIA_ETHERSCAN_API_KEY=YOUR_BASESCAN_API_KEY

seda.config.ts

This configuration file specifies the SedaProver contract addresses for different networks. Below is an example configuration for several supported networks:

export interface SedaConfig {
  coreAddress: string;
}

export const networkConfigs: { [network: string]: SedaConfig } = {
  // Proxy Core Addresses (SEDA mainnet)
  base: {
    coreAddress: '0xDF1fb5ACe711B16D90FC45776fF1bF02CEBc245D',
  },
  // Proxy Core Addresses (SEDA testnet)
  baseSepolia: {
    coreAddress: '0xffDB1d9bBE4D56780143428450c4C2058061E6F3',
  },
  superseedSepolia: {
    coreAddress: '0xE08989FB730E072689b4885c2a62AE5f1fc787F2',
  },
  chiado: {
    coreAddress: '0xbe2ace709959C121759d553cACf7e6532C25a3aA',
  },
  hyperliquidPurrsec: {
    coreAddress: '0x23c01fe3C1b7409A98bBd39a7c9e5C2263C64b59',
  },
};

Make sure to add the correct coreAddress for each network you're working with. You can find the latest deployed addresses here:

Prover Deployments

Hardhat Network Setup

Your Hardhat network configuration should follow the standard setup. Refer to the Hardhat documentation for detailed guidance on configuring networks in hardhat.config.ts.

Step 2: Deploy the Contract

Once your environment is set up, use Hardhat to deploy the PriceFeed contract. Ensure that you’ve defined the necessary environment variables, including ORACLE_PROGRAM_ID and EVM_PRIVATE_KEY, which are essential for deployment.

Run the following command to deploy the contract using Hardhat Ignition:

bunx hardhat pricefeed deploy --network baseSepolia --verify

After confirming the deployment, Hardhat Ignition will execute the deployment and provide the deployed contract address:

Using SEDA Core address from config: 0xffDB1d9bBE4D56780143428450c4C2058061E6F3
Using Oracle Program ID from environment: 0x5d899b1daa6811586cbf8afd2774c56489a9046f0b31db2bf37ddfeb1430f811

Deploying PriceFeed contract...

PriceFeed deployed successfully:
- Contract Address: 0xBdba4A677E64526B87BAEA5f61D6f9be27711576
- SEDA Core Address: 0xffDB1d9bBE4D56780143428450c4C2058061E6F3
- Oracle Program ID: 0x5d899b1daa6811586cbf8afd2774c56489a9046f0b31db2bf37ddfeb1430f811

Deployment information saved to /workspaces/seda-starter-kit/integrations/evm-hardhat/deployments/addresses.json
Network key: baseSepolia-84532

If you use the --verify flag, Hardhat will also verify the contract on the blockchain explorer, providing a link to view the verified contract code:

Verifying contract on block explorer...
Successfully submitted source code for contract
contracts/PriceFeed.sol:PriceFeed at 0xBdba4A677E64526B87BAEA5f61D6f9be27711576
for verification on the block explorer. Waiting for verification result...

Successfully verified contract PriceFeed on the block explorer.
https://sepolia.basescan.org/address/0xBdba4A677E64526B87BAEA5f61D6f9be27711576#code

Step 3: Post a Data Request

Once the contract is deployed, you can start posting data requests and interacting with the PriceFeed contract.

The starter kit includes tasks to simplify this process. To view available tasks, run:

bunx hardhat pricefeed --help                               
Hardhat version 2.26.1

Usage: hardhat [GLOBAL OPTIONS] pricefeed <TASK> [TASK OPTIONS]

AVAILABLE TASKS:

  deploy        Deploys the PriceFeed contract
  latest        Calls the latestAnswer function on the PriceFeed contract
  transmit      Calls the transmit function on the PriceFeed contract

pricefeed: Interact with the PriceFeed contract

For global options help run: hardhat help

For example, to post a data request on Base Sepolia, run:

bunx hardhat pricefeed transmit --network baseSepolia

Output:

No contract address specified, fetching from previous deployments...
Contract found: 0xEDE0dCB7C96353c0e5126A21EC850A8D94E7d436

Calling transmit() on PriceFeed at 0xBdba4A677E64526B87BAEA5f61D6f9be27711576...

Fees (ETH):
- Request Fee: 0.0001
- Result Fee: 0.0001
- Batch Fee: 0.0001
- Total: 0.0003

Request submitted successfully!
Request ID: 0xb9a0bbc2a1faba1f0259851b4ae7724f40cbfd1739fe3b083df72facc05361e6

If not specified, the script will fetch the contract address from the previous deployments.

Step 4: Read the Latest Answer

After the data request has been processed by the SEDA network, you can retrieve the result by calling the latestAnswer function. This will fetch the data from the network:

bunx hardhat pricefeed latest --network baseSepolia

Output:

No contract address specified, fetching from previous deployments...
Contract found: 0xBdba4A677E64526B87BAEA5f61D6f9be27711576

Calling latestAnswer() on PriceFeed at 0xBdba4A677E64526B87BAEA5f61D6f9be27711576
Latest Answer: 3865600000

With these steps, you’ve successfully deployed, posted data requests, and retrieved results using the PriceFeed contract on the SEDA network. Combining these deployment and interaction scripts allows for a smooth integration into your application.

Last updated

Was this helpful?