๐Contract Deployment
Deploying and testing your contract using Hardhat is a straightforward process, especially with the deployment scripts provided in the SEDA Hardhat 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
.env
The .env
file holds sensitive data such as private keys and contract IDs. Ensure that you fill in the required values:
seda.config.ts
seda.config.ts
This configuration file specifies the SedaProver
contract addresses for different networks. Hereโs an example for the baseSepolia
network:
Make sure you add the correct proverAddress
for each network you're working with.
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:
After confirming the deployment, Hardhat Ignition will execute the deployment and provide the deployed contract address:
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:
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:
For example, to post a data request on Base Sepolia, run:
Output:
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:
Output:
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