# Class: BanksClient
A client for the ledger state, from the perspective of an arbitrary validator.
The client is used to send transactions and query account data, among other things.
Use start()
to initialize a BanksClient.
# Table of contents
# Constructors
# Properties
# Methods
- getAccount
- getBalance
- getBlockHeight
- getClock
- getFeeForMessage
- getLatestBlockhash
- getRent
- getSlot
- getTransactionStatus
- getTransactionStatuses
- processTransaction
- sendTransaction
- simulateTransaction
- tryProcessTransaction
# Constructors
# constructor
• new BanksClient(inner
)
# Parameters
Name | Type |
---|---|
inner | BanksClient |
# Defined in
index.ts:197 (opens new window)
# Properties
# inner
• Private
inner: BanksClient
# Defined in
index.ts:200 (opens new window)
# Methods
# getAccount
▸ getAccount(address
, commitment?
): Promise
<AccountInfoBytes
>
Return the account at the given address at the slot corresponding to the given commitment level. If the account is not found, None is returned.
# Parameters
Name | Type | Description |
---|---|---|
address | PublicKey | The account address to look up. |
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<AccountInfoBytes
>
The account object, if the account exists.
# Defined in
index.ts:209 (opens new window)
# getBalance
▸ getBalance(address
, commitment?
): Promise
<bigint
>
Return the balance in lamports of an account at the given address at the slot.
# Parameters
Name | Type | Description |
---|---|---|
address | PublicKey | The account to look up. |
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<bigint
>
The account balance in lamports.
# Defined in
index.ts:371 (opens new window)
# getBlockHeight
▸ getBlockHeight(commitment?
): Promise
<bigint
>
Get the current block height.
# Parameters
Name | Type | Description |
---|---|---|
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<bigint
>
The current block height.
# Defined in
index.ts:345 (opens new window)
# getClock
▸ getClock(): Promise
<Clock
>
Get the cluster clock.
# Returns
Promise
<Clock
>
the clock object.
# Defined in
index.ts:361 (opens new window)
# getFeeForMessage
▸ getFeeForMessage(msg
, commitment?
): Promise
<bigint
>
Get the fee in lamports for a given message.
# Parameters
Name | Type | Description |
---|---|---|
msg | Message | The message to check. |
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<bigint
>
The fee for the given message.
# Defined in
index.ts:402 (opens new window)
# getLatestBlockhash
▸ getLatestBlockhash(commitment?
): Promise
<[string
, bigint
]>
Returns latest blockhash and last valid block height for given commitment level.
# Parameters
Name | Type | Description |
---|---|---|
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<[string
, bigint
]>
The blockhash and last valid block height.
# Defined in
index.ts:386 (opens new window)
# getRent
▸ getRent(): Promise
<Rent
>
Get the cluster rent.
# Returns
Promise
<Rent
>
The rent object.
# Defined in
index.ts:353 (opens new window)
# getSlot
▸ getSlot(commitment?
): Promise
<bigint
>
Get the slot that has reached the given commitment level (or the default commitment).
# Parameters
Name | Type | Description |
---|---|---|
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<bigint
>
The current slot.
# Defined in
index.ts:336 (opens new window)
# getTransactionStatus
▸ getTransactionStatus(signature
): Promise
<TransactionStatus
>
Return the status of a transaction with a signature matching the transaction's first signature.
Return None if the transaction is not found, which may be because the blockhash was expired or the fee-paying account had insufficient funds to pay the transaction fee. Note that servers rarely store the full transaction history. This method may return None if the transaction status has been discarded.
# Parameters
Name | Type | Description |
---|---|---|
signature | string | The transaction signature (the first signature of the transaction). |
# Returns
Promise
<TransactionStatus
>
The transaction status, if found.
# Defined in
index.ts:312 (opens new window)
# getTransactionStatuses
▸ getTransactionStatuses(signatures
): Promise
<TransactionStatus
[]>
Same as getTransactionStatus
, but for multiple transactions.
# Parameters
Name | Type | Description |
---|---|---|
signatures | string [] | The transaction signatures. |
# Returns
Promise
<TransactionStatus
[]>
The transaction statuses, if found.
# Defined in
index.ts:324 (opens new window)
# processTransaction
▸ processTransaction(tx
): Promise
<BanksTransactionMeta
>
Process a transaction and return the result with metadata.
# Parameters
Name | Type | Description |
---|---|---|
tx | Transaction | VersionedTransaction | The transaction to send. |
# Returns
Promise
<BanksTransactionMeta
>
The transaction result and metadata.
# Defined in
index.ts:239 (opens new window)
# sendTransaction
▸ sendTransaction(tx
): Promise
<void
>
Send a transaction and return immediately.
# Parameters
Name | Type | Description |
---|---|---|
tx | Transaction | VersionedTransaction | The transaction to send. |
# Returns
Promise
<void
>
# Defined in
index.ts:224 (opens new window)
# simulateTransaction
▸ simulateTransaction(tx
, commitment?
): Promise
<BanksTransactionResultWithMeta
>
Simulate a transaction at the given commitment level.
# Parameters
Name | Type | Description |
---|---|---|
tx | Transaction | VersionedTransaction | The transaction to simulate. |
commitment? | Commitment | The commitment to use. |
# Returns
Promise
<BanksTransactionResultWithMeta
>
The transaction simulation result.
# Defined in
index.ts:281 (opens new window)
# tryProcessTransaction
▸ tryProcessTransaction(tx
): Promise
<BanksTransactionResultWithMeta
>
Try to process a transaction and return the result with metadata.
If the transaction errors, a JS error is not raised.
Instead the returned object's result
field will contain an error message.
This makes it easier to process transactions that you expect to fail and make assertions about things like log messages.
# Parameters
Name | Type | Description |
---|---|---|
tx | Transaction | VersionedTransaction | The transaction to send. |
# Returns
Promise
<BanksTransactionResultWithMeta
>
The transaction result and metadata.