I'm writing a Solana program in Anchor and want to know what the current Epoch is. How do I do this?
1 Answer
Hey there with anchor you can use the solana_program::clock::Clock struct.
pub struct Clock {
pub slot: Slot,
pub epoch_start_timestamp: UnixTimestamp,
pub epoch: Epoch,
pub leader_schedule_epoch: Epoch,
pub unix_timestamp: UnixTimestamp,
}
You get the current epoch by using :
Clock::get()?.epoch;