Overview
TheProgram class is the primary interface for interacting with Anchor programs. It provides a type-safe, IDL-driven API for sending transactions, fetching accounts, and listening to events.
Constructor
Creates a new Program instance.
Static Methods
Fetches the IDL from the blockchain and creates a Program instance.
Fetches the IDL from the blockchain without creating a Program instance.
Properties
The on-chain address of the program.
The IDL in camelCase format for TypeScript compatibility.
The original IDL without camelCase conversion (snake_case from Rust).
The wallet and network provider used by this program.
The coder used for serializing and deserializing data.
Namespaces
methods
The recommended builder API for constructing and sending transactions.The methods namespace provides:
.accounts()- Set instruction accounts.signers()- Add transaction signers.remainingAccounts()- Add extra accounts.preInstructions()- Add instructions before.postInstructions()- Add instructions after.rpc()- Send and confirm transaction.instruction()- Build TransactionInstruction.transaction()- Build Transaction.simulate()- Simulate transaction.view()- Call read-only instruction
account
Provides access to account clients for fetching and subscribing to account data.See AccountClient for full details.
rpc (deprecated)
Legacy API for sending signed transactions. Use
methods instead.transaction (deprecated)
Legacy API for building Transaction objects. Use
methods instead.simulate (deprecated)
Legacy API for simulating transactions. Use
methods instead.instruction (deprecated)
Legacy API for building TransactionInstruction objects. Use
methods instead.Event Handling
Subscribe to program events emitted in transaction logs.
Unsubscribe from a program event.