Umi — API References - v1.3.0
    Preparing search index...

    Interface RpcInterface

    Defines the interface for an RPC client. It allows us to interact with the Solana blockchain.

    interface RpcInterface {
        accountExists(
            publicKey: PublicKey,
            options?: RpcBaseOptions,
        ): Promise<boolean>;
        airdrop(
            publicKey: PublicKey,
            amount: SolAmount,
            options?: Partial<RpcConfirmTransactionOptions>,
        ): Promise<void>;
        call<R, P extends any[] | Record<string, any> = any[]>(
            method: string,
            params?: P,
            options?: RpcCallOptions,
        ): Promise<R>;
        confirmTransaction(
            signature: TransactionSignature,
            options: RpcConfirmTransactionOptions,
        ): Promise<RpcConfirmTransactionResult>;
        getAccount(
            publicKey: PublicKey,
            options?: RpcGetAccountOptions,
        ): Promise<MaybeRpcAccount>;
        getAccounts(
            publicKeys: PublicKey[],
            options?: RpcGetAccountsOptions,
        ): Promise<MaybeRpcAccount[]>;
        getBalance(
            publicKey: PublicKey,
            options?: RpcBaseOptions,
        ): Promise<SolAmount>;
        getBlockTime(
            slot: number,
            options?: RpcBaseOptions,
        ): Promise<null | bigint>;
        getCluster(): Cluster;
        getEndpoint(): string;
        getGenesisHash(): Promise<string>;
        getLatestBlockhash(
            options?: RpcBaseOptions,
        ): Promise<BlockhashWithExpiryBlockHeight>;
        getProgramAccounts(
            programId: PublicKey,
            options?: RpcGetProgramAccountsOptions,
        ): Promise<RpcAccount[]>;
        getRent(bytes: number, options?: RpcGetRentOptions): Promise<SolAmount>;
        getSignatureStatuses(
            signatures: TransactionSignature[],
            options?: RpcGetSignatureStatusesOptions,
        ): Promise<(null | TransactionStatus)[]>;
        getSlot(options?: RpcBaseOptions): Promise<number>;
        getTransaction(
            signature: TransactionSignature,
            options?: RpcBaseOptions,
        ): Promise<
            | null
            | Transaction & { meta: TransactionMeta } & RpcGetTransactionResponseOther,
        >;
        sendTransaction(
            transaction: Transaction,
            options?: RpcSendTransactionOptions,
        ): Promise<TransactionSignature>;
        simulateTransaction(
            transaction: Transaction,
            options?: RpcSimulateTransactionOptions,
        ): Promise<RpcSimulateTransactionResult>;
    }
    Index

    Methods

    • Whether or not an account at a given address exists.

      Parameters

      • publicKey: PublicKey

        The public key of the account.

      • Optionaloptions: RpcBaseOptions

        The options to use when checking if an account exists.

      Returns Promise<boolean>

      true if the account exists, false otherwise.

    • Send and confirm an airdrop transaction to the given address.

      Parameters

      Returns Promise<void>

    • Send a custom RPC request to the node.

      Type Parameters

      • R
      • P extends any[] | Record<string, any> = any[]

      Parameters

      • method: string

        The method to call.

      • Optionalparams: P

        The parameters to pass to the method. Can be either: - An array for positional parameters - An object for named parameters

      • Optionaloptions: RpcCallOptions

        The options to use when sending a custom RPC request.

      Returns Promise<R>

      The generic result of the RPC call.

    • Fetch the balance of an account.

      Parameters

      • publicKey: PublicKey

        The public key of the account.

      • Optionaloptions: RpcBaseOptions

        The options to use when fetching an account's balance.

      Returns Promise<SolAmount>

      An amount of SOL.

    • Fetch the estimated production time of a block.

      Parameters

      • slot: number

        The slot to get the estimated production time for.

      • Optionaloptions: RpcBaseOptions

        The options to use when getting the block time of a slot.

      Returns Promise<null | bigint>

      The estimated production time of the block in Unix time.

    • The Solana cluster of the RPC being used.

      Returns Cluster

    • The RPC endpoint used by the client.

      Returns string

    • Get the genesis hash.

      Returns Promise<string>

      The genesis hash.

    • Get the amount of rent-exempt SOL required to create an account of the given size.

      Parameters

      • bytes: number

        The size of the account in bytes.

      • Optionaloptions: RpcGetRentOptions

        The options to use when fetching the rent exempt amount.

      Returns Promise<SolAmount>

      An amount of SOL.

    • Fetch the recent slot.

      Parameters

      • Optionaloptions: RpcBaseOptions

        The options to use when fetching the recent slot.

      Returns Promise<number>

      The recent slot.