The starter kit provides tools to deploy your Oracle Programs into the SEDA network efficiently.
In this section, weโll walk you through deploying your PriceFeed Oracle Program onto the SEDA network. You'll learn how to set up your environment, deploy the Oracle Program, and post a data request to retrieve real-time results.
Setting Up Environment Variables
Before deploying, make sure to configure the necessary environment variables:
SEDA_RPC_ENDPOINT: The endpoint for interacting with the SEDA network.
SEDA_MNEMONIC: The mnemonic phrase for your SEDA wallet.
You can set these variables inline with the command or define them in a .env file for convenience.
.env
# RPC for the SEDA network you want to interact with
SEDA_RPC_ENDPOINT=https://rpc.mainnet.seda.xyz
# Your SEDA chain mnemonic, fill this in to upload binaries or interact with data requests directly
SEDA_MNEMONIC=
# Used for posting data request on the seda chain and configuring the consumer contract
# You can get this by running `bunx seda-sdk oracle-program upload PATH_TO_BUILD`
ORACLE_PROGRAM_ID=
Funding your account
Make sure that the account associated with the provided mnemonic phrase is funded. You can fund your account by using the SEDA faucet.
Deploying the Oracle Program
Deploy your Oracle Program using the command below. This will compile and upload your Oracle Program to the SEDA network:
bun run deploy
โ Uploading Oracle Program to the SEDA network
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (index) โ Values โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ tx โ 'EA3D08F153152936DD0D1BC047986E8CD24479ACF237D2113A3C5B2B106A55F7' โ
โ oracleProgramId โ '8041b318bc64ca2d2b2493f03fe2037e8a3d808ee12d957df959d1bea3495932' โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Alternatively, you can use the SEDA SDK CLI to upload and manage your Oracle Programs. You can list existing Oracle Programs on the network:
bunx seda-sdk oracle-program list
โ Querying Oracle Programs from the SEDA network
โโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ (index) โ oracleProgramId โ expirationHeight โ
โโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโค
โ 0 โ '8041b318bc64ca2d2b2493f03fe2037e8a3d808ee12d957df959d1bea3495932' โ '0' โ
โโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ
Posting a Data Request
In the scripts/ folder, you can create scripts to post Data Requests using your deployed Oracle Programs. Here's an example script:
import { Signer, buildSigningConfig, postAndAwaitDataRequest } from '@seda-protocol/dev-tools';
async function main() {
if (!process.env.ORACLE_PROGRAM_ID) {
throw new Error('Please set the ORACLE_PROGRAM_ID in your env file');
}
// Retrieve the mnemonic from the .env file (SEDA_MNEMONIC and SEDA_RPC_ENDPOINT)
const signingConfig = buildSigningConfig({});
const signer = await Signer.fromPartial(signingConfig);
console.log('Posting and waiting for a result, this may take a while...');
const result = await postAndAwaitDataRequest(signer, {
consensusOptions: {
method: 'none'
},
oracleProgramId: process.env.ORACLE_PROGRAM_ID,
drInputs: Buffer.from('eth-usdc'),
tallyInputs: Buffer.from([]),
memo: Buffer.from(new Date().toISOString()),
}, {});
console.table(result);
}
main();
Run this script to post a data request (ensure ORACLE_PROGRAM_ID is set in your environment):
bun run post-dr
Output:
Posting and waiting for a result, this may take a lil while..
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ Values โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ version โ 0.0.1 โ
โ drId โ 756b747f40f589e9878980c13ed082b20592550158e2657e3af461e80a3d4d50 โ
โ consensus โ true โ
โ exitCode โ 0 โ
โ result โ 0x001ba597000000000000000000000000 โ
โ resultAsUtf8 โ ๏ฟฝ โ
โ blockHeight โ 21539 โ
โ gasUsed โ 0 โ
โ paybackAddress โ seda_sdk โ
โ sedaPayload โ โ
โโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This guide covers the essential steps to deploy and run your PriceFeed Oracle Program on the SEDA network, enabling you to post a data request and retrieve results efficiently.
You can also observe more details about your data request execution in the SEDA explorer. Currently Data Request functionality is only deployed to Devnet: