3

Hey so i seem to facing a weird situation where some of my init tx require rent to be passed in where as in other tx which use init, and rent is perfectly omitted without any issue not sure if its a bug or a concept am missing out on.

1
  • Can you add more code its hard to guide this way
    – Pratik.js
    Commented Jul 27, 2022 at 11:27

2 Answers 2

4

While the rent sysvar can now be loaded at runtime, some programs still require the rent sysvar account to be passed in to them. The main example of this is the spl token program. If you are initializing a new token account or a mint account, it's likely anchor will ask you for the rent sysvar to be passed in as an account.

This will likely go away in the future as different programs are updated. There's even a newer version of the spl token program that doesn't require the rent sysvar but for some reason anchor hasn't been able to switch over to using it yet.

4

Before Solana v1.8.X, sysvars had to be passed in as accounts, so there are programs with instructions that still require Rent to be passed in to maintain backward compatibility / because they haven't been updated.

If you're gonna CPI such an instruction then you will need to pass Rent in so that you can pass it to that instruction.

Edit: it seems like as of anchor 0.24.X, Rent no longer needs to be included for an #[init] account.

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.