Module solana_program::sysvar::rent

source ·
Expand description

Configuration for network rent.

The rent sysvar provides access to the Rent type, which defines storage rent fees.

Rent implements Sysvar::get and can be loaded efficiently without passing the sysvar account ID to the program.

See also the Solana documentation on the rent sysvar.

§Examples

Accessing via on-chain program directly:

fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {

    let rent = Rent::get()?;
    msg!("rent: {:#?}", rent);

    Ok(())
}

Accessing via on-chain program’s parameters:

fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    let account_info_iter = &mut accounts.iter();
    let rent_account_info = next_account_info(account_info_iter)?;

    assert!(rent::check_id(rent_account_info.key));

    let rent = Rent::from_account_info(rent_account_info)?;
    msg!("rent: {:#?}", rent);

    Ok(())
}

Accessing via the RPC client:

fn print_sysvar_rent(client: &RpcClient) -> Result<()> {
    let rent = client.get_account(&rent::ID)?;
    let data: Rent = bincode::deserialize(&rent.data)?;

    Ok(())
}

Re-exports§

  • pub use crate::rent::Rent;

Constants§

  • The const program ID.

Functions§

  • Returns true if given pubkey is the program ID.
  • Returns the program ID.