🚀Deploying Your Oracle Program
The starter kit provides tools to deploy your Oracle programs to the SEDA network efficiently.
In this section, we’ll walk you through deploying your PriceFeed
Oracle program, setting up your environment, and posting 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.
# RPC for the SEDA network you want to interact with
SEDA_RPC_ENDPOINT=https://rpc.testnet.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 the account associated with your mnemonic is funded. You can use the SEDA faucet to request tokens (Testnet only).
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. Make sure ORACLE_PROGRAM_ID
is defined 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 view more details about your data request execution in the SEDA Explorer.
https://testmet.explorer.seda.xyz/data-requests/{YOUR_DR_ID}
Last updated
Was this helpful?