Skip to main content

Module batch

Module batch 

Source
Expand description

Batch account operations.

Common multi-account patterns as single methods with clearer intent and fewer repeated unsafe blocks.

Structs§

ResizeWithPayer
Resize program-owned state, funding only missing rent through System CPI.

Functions§

close_and_transfer
Transfer all lamports from source to destination and zero the source.
realloc_checked
Checked realloc that also ensures the account remains rent-exempt after resizing.
realloc_checked_with
Reaping-safe realloc_checked: tops the account up to rent-exemption using the live Rent sysvar, so it stays correct after a rent reprice.
require_account_type
Assert that an account has the expected discriminator AND is owned by the given program. This two-check combo is the most common “is this the right account type?” pattern in Solana programs.
require_address
Assert that an account’s address matches an expected address.
require_rent_exempt
Verify that an account is rent-exempt using the hardcoded current rent constants (the fast, syscall-free path).
require_rent_exempt_with
Verify that an account is rent-exempt against a live crate::sysvar::Rent sysvar (RECOMMENDED for reaping-relevant checks).
require_same_address
Assert that two accounts have the same address.
transfer_lamports
Transfer amount lamports between two accounts without CPI.
zero_data
Zero the data bytes of an account without changing lamports or owner.