0

How to filter most recently created pdas of a program, How should date be store in pda data so that we can directly filter based on the data stored in pda. For ex. filtering all pda of a program created in last 2 days.

Fetching all pda and then filter out is too heavy operation, as number of pda increases. so want to directly fetch pda based on the data stored in them.

2 Answers 2

0

There may be better solutions through different RPC providers, but using the default Solana RPC, there's no way to create a "greater than" or "less than" filter, just exact memory comparison. So your options are:

  • call getProgramAccounts with a memcmp filter on every possible timestamp
  • call getProgramAccounts and filter on the client side
0

There is no technically way to achieve this. One clunky way would be to save some non-precise timestamp (like ddmmyyyy) in the PDA (wasting space for sure), and then u can query that with memcmp for the last X days that you wish to have.

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.