> For the complete documentation index, see [llms.txt](https://docs.kaiko.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kaiko.com/on-chain/kaiko-data/kaiko-reference-rates/data-on-ramp/zenith-testnet-pull-oracle.md). Agents can also search and read this documentation through its [MCP server](https://docs.kaiko.com/~gitbook/mcp).

# Zenith testnet pull oracle

Request a Kaiko-signed price on demand, verify it on-chain, and use it in your own transaction. Verification happens in your contract call, not Kaiko's.

### In this guide

* [How it works](#how-it-works)
* [Trust and verification](#trust-and-verification)
* [Getting started](#getting-started)
* [Staleness and errors](#staleness-and-errors)
* [Example consumer contract](#example-consumer-contract)
* [Reference](#reference)

### How it works

| Component         | Where                                 | Role                                                                                                                                                |
| ----------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| Signing service   | Off-chain, reached over the Kaiko API | Returns a price with a signature over it, bound to one chain and one contract.                                                                      |
| Verifier contract | On-chain, one deployment per chain    | Given a price and its signature, it confirms the pair is authentic. Stateless and read-only: it stores no prices and never initiates a transaction. |
| Your contract     | On-chain                              | Calls the verifier, checks the price isn't too stale for what it's about to do, then acts on it. Usually five lines before your own logic.          |

### Trust and verification

Signatures are EIP-712 typed data, bound to the destination chain and the verifier contract you'll submit to. Change the chain, the contract, or any digit of the price, and the signature stops matching.

The verifier only checks authenticity, meaning that Kaiko produced this exact price at this exact timestamp. Staleness checks happen in your contract, not in the oracle, using the signed timestamp returned with each price.

### Getting started

#### Prerequisites

* A Kaiko API key with access to the EVM pull oracle. This entitlement is granted separately from other Kaiko access; contact your Kaiko representative to enable it.

#### Request a price

```
GET /v2/data/oracle.v1/evm_signed_price/{instrument_id}?destination=zenith-testnet
```

Example:

```
GET /v2/data/oracle.v1/evm_signed_price/KK_BRR_BTCUSD?destination=zenith-testnet
```

Response fields:

| Field           | Description                                                                                                                                      |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `asset_class`   | The instrument's asset class, part of the signed payload (e.g. `crypto`)                                                                         |
| `instrument_id` | The instrument requested                                                                                                                         |
| `destination`   | The target chain/contract identifier (`zenith-testnet`)                                                                                          |
| `price`         | The reference price, scaled by the instrument's decimal exponent, returned as a string (scaled values can exceed the safe integer range in JSON) |
| `decimal`       | The scaling exponent applied to `price`                                                                                                          |
| `timestamp`     | Unix timestamp of the price                                                                                                                      |
| `signature`     | Kaiko's signature over the price data                                                                                                            |

#### Submit and verify

Submit the price and signature to Kaiko's verifier contract on Zenith Testnet (see [Reference](#reference)), in your own transaction, whenever your use case needs it.

### Staleness and errors

Each price carries a maximum staleness window at the API level. If no price within that window is available, the request fails rather than returning outdated data:

| Error                | Meaning                                                                    |
| -------------------- | -------------------------------------------------------------------------- |
| `InvalidArgument`    | The request is malformed, for example an unknown instrument or destination |
| `NotFound`           | The requested instrument does not exist                                    |
| `FailedPrecondition` | The latest available price is older than the allowed staleness window      |
| `Unavailable`        | No price has been received yet for this instrument                         |

Handle these cases explicitly, for example by retrying shortly after, rather than assuming a price is always available on demand.

### Example consumer contract

A minimal reference client, `PriceConsumer`, is deployed on Zenith Testnet (source-verified, see [Reference](#reference)). It is pinned to one instrument and does the three checks every consumer needs before acting on a price:

```solidity
contract PriceConsumer {
    uint256 public constant MAX_PRICE_AGE = 10 minutes;

    PriceVerifier public immutable verifier;
    bytes32 public immutable instrumentIdHash;

    constructor(PriceVerifier _verifier, string memory instrumentId) {
        require(address(_verifier) != address(0), "PriceConsumer: zero verifier");
        verifier = _verifier;
        instrumentIdHash = keccak256(bytes(instrumentId));
    }

    function verifiedPrice(PriceVerifier.Price calldata data, bytes calldata signature)
        external
        view
        returns (uint256 price, uint8 decimal)
    {
        // the payload really comes from Kaiko and was not tampered with
        require(verifier.verify(data, signature), "PriceConsumer: invalid signature");
        // Kaiko signs many instruments and a valid signature only proves "a Kaiko price": pin which one
        require(keccak256(bytes(data.instrumentId)) == instrumentIdHash, "PriceConsumer: wrong instrument");
        // old payloads stay validly signed forever: bound how stale a submitted price may be
        require(block.timestamp - data.timestamp <= MAX_PRICE_AGE, "PriceConsumer: stale price");
        return (data.price, data.decimal);
    }
}
```

**Try it end to end:** request a signed price for `KK_BRR_BTCUSD` (see [Request a price](#request-a-price)), then replay it through the deployed consumer contract via a free view call:

```bash
cast call 0xe863273ca397ee3467d5d7b7b809b16df0f9aa54 \
  'verifiedPrice((string,string,uint256,uint8,uint256),bytes)(uint256,uint8)' \
  '("<asset_class>","<instrument_id>",<price>,<decimal>,<timestamp>)' <signature> \
  --rpc-url https://rpc.testnet.zenith.network/
```

The tuple is the signed price struct in field order (`asset_class`, `instrument_id`, `price`, `decimal`, `timestamp`), filled from the response fields. A payload less than 10 minutes old returns the price and its decimal exponent. A payload older than 10 minutes reverts with `stale price`, a tampered one with `invalid signature`, and a validly signed price for another instrument (try `KK_BRR_ETHUSD`) with `wrong instrument`.

### Reference

| Item                                        | Value                                                                                          |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| Verifier contract                           | `0xa5156C36FF2fef927D53cd743eAb5B2288DBbA8A`                                                   |
| Chain ID                                    | `936485`                                                                                       |
| Explorer (source-verified)                  | <https://explorer.testnet.zenith.network/addresses/0xa5156C36FF2fef927D53cd743eAb5B2288DBbA8A> |
| Instruments available                       | BTC (`KK_BRR_BTCUSD`), ETH (`KK_BRR_ETHUSD`)                                                   |
| Example consumer                            | `0xe863273ca397ee3467d5d7b7b809b16df0f9aa54`, pinned to `KK_BRR_BTCUSD`, 10-minute staleness   |
| Example consumer explorer (source-verified) | <https://explorer.testnet.zenith.network/addresses/0xe863273ca397ee3467d5d7b7b809b16df0f9aa54> |

Additional instruments and chains are expected to follow.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kaiko.com/on-chain/kaiko-data/kaiko-reference-rates/data-on-ramp/zenith-testnet-pull-oracle.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
