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. These are operations that every serious Solana program needs but nobody bundles at the substrate level.

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.
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 given the current rent parameters.
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.