A set of accounts mapping one-to-one to the program's accounts struct, i.e.,
the type deriving #[derive(Accounts)]
.
The name of each field should match the name for that account in the IDL.
If multiple accounts are nested in the rust program, then they should be nested here.
An address to identify an account on chain. Can be a PublicKey, or Base 58 encoded string.
Context provides all non-argument inputs for generating Anchor transactions.
Accounts used in the instruction context.
Commitment parameters to use for a transaction.
Instructions to run after a given method. Often this is used, for example to close accounts after executing a method.
Instructions to run before a given method. Often this is used, for example to create accounts prior to executing a method.
All accounts to pass into an instruction after the main accounts
.
This can be used for optional or otherwise unknown accounts.
Accounts that must sign a given transaction.
Function to create a TransactionInstruction
generated from an IDL.
Additionally it provides an accounts
utility method, returning a list
of ordered accounts for the instruction.
The namespace provides functions to build TransactionInstruction objects for each method of a program.
instruction.<method>(...args, ctx);
args
- The positional arguments for the program. The type and number
of these arguments depend on the program being used.ctx
- Context non-argument parameters to pass to the method.
Always the last parameter in the method call.To create an instruction for the increment
method above,
const tx = await program.instruction.increment({
accounts: {
counter,
},
});
RpcFn is a single RPC method generated from an IDL, sending a transaction paid for and signed by the configured provider.
The namespace provides async methods to send signed transactions for each non-state method on Anchor program.
Keys are method names, values are RPC functions returning a TransactionInstruction.
rpc.<method>(...args, ctx);
args
- The positional arguments for the program. The type and number
of these arguments depend on the program being used.ctx
- Context non-argument parameters to pass to the method.
Always the last parameter in the method call.
## Example
To send a transaction invoking the `increment` method above,
```javascript
const txSignature = await program.rpc.increment({
accounts: {
counter,
authority,
},
});
SimulateFn is a single method generated from an IDL. It simulates a method against a cluster configured by the provider, returning a list of all the events and raw logs that were emitted during the execution of the method.
The namespace provides functions to simulate transactions for each method of a program, returning a list of deserialized events and raw program logs.
One can use this to read data calculated from a program on chain, by
emitting an event in the program and reading the emitted event client side
via the simulate
namespace.
program.simulate.<method>(...args, ctx);
args
- The positional arguments for the program. The type and number
of these arguments depend on the program being used.ctx
- Context non-argument parameters to pass to the method.
Always the last parameter in the method call.To simulate the increment
method above,
const events = await program.simulate.increment({
accounts: {
counter,
},
});
System IDL.
Tx is a function to create a Transaction
for a given program instruction.
The namespace provides functions to build Transaction objects for each method of a program.
program.transaction.<method>(...args, ctx);
args
- The positional arguments for the program. The type and number
of these arguments depend on the program being used.ctx
- Context non-argument parameters to pass to the method.
Always the last parameter in the method call.To create an instruction for the increment
method above,
const tx = await program.transaction.increment({
accounts: {
counter,
},
});
ViewFn is a single method generated from an IDL. It simulates a method against a cluster configured by the provider, and then parses the events and extracts return data from the raw logs emitted during the simulation.
Number of bytes in anchor discriminators
Returns the default provider being used by the client.
Sets the default provider on the client.
Generated using TypeDoc
The namespace provides handles to an AccountClient object for each account in a program.
Usage
Example
To fetch a
Counter
account from the above example,For the full API, see the AccountClient reference.