Gelato

Gelato Legacy Oracle Updates With the Web3 Functions SDK

Gelato used Web3 Functions to fetch API data off-chain and prepare conditional oracle updates for smart contracts. Its hosted automation service was later deprecated. In that design, timing checks determined update eligibility, while a successful transaction was needed to change the oracle's stored value.

Price API Data Into Oracle Storage

An API-backed oracle update used an off-chain function to read a price, encode a contract call and prepare that value for on-chain execution. The oracle template read lastUpdated() before fetching price data. It continued only after its timing condition passed. Its returned payload identified the destination contract and encoded updatePrice(uint256) with the selected price.

The smart contract received a number encoded for its interface; the off-chain code performed the HTTP request and conditional computation. This division kept API access outside the contract. Selecting the correct asset identifier and quote unit mattered because successful JSON parsing alone did not establish a value's meaning or accuracy.

The Web3 Functions Runtime and Its Context

The SDK provided tools for building and evaluating TypeScript functions, with a runtime context for arguments, blockchain RPC providers, persistent storage and secrets. Functions registered their handler with Web3Function.onRun. In the oracle template, multiChainProvider.default() selected the remote procedure call (RPC) provider used for contract reads. A schema declared runtime settings and argument types. The compiled bundle was stored on IPFS, the InterPlanetary File System, and identified by a content identifier (CID). Task configuration associated that code with its inputs and trigger. Package dependencies handled HTTP requests and contract-call encoding.

Update Intervals and Price Freshness

The update interval limited how soon the function would prepare another write, while the task trigger determined how often the function ran. The template's oracle function required the latest block timestamp to reach lastUpdated() plus 3,600 seconds before returning an update. That one-hour threshold was an application rule inside the function. Its starting point came from the destination oracle's stored update timestamp.

The secret-aware oracle template used a different 300-second gate. Each interval belonged to its template's hard-coded timing condition. Changing the task's trigger frequency alone would not change either comparison. More frequent evaluations could therefore produce skipped runs until the applicable timing condition passed.

The elapsed-time check measured time since the last contract update. It did not measure the age of the API's price observation. An integration that required fresh observations needed a data-age rule appropriate to its provider, alongside its update schedule.

Oracle Units and Write Permissions

Oracle integration depended on both the meaning of the encoded price and the permissions enforced by the destination contract.

Integer Encoding

The template rounded the API price down with Math.floor before encoding updatePrice(uint256). This conversion discarded fractional precision. Other destination contracts could require a different price scale. The application binary interface (ABI) described the accepted argument type. A contract that expected a scaled price needed an encoding rule that matched its units. Valid integer calldata could still express the wrong price if the writer and consumer interpreted its scale differently.

Authorized Contract Calls

The oracle's own code governed who could write when it imposed caller restrictions. Off-chain timing checks did not grant those permissions. A legacy task that routed calls through a dedicatedMsgSender proxy reached the destination with that proxy as msg.sender. The deployment signer and RPC provider were different from this execution caller. An authorization check therefore needed to recognize the address that actually called the oracle, subject to the selected execution route.

Does an Executable Result Prove the Oracle Changed?

A local SDK run could return canExec: true while the oracle's stored value remained unchanged, because the run had prepared transaction instructions. Its output alone did not establish transaction submission or execution. When reconciling that result with an expected update, inspect the conditions behind each record:

  • Confirm that the contract-state read used the intended oracle address and network.
  • Compare the latest block timestamp with the interval enforced inside the deployed function.
  • Inspect the returned to address and decode data using the destination contract's ABI.
  • Check whether any transaction receipt belonged to the oracle update and showed successful execution.
  • Read the oracle's relevant stored value and update timestamp to establish the actual state change.

A task-creation receipt established a different operation from an oracle write. The update still depended on the destination accepting the intended call.

API Credentials and Persistent Task Memory

The runtime provided separate facilities for private API inputs and persistent task memory, keeping credentials and bookkeeping apart from ordinary function arguments.

Secrets Outside IPFS

Runtime secrets supplied private credentials through context.secrets.get, allowing them to remain outside the compiled bundle uploaded to IPFS. Hard-coding a credential into the function or printing it in logs defeated that separation. The secret-aware oracle template returned canExec: false when its required secret was absent. A credential available during local testing also needed appropriate configuration in the deployed task; a local environment file did not establish that runtime setting.

Graphic: Gelato: Secrets Outside IPFS
Visual summary: Secrets Outside IPFS.

View image file

State After Successful Execution

Each evaluation started with fresh in-memory state. Persistent context.storage held string values between evaluations, so a stored checkpoint recorded off-chain bookkeeping. Writing that checkpoint did not establish an oracle-contract change. The SDK exposed an optional onSuccess callback after successful on-chain execution, with the transaction hash available in its context. Completion-sensitive bookkeeping could use that callback. Logic that marked an update as finished before execution could suppress needed work after a failed transaction, depending on how later runs used the checkpoint.

Signed Price Updates and Separate Fees

The Pyth integration applied oracle automation to signed price-update payloads, giving its destination contract a different input from the template's plain integer price. A simple updatePrice(uint256) call carried an API-derived number under the receiving contract's rules. Pyth Core's updatePriceFeeds accepted serialized, signed update data for on-chain verification. In the legacy integration, the Web3 Function decided when to submit those payloads. The oracle protocol supplied their verification rules; scheduling an API request did not itself provide that verification.

Gelato - Signed Price Updates and Separate Fees

View image file

Funding in that integration served separate purposes. For funded production tasks, the historical 1Balance arrangement covered Gelato's computation and transaction gas costs. Gelato subsidized testnet execution in that setup. The Pyth call also required a native-token update fee, which the executing proxy needed to cover. The function calculated that fee with getUpdateFee and included it as value in the returned call data. A funded automation balance therefore did not establish that the proxy could pay the oracle contract's fee.

Oracle Logic After Automation Deprecation

Preserving an oracle integration required carrying over its data interpretation and contract-call requirements into infrastructure that could actually execute the function. Gelato's Web3 Functions automation service was deprecated. Existing code bundles described function behavior separately from hosted service availability. Gasless transactions concerned fee sponsorship and submission; an oracle integration also required computation that fetched data and evaluated update conditions. Reusing the logic required matching the replacement's call format and preserving the intended target. Its execution caller also had to satisfy any write restrictions in the oracle contract.

Gelato: Oracle Logic After Automation Deprecation - diagram
Oracle Logic After Automation Deprecation.

View image file

Common questions about Gelato

Which SDK Command Displayed Local Oracle Function Logs?

The command npx w3f test web3-functions /oracle/index.ts --logs displayed local oracle function logs. It evaluated the function and showed its returned result alongside runtime statistics. The test needed an appropriate RPC configuration for the chain being examined. An integration test that also submitted a transaction performed additional work beyond this local function evaluation.

Were Failed API Requests Automatically Retried in the Oracle Template?

The oracle template disabled retries for its price request with retry: 0. It also configured a 5,000-millisecond timeout for that HTTP request. A later function evaluation was distinct from retrying the request within the same run. These settings belonged to the template's request code, rather than defining a universal Web3 Functions retry policy.

How Did Changing the Deployed Oracle Code Affect Its IPFS CID?

Changing the deployed function bundle changed its IPFS content identifier. Editing a local file alone did not change the bundle that an existing task referenced. A task retaining the original CID still identified the original content. Reproducing identical content with the same IPFS settings produced the same CID.

Do I Need to Embed a Wallet Private Key to Prepare Oracle Calldata?

Preparing oracle calldata did not require a wallet private key inside the deployed function. Task creation through a signing script was a separate operation. Credentials needed by that script belonged in its signing environment, while the function's runtime secrets supplied private API inputs where required. Neither operation required publishing a private key in the function bundle.

What Caused an Oracle Failure Callback to Have No Transaction Hash?

An oracle simulation failure could occur before transaction submission. The SDK's onFail context supplied callData for SimulationFailed and a transactionHash for ExecutionReverted. It also identified InsufficientFunds as a failure reason. These records described different execution states, so the failure reason determined what a missing transaction hash meant.

Did an onSuccess Callback Count as Another Web3 Function Run?

An onSuccess callback counted as a normal Web3 Function run within the applicable plan limits, adding off-chain work after successful on-chain execution.

Could the Shared Pyth Price Pusher Change Feed Settings Without Uploading New Function Code?

The shared Pyth price pusher loaded feed settings and update thresholds from an external config.yaml file. Configuration edits took effect through its configured refresh process without requiring a new code bundle. This mechanism changed supported configuration values; changing the function's underlying logic still required deploying different code.

Can a Successful Pyth Oracle Update Leave the Stored Price Unchanged?

A successful Pyth Core updatePriceFeeds call could leave a feed unchanged when the supplied update was no newer than its stored price. The contract ignored that update while allowing the call to succeed. The required update fee still applied, so transaction success alone did not establish that the feed's stored publication time advanced.

updated