Documentation Index
Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
Use this file to discover all available pages before exploring further.
Please view the third-party content disclaimer here.
Chronicle Protocol provides verifiable, cost-efficient oracle price feeds. Chronicle contracts are read-protected by a whitelist.
Prerequisites
- A Solidity contract targeting Polygon zkEVM Cardona testnet or mainnet.
- On testnet: your contract address must be added to the whitelist using the
SelfKisser contract (see step 1 below).
- On mainnet: open a support ticket on Discord in the #support channel to request whitelist access.
Find deployment addresses on the Chronicle Dashboard.
Read POL/USD price from Chronicle
The contract below reads the POL/USD price on the zkEVM Cardona testnet and handles whitelist registration automatically in the constructor.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
/**
* @title OracleReader
* @notice A simple contract to read from Chronicle oracles
* @dev To see the full repository, visit https://github.com/chronicleprotocol/OracleReader-Example.
* @dev Addresses in this contract are hardcoded for the zkEVM Cardona Testnet.
* For other supported networks, check the https://chroniclelabs.org/dashboard/oracles.
*/
contract OracleReader {
/**
* @notice The Chronicle oracle to read from.
* Chronicle_POL_USD_1 - 0x55a07a60cd9ed198B5Ba4360FF9800eBb6667388
* Network: zkEVM Cardona Testnet
*/
IChronicle public chronicle = IChronicle(address(0x55a07a60cd9ed198B5Ba4360FF9800eBb6667388));
/**
* @notice The SelfKisser granting access to Chronicle oracles.
* SelfKisser_1:0xCce64A8127c051E784ba7D84af86B2e6F53d1a09
* Network: zkEVM Cardona Testnet
*/
ISelfKisser public selfKisser = ISelfKisser(address(0xCce64A8127c051E784ba7D84af86B2e6F53d1a09));
constructor() {
// Note to add address(this) to chronicle oracle's whitelist.
// This allows the contract to read from the chronicle oracle.
selfKisser.selfKiss(address(chronicle));
}
/**
* @notice Function to read the latest data from the Chronicle oracle.
* @return val The current value returned by the oracle.
* @return age The timestamp of the last update from the oracle.
*/
function read() external view returns (uint256 val, uint256 age) {
(val, age) = chronicle.readWithAge();
}
}
// Copied from [chronicle-std](https://github.com/chronicleprotocol/chronicle-std/blob/main/src/IChronicle.sol).
interface IChronicle {
/**
* @notice Returns the oracle's current value.
* @dev Reverts if no value set.
* @return value The oracle's current value.
*/
function read() external view returns (uint256 value);
/**
* @notice Returns the oracle's current value and its age.
* @dev Reverts if no value set.
* @return value The oracle's current value using 18 decimals places.
* @return age The value's age as a Unix Timestamp .
* */
function readWithAge() external view returns (uint256 value, uint256 age);
}
// Copied from [self-kisser](https://github.com/chronicleprotocol/self-kisser/blob/main/src/ISelfKisser.sol).
interface ISelfKisser {
/// @notice Kisses caller on oracle `oracle`.
function selfKiss(address oracle) external;
}
Next steps
For more integration examples, see the Chronicle documentation portal.