Options
All
  • Public
  • Public/Protected
  • All
Menu

A connection to a fullnode JSON RPC endpoint

Hierarchy

  • Connection

Index

Constructors

Properties

Accessors

Methods

Constructors

  • 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

Properties

confirmTransactionUsingBlockHeightExceedanceStrategy: any
confirmTransactionUsingDurableNonceStrategy: any
confirmTransactionUsingLegacyTimeoutStrategy: any
getCancellationPromise: any
getTransactionConfirmationPromise: any

Accessors

  • The default commitment used for requests

    Returns undefined | Commitment

  • get rpcEndpoint(): string
  • The RPC endpoint

    Returns string

Methods

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

    • args: any[]
    • Optional override: Commitment
    • Optional encoding: "base64" | "jsonParsed"
    • Optional extra: any

    Returns any[]

  • Fetch all the account info for the specified public key

    Parameters

    Returns Promise<null | AccountInfo<Buffer>>

  • Fetch the balance for the specified public key

    Parameters

    Returns Promise<number>

  • Fetch a processed block from the cluster.

    deprecated

    Instead, call getBlock using a GetVersionedBlockConfig by setting the maxSupportedTransactionVersion property.

    Parameters

    Returns Promise<null | BlockResponse>

  • deprecated

    Instead, call getBlock using a GetVersionedBlockConfig by setting the maxSupportedTransactionVersion property.

    Parameters

    • slot: number
    • rawConfig: GetBlockConfig & { transactionDetails: "accounts" }

    Returns Promise<null | VersionedAccountsModeBlockResponse>

  • deprecated

    Instead, call getBlock using a GetVersionedBlockConfig by setting the maxSupportedTransactionVersion property.

    Parameters

    • slot: number
    • rawConfig: GetBlockConfig & { transactionDetails: "none" }

    Returns Promise<null | VersionedNoneModeBlockResponse>

  • Fetch a processed block from the cluster.

    Parameters

    Returns Promise<null | VersionedBlockResponse>

  • Parameters

    Returns Promise<null | VersionedAccountsModeBlockResponse>

  • Parameters

    Returns Promise<null | VersionedNoneModeBlockResponse>

  • Parameters

    Returns Promise<number>

  • Parameters

    Returns Promise<RpcResponseAndContext<Readonly<{ byIdentity: Readonly<Record<string, readonly number[]>>; range: Readonly<{ firstSlot: number; lastSlot: number }> }>>>

  • Fetch a list of Signatures from the cluster for a block, excluding rewards

    Parameters

    • slot: number
    • Optional commitment: Finality

    Returns Promise<BlockSignatures>

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

    Parameters

    • slot: number

    Returns Promise<null | number>

  • 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[]>

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

    Returns Promise<ContactInfo[]>

  • 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>

  • Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards

    deprecated

    Deprecated since Solana v1.8.0. Please use getBlockSignatures instead.

    Parameters

    • slot: number
    • Optional commitment: Finality

    Returns Promise<BlockSignatures>

  • 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[]>

  • Fetch a transaction details for a confirmed transaction

    deprecated

    Deprecated since Solana v1.8.0. Please use getTransaction instead.

    Parameters

    • signature: string
    • Optional commitment: Finality

    Returns Promise<null | ConfirmedTransaction>

  • Fetch the Epoch Info parameters

    Parameters

    Returns Promise<EpochInfo>

  • Fetch the Epoch Schedule parameters

    Returns Promise<EpochSchedule>

  • Fetch the fee calculator for a recent blockhash from the cluster, return with context

    deprecated

    Deprecated since Solana v1.8.0. Please use getFeeForMessage instead.

    Parameters

    Returns Promise<RpcResponseAndContext<null | FeeCalculator>>

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

    Returns Promise<number>

  • getGenesisHash(): Promise<string>
  • Fetch the genesis hash

    Returns Promise<string>

  • Fetch the cluster InflationGovernor parameters

    Parameters

    Returns Promise<InflationGovernor>

  • Fetch the specific inflation values for the current epoch

    Returns Promise<InflationRate>

  • Fetch the latest blockhash from the cluster

    Parameters

    Returns Promise<Readonly<{ blockhash: string; lastValidBlockHeight: number }>>

  • Fetch the latest blockhash from the cluster

    Parameters

    Returns Promise<RpcResponseAndContext<Readonly<{ blockhash: string; lastValidBlockHeight: number }>>>

  • Fetch the leader schedule for the current epoch

    Returns Promise<LeaderSchedule>

  • 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(): 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>

  • Fetch all the account info for multiple accounts specified by an array of public keys

    Parameters

    Returns Promise<(null | AccountInfo<Buffer>)[]>

  • Fetch the contents of a Nonce account from the cluster

    Parameters

    Returns Promise<null | NonceAccount>

  • Fetch parsed transaction details for a confirmed transaction

    deprecated

    Deprecated since Solana v1.8.0. Please use getParsedTransaction instead.

    Parameters

    • signature: string
    • Optional commitment: Finality

    Returns Promise<null | ParsedTransactionWithMeta>

  • Fetch parsed transaction details for a batch of confirmed transactions

    deprecated

    Deprecated since Solana v1.8.0. Please use getParsedTransactions instead.

    Parameters

    • signatures: string[]
    • Optional commitment: Finality

    Returns Promise<(null | ParsedTransactionWithMeta)[]>

  • Fetch a recent blockhash from the cluster

    deprecated

    Deprecated since Solana v1.8.0. Please use getLatestBlockhash instead.

    Parameters

    Returns Promise<{ blockhash: string; feeCalculator: FeeCalculator }>

    }

  • Fetch a recent blockhash from the cluster, return with context

    deprecated

    Deprecated since Solana v1.8.0. Please use getLatestBlockhash instead.

    Parameters

    Returns Promise<RpcResponseAndContext<{ blockhash: string; feeCalculator: FeeCalculator }>>

    }

  • getRecentPerformanceSamples(limit?: number): Promise<PerfSample[]>
  • Fetch recent performance samples

    Parameters

    • Optional limit: number

    Returns Promise<PerfSample[]>

  • Returns confirmed signatures for transactions involving an address backwards in time from the provided signature or most recent confirmed block

    Parameters

    Returns Promise<ConfirmedSignatureInfo[]>

  • Fetch the current slot that the node is processing

    Parameters

    Returns Promise<number>

  • Fetch the current slot leader of the cluster

    Parameters

    Returns Promise<string>

  • 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[]>

  • 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>

  • Fetch a confirmed or finalized transaction from the cluster.

    deprecated

    Instead, call getTransaction using a GetVersionedTransactionConfig by setting the maxSupportedTransactionVersion property.

    Parameters

    Returns Promise<null | TransactionResponse>

  • Fetch a confirmed or finalized transaction from the cluster.

    Parameters

    Returns Promise<null | VersionedTransactionResponse>

  • Fetch the current transaction count of the cluster

    Parameters

    Returns Promise<number>

  • Fetch the node version

    Returns Promise<Version>

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

    Parameters

    Returns Promise<VoteAccountStatus>

  • 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

  • Registers a callback to be invoked whenever logs are emitted.

    Parameters

    Returns number

  • 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

  • Register a callback to be invoked upon root changes

    Parameters

    Returns number

    subscription id

  • 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

  • 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

  • Register a callback to be invoked upon slot changes

    Parameters

    Returns number

    subscription id

  • 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(clientSubscriptionId: number): Promise<void>
  • Deregister an account notification callback

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

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

    Parameters

    • clientSubscriptionId: number

    Returns Promise<void>

  • 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(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(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>

Generated using TypeDoc