Options
All
  • Public
  • Public/Protected
  • All
Menu

A connection to a fullnode JSON RPC endpoint

Hierarchy

  • Connection

Index

Constructors

constructor

  • Establish a JSON RPC connection

    Parameters

    • endpoint: string

      URL to the fullnode JSON RPC endpoint

    • Optional commitmentOrConfig: Commitment | ConnectionConfig

      optional default commitment level or optional ConnectionConfig configuration object

    Returns Connection

Accessors

commitment

Methods

_buildArgs

  • _buildArgs(args: any[], override?: Commitment, encoding?: "jsonParsed" | "base64", extra?: any): any[]

confirmTransaction

getAccountInfo

getAccountInfoAndContext

getBalance

getBalanceAndContext

getBlock

getBlockTime

  • getBlockTime(slot: number): Promise<null | number>
  • Fetch the estimated production time of a block

    Parameters

    • slot: number

    Returns Promise<null | number>

getBlocks

  • getBlocks(startSlot: number, endSlot?: number, commitment?: Finality): Promise<number[]>
  • Fetch confirmed blocks between two slots

    Parameters

    • startSlot: number
    • Optional endSlot: number
    • Optional commitment: Finality

    Returns Promise<number[]>

getClusterNodes

getConfirmedBlock

  • Fetch a list of Transactions and transaction statuses from the cluster for a confirmed block.

    deprecated

    Deprecated since v1.13.0. Please use getBlock instead.

    Parameters

    • slot: number
    • Optional commitment: Finality

    Returns Promise<ConfirmedBlock>

getConfirmedBlockSignatures

getConfirmedSignaturesForAddress

  • getConfirmedSignaturesForAddress(address: PublicKey, startSlot: number, endSlot: number): Promise<string[]>
  • Fetch a list of all the confirmed signatures for transactions involving an address within a specified slot range. Max range allowed is 10,000 slots.

    deprecated

    Deprecated since v1.3. Please use getConfirmedSignaturesForAddress2 instead.

    Parameters

    • address: PublicKey

      queried address

    • startSlot: number

      start slot, inclusive

    • endSlot: number

      end slot, inclusive

    Returns Promise<string[]>

getConfirmedSignaturesForAddress2

getConfirmedTransaction

getEpochInfo

getEpochSchedule

getFeeCalculatorForBlockhash

getFirstAvailableBlock

  • getFirstAvailableBlock(): Promise<number>
  • Fetch the slot of the lowest confirmed block that has not been purged from the ledger

    Returns Promise<number>

getGenesisHash

  • getGenesisHash(): Promise<string>

getInflationGovernor

getInflationReward

getLargestAccounts

getLeaderSchedule

getMinimumBalanceForRentExemption

  • getMinimumBalanceForRentExemption(dataLength: number, commitment?: Commitment): Promise<number>
  • Fetch the minimum balance needed to exempt an account of dataLength size from rent

    Parameters

    Returns Promise<number>

getMinimumLedgerSlot

  • getMinimumLedgerSlot(): Promise<number>
  • Fetch the lowest slot that the node has information about in its ledger. This value may increase over time if the node is configured to purge older ledger data

    Returns Promise<number>

getMultipleAccountsInfo

getNonce

getNonceAndContext

getParsedAccountInfo

getParsedConfirmedTransaction

getParsedConfirmedTransactions

getParsedProgramAccounts

getParsedTokenAccountsByOwner

getProgramAccounts

getRecentBlockhash

getRecentBlockhashAndContext

getRecentPerformanceSamples

  • getRecentPerformanceSamples(limit?: number): Promise<PerfSample[]>

getSignatureStatus

getSignatureStatuses

getSignaturesForAddress

getSlot

getSlotLeader

  • getSlotLeader(commitment?: Commitment): Promise<string>

getSlotLeaders

  • getSlotLeaders(startSlot: number, limit: number): Promise<PublicKey[]>
  • Fetch limit number of slot leaders starting from startSlot

    Parameters

    • startSlot: number

      fetch slot leaders starting from this slot

    • limit: number

      number of slot leaders to return

    Returns Promise<PublicKey[]>

getStakeActivation

getSupply

getTokenAccountBalance

getTokenAccountsByOwner

getTokenLargestAccounts

getTokenSupply

getTotalSupply

  • getTotalSupply(commitment?: Commitment): Promise<number>
  • Fetch the current total currency supply of the cluster in lamports

    deprecated

    Deprecated since v1.2.8. Please use getSupply instead.

    Parameters

    Returns Promise<number>

getTransaction

getTransactionCount

  • getTransactionCount(commitment?: Commitment): Promise<number>

getVersion

getVoteAccounts

onAccountChange

  • Register a callback to be invoked whenever the specified account changes

    Parameters

    • publicKey: PublicKey

      Public key of the account to monitor

    • callback: AccountChangeCallback

      Function to invoke whenever the account is changed

    • Optional commitment: Commitment

      Specify the commitment level account changes must reach before notification

    Returns number

    subscription id

onLogs

onProgramAccountChange

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

    Parameters

    • programId: PublicKey

      Public key of the program to monitor

    • callback: ProgramAccountChangeCallback

      Function to invoke whenever the account is changed

    • Optional commitment: Commitment

      Specify the commitment level account changes must reach before notification

    • Optional filters: GetProgramAccountsFilter[]

      The program account filters to pass into the RPC method

    Returns number

    subscription id

onRootChange

  • Register a callback to be invoked upon root changes

    Parameters

    Returns number

    subscription id

onSignature

  • Register a callback to be invoked upon signature updates

    Parameters

    • signature: string

      Transaction signature string in base 58

    • callback: SignatureResultCallback

      Function to invoke on signature notifications

    • Optional commitment: Commitment

      Specify the commitment level signature must reach before notification

    Returns number

    subscription id

onSignatureWithOptions

  • Register a callback to be invoked when a transaction is received and/or processed.

    Parameters

    • signature: string

      Transaction signature string in base 58

    • callback: SignatureSubscriptionCallback

      Function to invoke on signature notifications

    • Optional options: SignatureSubscriptionOptions

      Enable received notifications and set the commitment level that signature must reach before notification

    Returns number

    subscription id

onSlotChange

  • Register a callback to be invoked upon slot changes

    Parameters

    Returns number

    subscription id

onSlotUpdate

  • Register a callback to be invoked upon slot updates. SlotUpdate's may be useful to track live progress of a cluster.

    Parameters

    Returns number

    subscription id

removeAccountChangeListener

  • removeAccountChangeListener(id: number): Promise<void>
  • Deregister an account notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

removeOnLogsListener

  • removeOnLogsListener(id: number): Promise<void>
  • Deregister a logs callback.

    Parameters

    • id: number

      subscription id to deregister.

    Returns Promise<void>

removeProgramAccountChangeListener

  • removeProgramAccountChangeListener(id: number): Promise<void>
  • Deregister an account notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

removeRootChangeListener

  • removeRootChangeListener(id: number): Promise<void>
  • Deregister a root notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

removeSignatureListener

  • removeSignatureListener(id: number): Promise<void>
  • Deregister a signature notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

removeSlotChangeListener

  • removeSlotChangeListener(id: number): Promise<void>
  • Deregister a slot notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

removeSlotUpdateListener

  • removeSlotUpdateListener(id: number): Promise<void>
  • Deregister a slot update notification callback

    Parameters

    • id: number

      subscription id to deregister

    Returns Promise<void>

requestAirdrop

  • requestAirdrop(to: PublicKey, lamports: number): Promise<string>
  • Request an allocation of lamports to the specified address

    import { Connection, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";

    (async () => {
    const connection = new Connection("https://api.testnet.solana.com", "confirmed");
    const myAddress = new PublicKey("2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM");
    const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);
    await connection.confirmTransaction(signature);
    })();

    Parameters

    Returns Promise<string>

sendEncodedTransaction

  • sendEncodedTransaction(encodedTransaction: string, options?: SendOptions): Promise<string>
  • Send a transaction that has already been signed, serialized into the wire format, and encoded as a base64 string

    Parameters

    • encodedTransaction: string
    • Optional options: SendOptions

    Returns Promise<string>

sendRawTransaction

  • sendRawTransaction(rawTransaction: Buffer | Uint8Array | number[], options?: SendOptions): Promise<string>
  • Send a transaction that has already been signed and serialized into the wire format

    Parameters

    • rawTransaction: Buffer | Uint8Array | number[]
    • Optional options: SendOptions

    Returns Promise<string>

sendTransaction

simulateTransaction

Generated using TypeDoc