Skip to main content

read_clock

Function read_clock 

Source
pub fn read_clock(account: &AccountView) -> Result<(u64, i64), ProgramError>
Expand description

Read both slot and unix_timestamp from the Clock sysvar account.

Validates the sysvar address, then returns (slot, unix_timestamp). This is the most common Clock usage — almost every DeFi instruction needs both the slot (for oracle staleness) and timestamp (for deadlines).

let (slot, timestamp) = read_clock(clock_account)?;
require!(timestamp <= deadline, MyError::Expired);