0

Is there a way to determine preferably on chain when the rent for an account was last paid? If not, is there a way to do so off-chain?

1 Answer 1

1

Technically, this is stored in the rent-epoch on the AccountInfo struct: https://github.com/anza-xyz/agave/blob/7c12f038dd7829ce3216bdd91b5de9d24631e279/sdk/program/src/account_info.rs#L29

So you can get it with a simple program:

use solana_program::{
    account_info::{next_account_info, AccountInfo},
    entrypoint::ProgramResult,
    msg,
    pubkey::Pubkey,
};

solana_program::entrypoint!(process_instruction);

/// Instruction processor
pub fn process_instruction(
    _program_id: &Pubkey,
    accounts: &[AccountInfo],
    _instruction_data: &[u8],
) -> ProgramResult {
    // Create an iterator to safely reference accounts in the slice
    let account_info_iter = &mut accounts.iter();
    let account_info = next_account_info(account_info_iter)?;
    msg!("{}", account_info.rent_epoch);
    Ok(())
}

But the rent_epoch doesn't mean anything anymore, since rent has been removed from all networks.

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.