> For the complete documentation index, see [llms.txt](https://docs.seda.xyz/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seda.xyz/home/archvie/building-your-oracle-program-onchain/deploying-your-oracle-program-for-onchain.md).

# Deploying Your Oracle Program for Onchain

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.

{% code title=".env" %}

```
# RPC for the SEDA network you want to interact with
SEDA_RPC_ENDPOINT=https://rpc.testnet.seda.xyz

# (optional) Explorer for the SEDA network you want to interact with 
SEDA_EXPLORER_URL=https://testnet.explorer.seda.xyz

# For Mainnet, uncomment the lines below
SEDA_RPC_ENDPOINT=https://rpc.seda.xyz
SEDA_EXPLORER_URL=https://explorer.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=
```

{% endcode %}

## **Funding your account**

Make sure the account associated with your mnemonic is funded. You can use the [SEDA faucet](https://testnet.explorer.seda.xyz/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:

```bash
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:

```bash
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:

```typescript
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:

```bash
bun run post-dr
```

Output:

```bash
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 │                                                                  │
│   explorerLink │ https://testnet.explorer.seda.xyz/data-requests/...              │
└────────────────┴──────────────────────────────────────────────────────────────────┘
```

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://testnet.explorer.seda.xyz/).

`https://testmet.explorer.seda.xyz/data-requests/{YOUR_DR_ID}/{POSTED_BLOCK_HEIGHT}`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.seda.xyz/home/archvie/building-your-oracle-program-onchain/deploying-your-oracle-program-for-onchain.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
