Skip to Content

Data Feed Specification

This page provides technical details about how data is encoded and structured in the Morpher EVM Oracle.

Data Encoding Format

All prices are encoded with the 6-1-25 standard and 18 decimals. The bytes32 you receive from the oracle has the following structure:

First 6 bytes

Data timestamp in milliseconds

7th byte

Price decimals, always 18 (0x12)

Last 25 bytes

Price value: First 7 bytes for integer part, last 18 for decimal part

Decoding Example

Here’s an example of how to decode the bytes32 data in Solidity:

function decodePrice(bytes32 _priceData) public pure returns (uint256 timestamp, uint8 decimals, uint256 price) { // Extract timestamp (first 6 bytes) timestamp = uint256(uint48(bytes6(_priceData))); // Extract decimals (7th byte) decimals = uint8(bytes1(_priceData << 48)); // Extract price (last 25 bytes) price = uint256(uint200(_priceData << 56)); return (timestamp, decimals, price); }

Data Freshness

The timestamp included in the data allows consumers to verify the freshness of the data. It’s recommended to implement validation in your contracts to ensure you’re not acting on stale data.