    import {Connection} from '@solana/web3'

public class | source

# Connection

A connection to a fullnode JSON RPC endpoint

## Constructor Summary

Public Constructor
public | constructor(endpoint: string, commitment: Commitment) Establish a JSON RPC connection |

## Method Summary

Public Methods
public | async confirmTransaction(signature: TransactionSignature, commitment: Commitment): Promise<boolean> Confirm the transaction identified by the specified signature |
public | async getAccountInfo(publicKey: PublicKey, commitment: Commitment): Promise<AccountInfo> Fetch all the account info for the specified public key |
public | async getBalance(publicKey: PublicKey, commitment: Commitment): Promise<number> Fetch the balance for the specified public key |
public | async getClusterNodes(): Promise<Array<ContactInfo>> Return the list of nodes that are currently participating in the cluster |
public | async getEpochInfo(commitment: Commitment): Promise<GetEpochInfoRpcResult> Fetch the Epoch Info parameters |
public | async getEpochSchedule(): Promise<GetEpochScheduleRpcResult> Fetch the Epoch Schedule parameters |
public | async getInflation(commitment: Commitment): Promise<GetInflationRpcResult> Fetch the cluster Inflation parameters |
public | async getMinimumBalanceForRentExemption(dataLength: number, commitment: Commitment): Promise<number> Fetch the minimum balance needed to exempt an account of `dataLength` size from rent |
public | async getProgramAccounts(programId: PublicKey, commitment: Commitment): Promise<Array<PublicKeyAndAccount>> Fetch all the accounts owned by the specified program id |
public | async getRecentBlockhash(commitment: Commitment): Promise<BlockhashAndFeeCalculator> Fetch a recent blockhash from the cluster |
public | async getSignatureStatus(signature: TransactionSignature, commitment: Commitment): Promise<SignatureSuccess|TransactionError|nullliteral> Fetch the current transaction count of the cluster |
public | async getSlot(commitment: Commitment): Promise<number> Fetch the current slot that the node is processing |
public | async getSlotLeader(commitment: Commitment): Promise<string> Fetch the current slot leader of the cluster |
public | async getTotalSupply(commitment: Commitment): Promise<number> Fetch the current total currency supply of the cluster in lamports |
public | async getTransactionCount(commitment: Commitment): Promise<number> Fetch the current transaction count of the cluster |
public | async getVoteAccounts(commitment: Commitment): Promise<VoteAccountStatus> Return the list of nodes that are currently participating in the cluster |
public | onAccountChange(publicKey: PublicKey, callback: AccountChangeCallback): number Register a callback to be invoked whenever the specified account changes |
public | onProgramAccountChange(programId: PublicKey, callback: ProgramAccountChangeCallback): number Register a callback to be invoked whenever accounts owned by the specified program change |
public | async removeAccountChangeListener(id: number): Promise<void> Deregister an account notification callback |
public | async removeProgramAccountChangeListener(id: number): Promise<void> Deregister an account notification callback |
public | async requestAirdrop(to: PublicKey, amount: number, commitment: Commitment): Promise<TransactionSignature> Request an allocation of lamports to the specified account |
public | async sendRawTransaction(rawTransaction: Buffer): Promise<TransactionSignature> Send a transaction that has already been signed and serialized into the wire format |
public | async sendTransaction(transaction: Transaction, signers: ...Array<Account>): Promise<TransactionSignature> Sign and send a transaction |

## Public Constructors

### public constructor(endpoint: string, commitment: Commitment) source

Establish a JSON RPC connection

#### Params:

Name | Type | Attribute | Description
endpoint | string |  | URL to the fullnode JSON RPC endpoint
commitment | Commitment | nullable: true | optional default commitment level

## Public Methods

### public async confirmTransaction(signature: TransactionSignature, commitment: Commitment): Promise<boolean> source

Confirm the transaction identified by the specified signature

#### Params:

Name | Type | Attribute | Description
signature | TransactionSignature |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<boolean>

### public async getAccountInfo(publicKey: PublicKey, commitment: Commitment): Promise<AccountInfo> source

Fetch all the account info for the specified public key

#### Params:

Name | Type | Attribute | Description
publicKey | PublicKey |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<AccountInfo>

### public async getBalance(publicKey: PublicKey, commitment: Commitment): Promise<number> source

Fetch the balance for the specified public key

#### Params:

Name | Type | Attribute | Description
publicKey | PublicKey |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<number>

### public async getClusterNodes(): Promise<Array<ContactInfo>> source

Return the list of nodes that are currently participating in the cluster

#### Return:

Promise<Array<ContactInfo>>

### public async getEpochInfo(commitment: Commitment): Promise<GetEpochInfoRpcResult> source

Fetch the Epoch Info parameters

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<GetEpochInfoRpcResult>

### public async getEpochSchedule(): Promise<GetEpochScheduleRpcResult> source

Fetch the Epoch Schedule parameters

#### Return:

Promise<GetEpochScheduleRpcResult>

### public async getInflation(commitment: Commitment): Promise<GetInflationRpcResult> source

Fetch the cluster Inflation parameters

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<GetInflationRpcResult>

### public async getMinimumBalanceForRentExemption(dataLength: number, commitment: Commitment): Promise<number> source

Fetch the minimum balance needed to exempt an account of `dataLength` size from rent

#### Params:

Name | Type | Attribute | Description
dataLength | number |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<number>

### public async getProgramAccounts(programId: PublicKey, commitment: Commitment): Promise<Array<PublicKeyAndAccount>> source

Fetch all the accounts owned by the specified program id

#### Params:

Name | Type | Attribute | Description
programId | PublicKey |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<Array<PublicKeyAndAccount>>

### public async getRecentBlockhash(commitment: Commitment): Promise<BlockhashAndFeeCalculator> source

Fetch a recent blockhash from the cluster

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<BlockhashAndFeeCalculator>

### public async getSignatureStatus(signature: TransactionSignature, commitment: Commitment): Promise<SignatureSuccess|TransactionError|nullliteral> source

Fetch the current transaction count of the cluster

#### Params:

Name | Type | Attribute | Description
signature | TransactionSignature |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<SignatureSuccess|TransactionError|nullliteral>

### public async getSlot(commitment: Commitment): Promise<number> source

Fetch the current slot that the node is processing

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<number>

### public async getSlotLeader(commitment: Commitment): Promise<string> source

Fetch the current slot leader of the cluster

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<string>

### public async getTotalSupply(commitment: Commitment): Promise<number> source

Fetch the current total currency supply of the cluster in lamports

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<number>

### public async getTransactionCount(commitment: Commitment): Promise<number> source

Fetch the current transaction count of the cluster

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<number>

### public async getVoteAccounts(commitment: Commitment): Promise<VoteAccountStatus> source

Return the list of nodes that are currently participating in the cluster

#### Params:

Name | Type | Attribute | Description
commitment | Commitment | nullable: true |

#### Return:

Promise<VoteAccountStatus>

### public onAccountChange(publicKey: PublicKey, callback: AccountChangeCallback): number source

Register a callback to be invoked whenever the specified account changes

#### Params:

Name | Type | Attribute | Description
publicKey | PublicKey |  | Public key of the account to monitor
callback | AccountChangeCallback |  | Function to invoke whenever the account is changed

#### Return:

number | subscription id

### public onProgramAccountChange(programId: PublicKey, callback: ProgramAccountChangeCallback): number source

Register a callback to be invoked whenever accounts owned by the specified program change

#### Params:

Name | Type | Attribute | Description
programId | PublicKey |  | Public key of the program to monitor
callback | ProgramAccountChangeCallback |  | Function to invoke whenever the account is changed

#### Return:

number | subscription id

### public async removeAccountChangeListener(id: number): Promise<void> source

Deregister an account notification callback

#### Params:

Name | Type | Attribute | Description
id | number |  | subscription id to deregister

#### Return:

Promise<void>

### public async removeProgramAccountChangeListener(id: number): Promise<void> source

Deregister an account notification callback

#### Params:

Name | Type | Attribute | Description
id | number |  | subscription id to deregister

#### Return:

Promise<void>

### public async requestAirdrop(to: PublicKey, amount: number, commitment: Commitment): Promise<TransactionSignature> source

Request an allocation of lamports to the specified account

#### Params:

Name | Type | Attribute | Description
to | PublicKey |  |
amount | number |  |
commitment | Commitment | nullable: true |

#### Return:

Promise<TransactionSignature>

### public async sendRawTransaction(rawTransaction: Buffer): Promise<TransactionSignature> source

Send a transaction that has already been signed and serialized into the wire format

#### Params:

Name | Type | Attribute | Description
rawTransaction | Buffer |  |

#### Return:

Promise<TransactionSignature>

### public async sendTransaction(transaction: Transaction, signers: ...Array<Account>): Promise<TransactionSignature> source

Sign and send a transaction

#### Params:

Name | Type | Attribute | Description
transaction | Transaction |  |
signers | ...Array<Account> |  |

#### Return:

Promise<TransactionSignature>