For the complete documentation index, see llms.txt. This page is also available as Markdown.

Oracle & VRF Integration

Two MegaETH-native capabilities power automatic market resolution and provably fair randomness in evently: Redstone Pull-model Oracle and Drand BLS12-381 VRF.


Redstone Pull-model Oracle

How it works

Redstone uses the Pull model: price data is NOT stored on-chain. Instead, a keeper (off-chain script) fetches the latest signed price package from Redstone and injects it as calldata when calling resolveMarketWithOracle().

The contract inherits from RedstoneConsumerNumericBase and reads the price inline using getOracleNumericValueFromTxMsg(feedId). Signature verification happens automatically — the call reverts if fewer than 3 valid redstone-primary-prod signers are present in the calldata.

Integration — Keeper script

const { WrapperBuilder } = require("@redstone-finance/evm-connector");
const { ethers } = require("hardhat");

const contract = await ethers.getContractAt("EventlyMarkets", MARKETS_ADDRESS);

const wrapped = WrapperBuilder
  .wrap(contract)
  .usingDataService({
    dataServiceId: "redstone-primary-prod",
    uniqueSignersCount: 3,
    dataFeeds: [feedId],  // e.g. "ETH"
  });

await wrapped.resolveMarketWithOracle(marketId, evidenceHash);

Authorized signers

The contract hardcodes 5 redstone-primary-prod signer addresses in getAuthorisedSignerIndex(). Minimum threshold is 3 (getUniqueSignersThreshold()). Any call with fewer valid signatures will revert.

Encoding price feed IDs

The priceFeedId parameter in createOracleMarket is bytes32. Encode it as a right-padded ASCII string:

Strike price precision

Strike prices use 8 decimal places (same as Redstone USD feeds):

Value
Encoded

$3,000

300000000000

$100,000

10000000000000

$0.50

50000000


Drand BLS12-381 VRF (MegaETH Native)

MegaETH exposes a native precompile for verifying Drand quicknet BLS12-381 randomness proofs. evently uses this for:

  1. Monthly dispute lotterydistributeMonthlyDisputeRewards(month, vrfProof, vrfMessage) draws a single winner-takes-all

  2. Weekly Lucky Trader raffledrawLuckyTrader(week, vrfProof, vrfMessage, bonusAmount) draws one winner from that week's active traders

Interface

The contract calls IDrandVerifier(drandVerifier).verify(vrfProof, vrfMessage) and reverts if the proof is invalid.

Winner derivation

The VRF proof itself is the source of entropy — it is deterministic given the Drand round and cannot be manipulated by the caller.

Admin setup

Set the precompile address before any draw:

The address is network-specific. Confirm the MegaETH Drand precompile address from the official MegaETH documentation before deployment.

Fetching a Drand proof (off-chain)


Events

Event
When emitted

OracleResolution(marketId, feedId, price, winningOption)

Oracle market resolved

DisputeLotteryWinner(month, winner, amount)

Monthly dispute lottery drawn

LuckyTraderWinner(week, winner, bonusAmount)

Weekly lucky trader drawn

DrandVerifierUpdated(newVerifier)

Drand precompile address updated

Last updated

Was this helpful?