ERC-7412
A standard for using oracle data on Ethereum
Build protocols that use data from oracles
Write and deploy smart contracts that call oracle contracts to reference off-chain data.
Example Code
function ethPrice() public view returns (uint256) {
IPythERC7412Wrapper pyth = IPythERC7412Wrapper("0xEb38e347F24ea04ffA945a475BdD949E0c383A0F");
bytes32 priceId = "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace";
uint stalenessTolerance = 60; // in seconds
return pyth.getLatestPrice(priceId, stalenessTolerance); // also see getBenchmarkPrice()
}
Example Code
function linkPrice() public view returns (uint256) {
// Under Development
DataStreamsERC7412Compatible chainlink = DataStreamsERC7412Compatible();
}
Build apps with protocols that connect to oracles
The client library automatically adds oracle data to transactions when necessary.
// Under Development
import { withRequiredOracleData, PythAdapter } from "erc7412";
// Call View Functions
// This automatically resolves `OracleDataRequired` and `FeeRequired` errors.
// TODO
// Prepare Transactions for Signing
// This returns an array that includes `fulfillOracleQuery()` calls when necessary.
const transactionsWithOracleData = await withRequiredOracleData(
transactions,
[new PythAdapter('https://hermes.pyth.network')]
);
return await client.sendTransactions({ transactions: transactionsWithOracleData });
See the full example using permissionless.js.
// Under Development
import { withRequiredOracleData, PythAdapter } from "erc7412";
// Call View Functions
// This automatically resolves `OracleDataRequired` and `FeeRequired` errors.
// TODO
// Prepare Transactions for Signing
// This returns a call to the trusted multicall forwarder.
// TODO
See the full example using viem v2.
// Under Development
import { withRequiredOracleData, PythAdapter } from "erc7412";
// Call View Functions
// This automatically resolves `OracleDataRequired` and `FeeRequired` errors.
// TODO
// Prepare Transactions for Signing
// This returns a call to the trusted multicall forwarder.
// TODO
See the full example using ethers.js v6.
Compatible Account Abstraction Solutions
Protocols that integrate with the trusted multicall forwarder are also compatible with EOAs.
Build something awesome that integrates with Synthetix Perps V3.