Expand description
One-import path for authored Hopper programs.
Re-exports§
pub use crate::guards::require;pub use crate::guards::require_address;pub use crate::guards::require_data_len;pub use crate::guards::require_disc;pub use crate::guards::require_eq;pub use crate::guards::require_gt;pub use crate::guards::require_gte;pub use crate::guards::require_has_data;pub use crate::guards::require_keys_eq;pub use crate::guards::require_keys_neq;pub use crate::guards::require_layout;pub use crate::guards::require_neq;pub use crate::guards::require_owner;pub use crate::guards::require_payer;pub use crate::guards::require_signer;pub use crate::guards::require_unique_2;pub use crate::guards::require_unique_3;pub use crate::guards::require_version;pub use crate::guards::require_writable;pub use crate::receipts::emit_receipt;pub use crate::receipts::emit_tagged_receipt;pub use crate::receipts::emit_typed_receipt;pub use crate::receipts::set_return_data;pub use crate::receipts::Receipt;pub use hopper_associated_token;pub use hopper_system;pub use hopper_token;pub use hopper_token_2022;pub use hopper_memo;
Modules§
- associated_
token_ instructions - error
- Hopper-owned program error type for Solana on-chain programs.
- system_
instructions - Compatibility re-exports.
- token_
2022_ instructions - token_
instructions - SPL Token instruction builders exported by Hopper.
Macros§
- const_
assert_ pod - Compile-time assertion for safe manual
Podimplementations. - err
- Return an error immediately. Parallel to Anchor’s
err!. - error
- Alias for
err!. Anchor compatibility shim so ported code needs no rename. Functionally identical. - fast_
entrypoint - Backward-compatible alias for the fast Hopper entrypoint macro.
- hopper_
accounts - Generate a typed instruction context struct with validated account parsing.
- hopper_
check - Composable account constraint checking.
- hopper_
close - Safely close an account with sentinel protection.
- hopper_
entrypoint - Declare the explicit Hopper runtime entrypoint bridge.
- hopper_
error - Generate sequential error codes.
- hopper_
fast_ entrypoint - Declare the fast two-argument Hopper entrypoint.
- hopper_
init - Initialize an account: create via CPI, zero-init, write header.
- hopper_
interface - Declare a cross-program interface view.
- hopper_
invariant - Invariant checking macro.
- hopper_
layout - Define a zero-copy account layout.
- hopper_
lazy_ entrypoint - Declare the Hopper lazy entrypoint.
- hopper_
load - Destructuring sugar for raw-dispatch handlers.
- hopper_
manifest - Generate a layout manifest for schema tooling.
- hopper_
register_ discs - Discriminator registry – compile-time uniqueness enforcement.
- hopper_
require - Require a condition, returning a custom error if false.
- hopper_
segment - Declare a segmented account with typed segments.
- hopper_
validate - Build a validation pipeline declaratively.
- hopper_
verify_ pda - PDA verification with BUMP_OFFSET optimization.
- hopper_
virtual - Declare a multi-account virtual state mapping.
- lazy_
entrypoint - Backward-compatible alias for the lazy Hopper entrypoint macro.
- no_
allocator - nostd_
panic_ handler - program_
entrypoint - Declare the canonical Hopper program entrypoint.
- require_
lt - Assert
left < rightstrictly. Anchor-parity sibling ofrequire_gt!. Default error isProgramError::InvalidArgumentbecause a failed ordering check most often flags a bad user input. - require_
lte - Assert
left <= right. Anchor-parity sibling ofrequire_gte!.
Structs§
- Account
- A typed, owner-validated account (immutable).
- Account
Constraint - A builder for constructing validation constraints on a single account.
- Account
Explain - Human-readable explanation of a single account.
- Account
Header - The 16-byte account header, overlay-safe.
- Account
Mut - A typed, owner-validated account (mutable).
- Account
Reader - Header-aware read-only account reader.
- Account
View - Zero-copy view over a Solana account.
- Address
- A Solana address (public key): 32 bytes, transparent layout.
- Authority
- Marker: an authority/signer address.
- BitSet
- Compact bit array overlaid on a byte slice.
- Cached
Clock - Cached Clock sysvar fields.
- Cached
Rent - Cached Rent sysvar fields.
- Capability
Set - A set of capabilities declared for an instruction.
- Context
- Execution context for a Hopper instruction handler.
- Context
Explain - Human-readable explanation of a context.
- Decoded
Receipt - Decoded receipt from wire bytes. Useful for CLI and off-chain tooling.
- Execution
Context - Mutable execution context available during the Execute phase.
- Field
Info - Descriptor for one field in a Hopper layout.
- Field
Mut - Mutable typed view over a field’s bytes.
- Field
Ref - Immutable typed view over a field’s bytes.
- Fingerprint
Transition - Pair of fingerprints for asserting version transitions.
- Fixed
Vec - Bounded dynamic array overlaid on a byte slice.
- Frame
- Execution frame holding the instruction’s accounts and data.
- Frame
Account - Immutable account view within a Frame.
- Frame
Account Mut - Mutable account view within a Frame.
- Hopper
Account - A layout-bound, owner-validated account.
- Hopper
Cpi - Stack-allocated CPI call with compile-time-known account count and data size.
- Hopper
CpiBuf - Variable-data CPI builder – const accounts, runtime data length.
- Hopper
Ctx - Typed instruction context carrying validated accounts, bumps, and metadata.
- Hopper
Header - The canonical 16-byte header at the start of every Hopper account.
- Instruction
Account - Metadata for an account referenced in a CPI instruction.
- Instruction
Policy - Instruction policy – maps capabilities to validation requirements.
- Instruction
View - A cross-program instruction to invoke.
- Interface
Mint - Polymorphic SPL Token / Token-2022 mint overlay.
- Interface
Token Account - Polymorphic SPL Token / Token-2022 token-account overlay.
- Invariant
Set - Batch invariant checker.
- Journal
- An append-only journal of fixed-size entries.
- Journal
Reader - Read-only journal view.
- Layout
Fingerprint - An 8-byte deterministic layout fingerprint.
- Layout
Info - Runtime metadata snapshot of an account’s layout identity.
- Memo
- SPL Memo CPI builder.
- Migrating
Account - An account undergoing migration from layout
Fromto layoutTo. - Mint
- Marker: a mint address.
- Mut
- Writable wrapper – validates that the account is writable.
- Packed
Map - Packed key->value map overlaid on a byte slice.
- Phased
Frame - A phased execution context that enforces ordering via type state.
- Policy
Pack Descriptor - Descriptor for a named policy pack with full metadata.
- Post
Mutation Validator - Collects post-mutation checks that run after instruction execution.
- Program
- Marker: a program address (executable).
- Program
Account - A generic program-owned account.
- Program
Ref - A verified executable program reference.
- Realloc
Guard - Per-instruction realloc budget guard.
- Receipt
Explain - Human-readable explanation of a decoded receipt.
- Requirement
Set - A set of active policy requirements.
- Resolved
Frame - A frame that has been resolved with typed account references.
- Ring
Buffer - Fixed-capacity circular buffer overlaid on a byte slice.
- Seed
- A single PDA seed for CPI signing.
- Segment
Borrow - A single active segment borrow.
- Segment
Borrow Registry - Instruction-scoped segment borrow registry.
- Segment
Entry - A segment entry in the registry.
- Segment
Registry - Read-only view over a segmented account’s registry.
- Segment
Registry Mut - Mutable view over a segmented account’s registry.
- Segmented
Account - A segmented account with role-aware region access.
- Sharded
Access - A sharded collection that distributes entries across multiple accounts.
- Signer
- A PDA signer: a set of seeds that derive the signing PDA.
- Signer
Account - A verified signer account.
- Slab
- A fixed-size slab allocator over a byte slice.
- SlotMap
- Fixed-slot map overlaid on a byte slice.
- Sorted
Vec - Sorted bounded dynamic array – zero-copy with O(log n) binary search.
- State
Diff - A diff between two states of account data.
- State
Receipt - A structured record of a state mutation.
- State
Snapshot - A stack-allocated snapshot of account data.
- Static
Segment - A compile-time constant segment descriptor.
- Sysvar
Context - Combined sysvar context for a single instruction.
- Token
Account - Marker: a token account address.
- Transaction
Constraint - Transaction-level constraint that validates global properties.
- Transition
Rule Pack - Associates validation rules with specific instruction tags.
- Trust
Flags - Policy flags for additional constraints.
- Trust
Profile - A foreign-account trust profile.
- Typed
Address - A 32-byte public key tagged with a phantom layout type.
- Unchecked
Account - An unchecked account. No validation is performed.
- Untyped
Address - An untyped 32-byte address (interop bridge).
- Validated
Frame - A frame whose accounts have been validated.
- Validation
Bundle - A bundle that composes multiple
ValidationGroups into a single check. - Validation
Context - Context passed to each validation node.
- Validation
Graph - A stack-allocated validation graph with up to
Nnodes. - Validation
Group - A named group of validation rules.
- Verified
Account - Immutable verified account – proof that validation passed.
- Verified
Account Mut - Mutable verified account – proof that validation passed, with write access.
- Virtual
Slot - A mapping from virtual slot index to account index.
- Virtual
State - A virtual state assembly mapping
Nslots to accounts. - Wire
Bool - Boolean wire type stored as a single byte.
- WireI16
- 16-bit signed little-endian wire integer.
- WireI32
- 32-bit signed little-endian wire integer.
- WireI64
- 64-bit signed little-endian wire integer.
- Wire
I128 - 128-bit signed little-endian wire integer.
- WireU16
- 16-bit unsigned little-endian wire integer.
- WireU32
- 32-bit unsigned little-endian wire integer.
- WireU64
- 64-bit unsigned little-endian wire integer.
- Wire
U128 - 128-bit unsigned little-endian wire integer.
Enums§
- Access
Kind - Read or write access intent for a segment borrow.
- Capability
- Instruction capability flags.
- Compat
Impact - Compatibility impact level encoded in a receipt.
- Failure
Stage - Stage of instruction execution at which a failure was recorded.
- Migration
Kind - The kind of migration.
- Phase
- Instruction execution phase encoded in a receipt.
- Policy
Requirement - What validation is required when a capability is active.
- Program
Error - Errors that a Solana program can return.
- Segment
Role - Segment role classification.
- Token
Program Kind - Which token program owns this account.
- Trust
Level - Trust level for foreign account validation.
Constants§
- ACCOUNT_
CLOSE_ CAPS - Capabilities for an account close instruction.
- ACCOUNT_
CLOSE_ POLICY - Capabilities for an account close instruction.
- ACCOUNT_
INIT_ CAPS - Capabilities for an account init instruction.
- ACCOUNT_
INIT_ POLICY - Capabilities for an account initialization instruction.
- ATA_
PROGRAM_ ID - Associated Token Account program.
- AUTHORITY_
CHANGE_ CAPS - Capabilities for an authority change instruction.
- AUTHORITY_
CHANGE_ POLICY - Capabilities for an instruction that modifies authority/permissions.
- CLOSE_
SENTINEL - Sentinel byte written to byte 0 when an account is closed. Prevents account revival attacks.
- EVENT_
CPI_ PREFIX - Event CPI prefix. Programs should check for this at dispatch entry
and return
Ok(())to allow self-CPI events to pass through. - EXTERNAL_
CALL_ CAPS - Capabilities for a CPI-invoking instruction.
- EXTERNAL_
CALL_ POLICY - Capabilities for an instruction that makes external calls via CPI.
- FAILED_
INVARIANT_ NONE - Sentinel value for
failed_invariant_idxmeaning “no invariant was associated with the failure”. - HEADER_
EXECUTABLE - Non-duplicate + executable.
- HEADER_
LEN - Header length in bytes.
- HEADER_
SIGNER - Non-duplicate + signer.
- HEADER_
SIGNER_ WRITABLE - Non-duplicate + signer + writable.
- HEADER_
WRITABLE - Non-duplicate + writable.
- JOURNAL_
TOUCH_ CAPS - Capabilities for a journal-writing instruction.
- JOURNAL_
TOUCH_ POLICY - Capabilities for an instruction that appends to a journal segment.
- MAX_
MEMO_ SIGNERS - Maximum signer accounts a single memo invocation may cite.
- MEMO_
PROGRAM_ ID - SPL Memo v2 program id:
MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr. - MIGRATION_
SENSITIVE_ CAPS - Capabilities for a migration/realloc instruction.
- MIGRATION_
SENSITIVE_ POLICY - Capabilities for an instruction that reallocates an account (migration-sensitive).
- NAMED_
POLICY_ PACKS - All named policy packs with full descriptors, in order.
- READ_
ONLY_ AUDIT_ CAPS - Capabilities for a read-only audit instruction.
- READ_
ONLY_ AUDIT_ POLICY - Capabilities for a read-only audit/inspection instruction.
- RECEIPT_
SIZE - Receipt summary size in bytes.
- RECEIPT_
SIZE_ LEGACY - Legacy receipt size, kept as a named constant for readers that want to quickly check if they received the shorter pre-0.2 receipt and ignore the failure-payload suffix.
- SEG_
ROLE_ AUDIT - SEG_
ROLE_ CACHE - SEG_
ROLE_ CORE - Segment role flags – convenience constants for
SegmentEntry::new(). - SEG_
ROLE_ EXTENSION - SEG_
ROLE_ INDEX - SEG_
ROLE_ JOURNAL - SEG_
ROLE_ SHARD - SHARD_
MUTATION_ CAPS - Capabilities for a shard-modifying instruction.
- SHARD_
MUTATION_ POLICY - Capabilities for an instruction that modifies shard data in a sharded account.
- SYSTEM_
PROGRAM_ ID - System program address: 11111111111111111111111111111111
- TOKEN_
2022_ PROGRAM_ ID - Token-2022 program.
- TOKEN_
PROGRAM_ ID - SPL Token program address.
- TREASURY_
WRITE_ CAPS - Capabilities for a treasury write instruction.
- TREASURY_
WRITE_ POLICY - Capabilities for an instruction that writes to treasury/vault balances.
Traits§
- Account
Meta Provider - Trait for types that provide static metadata about themselves.
- Explain
Account - Trait for accounts that can produce a structured explanation.
- Field
Map - Trait for layouts that expose field metadata in wire order.
- Fixed
Layout - Trait for types with a compile-time known wire size.
- From
Account - Trait for types that can be constructed from an AccountView with validation.
- HasView
- Helper trait for types that hold an
&AccountView. - Hopper
Accounts - Trait implemented by account structs (manually or via derive).
- Hopper
Ix - Trait defining a Hopper instruction.
- Hopper
Layout - Trait implemented by
hopper_layout!types providing layout metadata. - Instruction
Args - Trait for parsing instruction data into a typed args struct.
- Layout
Contract - A compile-time layout contract binding type identity to wire format.
- Pod
- Marker for types that can be safely overlaid on raw account bytes.
- Segment
Map - Compile-time segment layout for a zero-copy struct.
- Tail
Codec - Canonical serializer for dynamic-tail payloads.
- Transparent
Address - Marker trait for types that are
#[repr(transparent)]over[u8; 32]. - Validatable
- Trait for validation runnables (groups and graphs).
- Validate
Account - Trait for accounts that can self-validate.
- Validate
Args - Trait for args that can be validated independently of accounts.
- Wire
Type - Marker trait for types safe to use as zero-copy wire fields.
Functions§
- assert_
segment_ field_ alignment - Compile-time assertion that a type’s
SegmentMapandFieldMapare isomorphic: same count, same names, same offsets, same sizes. - bps_of
- Basis-point fee (floor):
amount * bps / 10_000. - bps_
of_ ceil - Basis-point fee (ceiling):
ceil(amount * bps / 10_000). - cast_
unchecked ⚠ - Raw unchecked cast from bytes to an immutable reference.
- cast_
unchecked_ ⚠mut - Raw unchecked cast from bytes to a mutable reference.
- check_
account - Combined account check: owner + discriminator + minimum size.
- check_
account_ fast - Fast single-compare account validation.
- check_
authority_ fast - Validate a signer + writable account (authority) with single u32 compare.
- check_
cooldown_ elapsed - Check that enough time has elapsed since the last operation.
- check_
deadline_ not_ passed - Check that a deadline has NOT passed (now < deadline).
- check_
discriminator - Check that the discriminator byte matches.
- check_
executable_ fast - Validate an executable (program) account with single u32 compare.
- check_
has_ one - Check
has_one: a stored address in account data matches another account’s address. - check_
invariant - Check a single invariant condition.
- check_
invariant_ fn - Check a single invariant with a closure (lazy evaluation).
- check_
keys_ eq - Check that two account addresses are equal.
- check_
lamport_ conservation - Verify SOL conservation: total lamports before == total lamports after.
- check_
no_ subsequent_ invocation - Ensure our program is not invoked after the current instruction.
- check_
owner - Check that an account is owned by the expected program.
- check_
owner_ multi - Check that an account is owned by one of the given program IDs.
- check_
rent_ exempt - Check that an account is rent exempt.
- check_
signer - Check that an account is a signer.
- check_
signer_ fast - Validate a signer account with single u32 compare.
- check_
size - Check minimum data size.
- check_
staleness - Check that data is not stale (updated recently enough).
- check_
state_ transition - Check that a state transition is valid.
- check_
writable - Check that an account is writable.
- check_
writable_ coherence - Validate that every writable account in the slice is also a signer OR is owned by our program.
- check_
writable_ fast - Validate a writable account with single u32 compare.
- checked_
add - Checked addition.
- checked_
div - Checked division (returns error on divide by zero).
- checked_
div_ ceil - Checked ceiling division:
ceil(a / b). - checked_
mul - Checked multiplication.
- checked_
mul_ div - Compute
(a * b) / cwith u128 intermediate to prevent overflow. - checked_
mul_ div_ ceil - Compute
ceil((a * b) / c)with u128 intermediate. - checked_
pow - Checked exponentiation via repeated squaring.
- checked_
sub - Checked subtraction.
- cpi_
invoke - Invoke a CPI with full validation.
- cpi_
invoke_ signed - Invoke a signed CPI with full validation.
- cpi_
set_ return_ data - Set return data for the current instruction.
- detect_
flash_ loan_ bracket - Detect flash-loan bracket: same program called before AND after current.
- dispatch_
instruction - Read a 1-byte dispatch tag from instruction data.
- dispatch_
instruction_ 8 - Read an 8-byte discriminator (Anchor/Quasar compatible).
- dispatch_
instruction_ u16 - Read a 2-byte dispatch tag (for programs with >256 instructions).
- div_
ceil - Compute
ceil(a / b)without overflow (for u64). - emit_
event - Emit a Pod event via
sol_log_data. - emit_
event_ tagged - Emit event with a discriminator prefix for easy client-side filtering.
- emit_
slices - Emit one or more byte slices as a single
sol_log_dataentry. - find_
and_ verify_ pda - Find a PDA and verify it matches the account, returning the bump.
- hopper_
entry - Typed instruction entry point.
- init_
header - Initialize an account’s header from a layout contract type.
- interface_
transfer_ checked - Polymorphic
TransferCheckedCPI that dispatches to the program that owns the source token account. - interface_
transfer_ checked_ signed - PDA-signing variant of
interface_transfer_checked. - is_
zero_ address - Check if a 32-byte address is all zeros (the default/system address).
- keys_
eq_ fast - Fast 32-byte key equality check using 4x u64 comparisons.
- load_
foreign_ with_ profile - Load a foreign account with a trust profile, returning a typed overlay.
- migrate_
append - Migrate an account in-place by appending new fields.
- pod_
from_ bytes - Zero-copy cast from bytes to an immutable reference.
- pod_
from_ bytes_ mut - Zero-copy cast from bytes to a mutable reference.
- pod_
read - Copy a Pod value from bytes (alignment-safe).
- pod_
write - Write a Pod value to bytes (alignment-safe).
- read_
disc - Read the discriminator from account data (byte 0).
- read_
layout_ id - Read the 8-byte layout_id from account data (bytes 4..12).
- read_
version - Read the version from account data (byte 1).
- rent_
exempt_ min - Rent-exempt minimum lamports for a given data size.
- require_
all_ unique - Verify that all accounts in a slice have unique addresses.
- require_
all_ unique_ accounts - Validate that all account addresses are unique.
- require_
authority - Validate an authority account: must be signer, owned by expected program.
- require_
data_ min - Validate minimum instruction data length.
- require_
keys_ equal - Validate two accounts have the same key (e.g., stored address == provided account).
- require_
lamports_ gte - Validate that an account has at least
minlamports. - require_
owned_ at - Validate that a specific account is owned by the program.
- require_
owned_ writable - Validate a writable program-owned account.
- require_
signer_ at - Validate that a specific account is a signer.
- require_
top_ level - Require that the current instruction is top-level (not a CPI).
- require_
unique - Validate two accounts are different (no duplicates).
- require_
unique_ signer_ accounts - Validate that no duplicated account is used as a signer.
- require_
unique_ signers - Verify that no duplicated account is used as a signer.
- require_
unique_ writable - Verify that no duplicated account is writable.
- require_
unique_ writable_ accounts - Validate that no duplicated account is writable.
- require_
writable_ at - Validate that a specific account is writable.
- scale_
amount - Scale a token amount between different decimal precisions (floor).
- scale_
amount_ ceil - Scale a token amount between decimal precisions, rounding up.
- scale_
bps - Scale a value in basis points (BPS).
value * bps / 10_000, with overflow protection via u128 intermediate. - scale_
fraction - Scale a value by a fraction
(numerator / denominator). - segment_
id - Compute a segment ID from a name (const FNV-1a hash, truncated to 4 bytes).
- snapshot_
lamports - Snapshot lamport values for conservation checking.
- to_u64
- Safe narrowing cast from u128 to u64.
- verify_
pda - Verify a PDA with bump, using the cheap
create_program_addresspath. - verify_
pda_ cached - Verify a PDA by reading the bump from account data at a known offset.
- write_
header - Write a complete Hopper header to the beginning of
data. - zero_
init - Zero-initialize a byte slice. Must be called before
write_header.
Type Aliases§
- Program
Result - Result type returned by all Hopper instruction handlers.
- Segment
Id - A 4-byte segment identifier, computed from a name at compile time.
- Token
- Alias for
TokenAccount.