@solana/web3.js
    Preparing search index...

    Class Connection

    A connection to a fullnode JSON RPC endpoint

    Index
    awaitSubscriptionReady confirmTransaction getAccountInfo getAccountInfoAndContext getAddressLookupTable getAgGenesisCert getBalance getBalanceAndContext getBlock getBlockCommitment getBlockProduction getBlocks getBlockSignatures getBlocksWithLimit getBlockTime getClusterNodes getConfirmedBlock getConfirmedBlockSignatures getConfirmedTransaction getEpochInfo getEpochSchedule getFeeForMessage getFirstAvailableBlock getGenesisHash getHealth getHighestSnapshotSlot getIdentity getInflationGovernor getInflationRate getInflationReward getLargestAccounts getLatestBlockhash getLatestBlockhashAndContext getLeaderSchedule getMaxRetransmitSlot getMaxShredInsertSlot getMinimumBalanceForRentExemption getMinimumLedgerSlot getMultipleAccountsInfo getMultipleAccountsInfoAndContext getMultipleParsedAccounts getNonce getNonceAndContext getParsedAccountInfo getParsedBlock getParsedConfirmedTransaction getParsedConfirmedTransactions getParsedProgramAccounts getParsedTokenAccountsByOwner getParsedTransaction getParsedTransactions getProgramAccounts getRecentPerformanceSamples getRecentPrioritizationFees getSignaturesForAddress getSignatureStatus getSignatureStatuses getSlot getSlotLeader getSlotLeaders getStakeMinimumDelegation getSupply getTokenAccountBalance getTokenAccountsByDelegate getTokenAccountsByOwner getTokenLargestAccounts getTokenSupply getTransaction getTransactionCount getTransactions getVersion getVoteAccounts isBlockhashValid onAccountChange onBlock onLogs onProgramAccountChange onRootChange onSignature onSignatureWithOptions onSlotChange onSlotUpdate onVote removeAccountChangeListener removeBlockListener removeOnLogsListener removeProgramAccountChangeListener removeRootChangeListener removeSignatureListener removeSlotChangeListener removeSlotUpdateListener removeVoteListener requestAirdrop sendEncodedTransaction sendRawTransaction sendTransaction simulateTransaction
    getBlockHeight: (
        commitmentOrConfig?: Commitment | GetBlockHeightConfig,
    ) => Promise<bigint> = ...
    • Wait until an active subscription has either been established or failed.

      This rejects if the supplied subscription id is not active when observation begins, or if the subscription becomes inactive before setup reaches a terminal state.

      Parameters

      • clientSubscriptionId: number
      • Optionalconfig: Readonly<{ abortSignal?: AbortSignal }>

      Returns Promise<void>

    • Fetch the Alpenglow genesis certificate, or null if the node does not have one.

      Returns Promise<
          | Readonly<
              {
                  block: Readonly<{ blockId: readonly number[]; slot: Slot }>;
                  signature: Readonly<
                      { bitmap: readonly number[]; signature: readonly number[] },
                  >;
              },
          >
          | null,
      >

    • Fetch the amount of cluster stake that has voted on a block.

      Parameters

      • slot: number | bigint

      Returns Promise<
          Readonly<
              { commitment: readonly Lamports[]
              | null; totalStake: Lamports },
          >,
      >

    • Fetch confirmed blocks between two slots

      Parameters

      • startSlot: number | bigint
      • OptionalendSlot: number | bigint
      • Optionalcommitment: Finality

      Returns Promise<GetBlocksApiResponse>

    • Fetch confirmed blocks between two slots

      Parameters

      • startSlot: number | bigint
      • OptionalendSlot: number | bigint
      • Optionalconfig: GetBlocksConfig

      Returns Promise<GetBlocksApiResponse>

    • Fetch confirmed blocks between two slots

      Parameters

      Returns Promise<GetBlocksApiResponse>

    • Fetch confirmed blocks starting at the provided slot, limited to the requested length.

      Parameters

      • startSlot: number | bigint
      • limit: number
      • Optionalcommitment: Finality

      Returns Promise<GetBlocksWithLimitApiResponse>

    • Fetch confirmed blocks starting at the provided slot, limited to the requested length.

      Parameters

      Returns Promise<GetBlocksWithLimitApiResponse>

    • Fetch the estimated production time of a block

      Parameters

      • slot: number | bigint

      Returns Promise<UnixTimestamp>

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

      Returns Promise<GetClusterNodesApiResponse>

    • Fetch the Epoch Info parameters

      Parameters

      Returns Promise<
          Readonly<
              {
                  absoluteSlot: bigint;
                  blockHeight: bigint;
                  epoch: bigint;
                  slotIndex: bigint;
                  slotsInEpoch: bigint;
                  transactionCount: bigint
                  | null;
              },
          >,
      >

    • Fetch the fee for a message from the cluster, return with context

      Parameters

      Returns Promise<
          Readonly<
              {
                  context: Readonly<{ slot: Slot }>;
                  value: GetFeeForMessageApiResponse;
              },
          >,
      >

    • Fetch the slot of the lowest confirmed block that has not been purged from the ledger

      Returns Promise<bigint>

    • Fetch the highest full and incremental snapshot slots available on the RPC node.

      Returns Promise<Readonly<{ full: bigint; incremental: bigint | null }>>

    • Fetch the specific inflation values for the current epoch

      Returns Promise<
          Readonly<
              { epoch: bigint; foundation: number; total: number; validator: number },
          >,
      >

    • Fetch the inflation reward for a list of addresses for an epoch

      Parameters

      Returns Promise<
          (
              | Readonly<
                  {
                      amount: Lamports;
                      commission: number;
                      effectiveSlot: bigint;
                      epoch: bigint;
                      postBalance: Lamports;
                  },
              >
              | null
          )[],
      >

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

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

      Parameters

      Returns Promise<
          RpcResponseAndContext<
              (
                  | Readonly<
                      AccountInfo<Uint8Array<ArrayBufferLike> | ParsedAccountData> & {
                          space: bigint;
                      },
                  >
                  | null
              )[],
          >,
      >

    • Fetch recent performance samples

      Parameters

      • Optionallimit: number

      Returns Promise<GetRecentPerformanceSamplesApiResponse>

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

      Parameters

      Returns Promise<
          Readonly<
              Overwrite<
                  Readonly<
                      {
                          blockTime: UnixTimestamp
                          | null;
                          confirmationStatus: Commitment | null;
                          err: TransactionError | null;
                          memo: string | null;
                          signature: Signature;
                          slot: bigint;
                          transactionIndex?: number;
                      },
                  >,
                  { signature: string },
              >,
          >[],
      >

    • Fetch limit number of slot leaders starting from startSlot

      Parameters

      • startSlot: number | bigint

        fetch slot leaders starting from this slot

      • limit: number

        number of slot leaders to return

      Returns Promise<PublicKey[]>

    • Fetch the node version

      Returns Promise<Readonly<{ "feature-set": number; "solana-core": string }>>

    • Register a callback to be invoked when a new vote is observed in gossip.

      This subscription is unstable and requires the validator to be started with --rpc-pubsub-enable-vote-subscription.

      Parameters

      • callback: VoteCallback

        Function to invoke whenever a vote is observed

      Returns number

      subscription id

    • Deregister an account notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a block notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a logs callback.

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister.

      Returns Promise<void>

    • Deregister an account notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a root notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a signature notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a slot notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a slot update notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

    • Deregister a vote notification callback

      Parameters

      • clientSubscriptionId: number

        client subscription id to deregister

      Returns Promise<void>

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

    • Send a transaction that has already been signed, serialized into the wire format, and encoded as a base64 string

      Parameters

      • encodedTransaction: string
      • Optionaloptions: SendOptions

      Returns Promise<string>

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

      Parameters

      • rawTransaction: number[] | Uint8Array<ArrayBufferLike>
      • Optionaloptions: SendOptions

      Returns Promise<string>

    • Sign and send a transaction

      Parameters

      • transaction: Transaction
      • signers: Readonly<
            {
                address: Address<string>;
                signTransactions(
                    transactions: readonly (
                        Readonly<
                            { messageBytes: TransactionMessageBytes; signatures: SignaturesMap },
                        > & TransactionWithinSizeLimit & TransactionWithLifetime
                    )[],
                    config?: BaseTransactionSignerConfig,
                ): Promise<readonly Readonly<Record<Address, SignatureBytes>>[]>;
            },
        >[]
      • Optionaloptions: SendOptions

      Returns Promise<string>

      Instead, call sendTransaction with a VersionedTransaction

    • Send a signed transaction

      Parameters

      Returns Promise<string>