3

I'd like to make some RPC calls a few slots after the end of each epoch. This is mainly to do with staking rewards calculations.

How can I get a callback into my code on each new epoch (once every two or three days)?

None of the things I can subscribe to on the WS API look quite right. I can subscribe to slots, but I don't want 432,000 callbacks just to check on which one the epoch number incremented. Can I find a program that executes near the start or end of each epoch (and preferably not that much the rest of the time) and use programSubscribe to listen for that?

1 Answer 1

2

There is no generic functionality for callbacks on Solana, so you must create something external which listens to the chain in some way.

External products such as Cronos http://cronos.so/ exist to solve this exact problem.

If you want an easy solution, you can just write a simple program that polls the block height every few minutes, and does extra work if the height matches some critera (ie. within the first 100 hundred slots of the 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.