1

I'm writing a Solana program in Anchor and want to know what the current Epoch is. How do I do this?

1 Answer 1

3

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.