@lightprotocol/stateless.js - v0.23.1
    Preparing search index...

    Class Rpc

    Hierarchy

    • Connection
      • Rpc

    Implements

    Index

    Constructors

    • Parameters

      • endpoint: string
      • compressionApiEndpoint: string
      • proverEndpoint: string
      • Optionalconfig: ConnectionConfig

      Returns Rpc

    Properties

    compressionApiEndpoint: string
    proverEndpoint: string
    allStateTreeInfos: TreeInfo[] | null = null
    lastStateTreeFetchTime: number | null = null
    CACHE_TTL: number = ...
    fetchPromise: Promise<TreeInfo[]> | null = null

    Methods

    • Get a list of all state tree infos. If not already cached, fetches from the cluster. if featureFlags.isV2(), returns v2 trees too.

      Returns Promise<TreeInfo[]>

    • Ensure that the Compression Indexer has already indexed the transaction

      Parameters

      • slot: number

      Returns Promise<boolean>

    • Parameters

      • hashes: BN[] = []

        Array of BN254 hashes.

      • newAddresses: BN[] = []

        Array of BN254 new addresses.

      Returns Promise<ValidityProofWithContext>

      validity proof with context

      use getValidityProofV0 instead.

      Fetch the latest validity proof for (1) compressed accounts specified by an array of account hashes. (2) new unique addresses specified by an array of addresses.

      Validity proofs prove the presence of compressed accounts in state trees and the non-existence of addresses in address trees, respectively. They enable verification without recomputing the merkle proof path, thus lowering verification and data costs.

    • Fetch the latest validity proof for (1) compressed accounts specified by an array of account hashes. (2) new unique addresses specified by an array of addresses.

      Validity proofs prove the presence of compressed accounts in state trees and the non-existence of addresses in address trees, respectively. They enable verification without recomputing the merkle proof path, thus lowering verification and data costs.

      Parameters

      • hashes: HashWithTree[] = []

        Array of { hash: BN254, tree: PublicKey, queue: PublicKey }.

      • newAddresses: AddressWithTree[] = []

        Array of { address: BN254, tree: PublicKey, queue: PublicKey }.

      Returns Promise<ValidityProofWithContext>

      validity proof with context

    • Fetch the latest validity proof for (1) compressed accounts specified by an array of account Merkle contexts, and (2) new unique addresses specified by an array of address objects with tree info.

      Validity proofs prove the presence of compressed accounts in state trees and the non-existence of addresses in address trees, respectively. They enable verification without recomputing the merkle proof path, thus lowering verification and data costs.

      Parameters

      Returns Promise<ValidityProofWithContext>

    • Fetch the account info for the specified public key. Returns metadata to load in case the account is cold.

      Parameters

      • address: PublicKey

        The account address to fetch.

      • programId: PublicKey

        The owner program ID.

      • OptionalcommitmentOrConfig: Commitment | GetAccountInfoConfig

        Optional. The commitment or config to use for the onchain account fetch.

      • OptionaladdressSpace: TreeInfo

        Optional. The address space info that was used at init.

      Returns Promise<
          | {
              accountInfo: AccountInfo<Buffer<ArrayBufferLike>>;
              isCold: boolean;
              loadContext?: MerkleContext;
          }
          | null,
      >

      Account info with load info, or null if account doesn't exist. LoadContext is always some if the account is compressible. isCold indicates the current state of the account, if true the account must referenced in a load instruction before use.

    • Get token account balance for an address, regardless of whether the token account is hot or cold.

      Parameters

      • address: PublicKey

        Token account address.

      • owner: PublicKey

        Owner public key.

      • mint: PublicKey

        Mint public key.

      • Optionalcommitment: Commitment

        Commitment level for on-chain query.

      Returns Promise<UnifiedTokenBalance>

      Unified token balance from both sources.