Skip to main content

Run your own oracle price feed

What is a blockchain oracle?

A blockchain oracle is a service that brings offchain data, such as an asset price, onto a blockchain so smart contracts can use it; protocols also call it a price oracle or price feed.

Chains, DeFi protocols and oracle networks run their own when trades and liquidations on their contracts need a current price on each chain they’re deployed to.

Goldsky Compose runs the oracle as a task that reads your sources on a schedule and writes the value to each chain separately, logging every call; the sources, the pricing logic and the contracts stay yours.

Who uses a blockchain oracle?

Chains, DeFi protocols and oracle networks that publish their own prices to contracts on several chains.

How an oracle price gets from your sources to each chain

The diagram follows one price update, from your offchain sources to the contracts that read it, and shows who does each step. Your setup may differ.

Your business, step 1: Prices move offchainYour sources or exchange APIs update
Your business, step 2: Deploy the oracle contractsOne contract on each chain
Goldsky, step 3: ComposeFetch the latest priceYour task reads sources on its cadence
Goldsky, steps 4–5: ComposePush to each chainOne update per chain, each independent
Blockchains, step 6: Contracts read the priceProtocols use it for trades and liquidations
Goldsky, step 7: ComposeRecord every valueEach published update, logged
  • Goldsky

How to run a blockchain oracle

A TypeScript task that Goldsky hosts reads your price sources on a schedule and writes the value to your oracle contract on each chain, one write per chain, retrying and logging each call.

What you’ll need

  • Goldsky Compose
  • Price sources you’re allowed to use, reachable over HTTP
  • Your pricing logic, such as a median across sources
  • An oracle contract on each chain that accepts updates only from your publisher address
  1. Pick the sources the price comes from

    An oracle is only as good as the sources behind it, so they’re the first decision.

    Choose sources your protocol’s users would accept and decide how to combine them, such as taking the median. With a single source, one bad print reaches every contract that reads the price.

  2. Deploy the oracle contract on each chain

    Each chain needs its own contract that stores the price for other contracts to read.

    The contract should accept updates only from your publisher’s address and expose the price through the interface your consumers already read. A contract anyone can update is a price anyone can set.

  3. Fetch the latest price

    Handled by Goldsky Compose

    The value onchain has to be refreshed from the sources on a set cadence.

    Each run reads every source, discards responses that fail your checks and computes the value. If too few sources respond, the run should fail where you can see it, not publish a value your rules wouldn’t accept.

    Goldsky Compose starts the task from a cron trigger and reads each source with ctx.fetch, which retries failed reads and records each request and response on the run.

    Call external APIs from a task (opens in a new tab)
  4. Push the value to each chain

    Handled by Goldsky Compose

    Contracts on every chain you’re deployed to need the same price at about the same time.

    Each chain’s write has to succeed or fail on its own, so congestion on one chain doesn’t hold back the rest. A chain that missed an update gets the next one, and its consumers see the older price until then.

    One task can send a writeContract to each chain at once from the same publisher wallet and collect the results with Promise.allSettled, so one chain’s failure doesn’t block the others.

    Send transactions from a task (opens in a new tab)
  5. Stop publishing when the data is wrong

    Handled by Goldsky Compose

    A bad price can set off liquidations, so operators need a way to stop updates without shipping new code.

    Agree who can halt the feed, how they do it and what consumers see meanwhile. An oracle with no stop switch keeps publishing a bad value until someone deploys a fix.

    The NAV oracle guide shows one pattern: the source returns a ripcord flag, and while it’s set the task skips the write and returns normally, so no retries fire.

    Add a publishing kill switch (opens in a new tab)
  6. Let contracts read the price

    Lending markets, exchanges and other contracts read the stored price when they settle a trade or check a loan.

    Consumers should check when the price was last updated and refuse values older than they accept. Without that check, a stalled feed lets trades settle on an old price.

  7. Keep a record of every published value

    Handled by Goldsky Compose

    Anyone relying on the price may want to check where a given value came from.

    Each published value should trace back to the source responses and the calculation behind it. If it doesn’t, a disputed liquidation turns into an argument about what the sources said at the time.

    With Goldsky, every ctx.fetch call, its URL and its response are captured in the task run’s event log, next to the transaction that published the value.

    How fetch calls are recorded (opens in a new tab)

What you control

Your team
  • Pick the sources the price comes from
  • Deploy the oracle contract on each chain

Security and deployment

  • SOC 2 Type IIIndependently audited security controls.
  • Dedicated infrastructureSingle-tenant options for production workloads.
  • Data residencyCloud, on-premises or co-located.

Run a blockchain oracle with Goldsky

We’ll map it to your systems and show you what Goldsky runs, so your team builds the product, not the pipelines underneath it.

© Endless Sky Inc. All rights reserved.

PrivacyTermsSecurity

System status