Skip to main content

Module rent

Module 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(())
}

Structs§

Rent
Configuration of network rent.

Constants§

IDNon-target_arch=bpf
The const program ID.

Functions§

check_id
Returns true if given address is the ID.
id
Returns the ID.