Overview
TheProvider interface and AnchorProvider class manage the wallet and network context for Anchor programs. They handle transaction signing, sending, and confirmation.
Provider Interface
The baseProvider interface defines the contract for network and wallet interactions.
Properties
The Solana RPC connection to the cluster.
The public key of the wallet, if available.
The wallet instance used for signing transactions.
AnchorProvider
The standard implementation of theProvider interface.
Constructor
Creates a new AnchorProvider instance.
Static Methods
Returns the default confirmation options.
Creates a provider with a wallet from the local filesystem. Node.js only.
Creates a provider from the
ANCHOR_PROVIDER_URL environment variable. Node.js only.Instance Properties
The Solana cluster connection.
The wallet instance for signing transactions.
The public key of the wallet.
Default transaction confirmation options.
Methods
Sends a transaction, waits for confirmation, and returns the signature.
Sends multiple transactions in parallel and waits for all confirmations.
simulate
async (tx, signers?, commitment?, includeAccounts?) => Promise<SuccessfulTxSimulationResponse>
Simulates a transaction without sending it to the network.
Wallet Interface
TheWallet interface defines how wallets sign transactions.
Signs a single transaction.
Signs multiple transactions.
The wallet’s public key.
Helper Functions
Sets the global default provider.
Gets the current global provider.