Skip to Content

🚧 These packages are still in development and may change rapidly as they are developed.

TypeScriptAptosJSProClient

AptosJSProClient

The AptosJSProClient is a client for the Aptos blockchain that is used to manage your networks and account connections. This is a layer on top of the @aptos-labs/ts-sdk client.

Usage

import { AptosJSProClient, convertAptosAccountToAccountInfo, convertAptosAccountToSigner, } from "@aptos-labs/js-pro"; import { Network } from "@aptos-labs/ts-sdk"; const account = Account.generate(); const client = new AptosJSProClient({ network: { network: Network.DEVNET }, account: convertAptosAccountToAccountInfo(account), signer: convertAptosAccountToSigner(account), });

Parameters

NameTypeDefault
accountAccountInfo
configClientConfigs
networkNetworkInfo
signerSignerClient

AccountInfo

NameTypeDefault
addressAccountAddress
publicKeyPublicKey

ClientConfigs

NameTypeDefault
apiKeystring | { [network: string]: string | undefined; }

This will be included as Authorization: Bearer <apiKey> in all requests to Aptos APIs. For the Aptos client this means settings AptosConfig.clientConfig.API_KEY. For the indexer client, we provide a custom header.

This argument takes precedence over the relevant argument in the configs for aptos and indexerClient.

It is okay to accept a single argument here because it is standard to use the same API key for both APIs (node and indexer APIs).

aptos{ config: AptosSettings; }

Will override any Network settings if provided in this config.

indexerClient{ options: RequestConfig | undefined; }
serverTime() => number

A function that returns the current server time in milliseconds.

Date.now

NetworkInfo

The configurations for the current network.

NameTypeDefault
networkNetwork

SignerClient

A SignerClient can be of two types: CustomSignerClient and AdapterSignerClient.

CustomSignerClient

This client is typically used with an Account object.

NameTypeDefault
type"custom"
signTransaction(params: { aptos: Aptos; signer?: Account; transaction: AnyRawTransaction; }) => Promise<{ rawTransaction: Uint8Array<ArrayBufferLike>; authenticator: AccountAuthenticator; }>
signAndSubmitTransaction(params: { aptos: Aptos; transaction: AnyRawTransaction; signer?: Account; } & FeePayerOrFeePayerAuthenticatorOrNeither) => Promise<...>

AdapterSignerClient

This client is typically used with the @aptos-labs/wallet-adapter-react.

NameTypeDefault
type"adapter"
signTransaction(params: { aptos: Aptos; signer?: Account; transaction: AnyRawTransaction; }) => Promise<{ rawTransaction: Uint8Array<ArrayBufferLike>; authenticator: AccountAuthenticator; }>
signAndSubmitTransaction(params: { aptos: Aptos; transaction?: AnyRawTransaction; payload?: { sender?: AccountAddressInput; data: InputGenerateTransactionPayloadData; options?: InputGenerateTransactionOptions & { ...; }; }; signer?: Account; } & FeePayerOrFeePayerAuthenticatorOrNeither) => Promise<...>

Methods

NameTypeDefault
stateAptosJSProClientState
signerSignerClient | undefined
accountAccountInfo | undefined
networkNetworkInfo
aptosAptos
indexer{ getAccountTokensTotal(variables: Exact<{ address: string; where: Current_Token_Ownerships_V2_Bool_Exp | Current_Token_Ownerships_V2_Bool_Exp[]; }>, requestHeaders?: HeadersInit | undefined, signal?: AbortSignal | ... 1 more ... | undefined): Promise<...>; ... 14 more ...; getNumberOfDelegators(variables?: Exact<.....
getServerTime() => number
getServerDate() => Date
setAccount(account: AccountInfo | undefined) => void
setNetwork(network: NetworkInfo) => void
setSigner(signer: SignerClient | undefined) => void
setConfig(config: ClientConfigs) => void
onAccountChange(callback: (account?: AccountInfo | undefined) => void) => () => void
onNetworkChange(callback: (network: NetworkInfo) => void) => () => void
onSignerChange(callback: (signer?: SignerClient | undefined) => void) => () => void
onConfigChange(callback: (config?: ClientConfigs | undefined) => void) => () => void
onChange(callback: (state: AptosJSProClientState) => void) => () => void
createNetworkConfig(network?: NetworkInfo | undefined) => AptosSettings
createAptos(clientConfig?: AptosSettings | undefined, network?: NetworkInfo | undefined) => Aptos

To support V1 networks, we are case insensitive when matching the network name.

createIndexer(clientConfig?: AptosSettings | undefined, network?: NetworkInfo | undefined) => { getAccountTokensTotal(variables: Exact<{ address: string; where: Current_Token_Ownerships_V2_Bool_Exp | Current_Token_Ownerships_V2_Bool_Exp[]; }>, requestHeaders?: HeadersInit | undefined, signal?: AbortSignal | ... 1 more ... | unde...
getClients(this: AptosJSProClient, { network: selectedNetwork }?: GetClientsParameters | undefined) => GetClientsResult
fetchAccountTransactions(this: AptosJSProClient, { network, address, limit, offset, orderBy, where, fungibleAssetActivitiesWhere, tokenActivitiesWhere, fungibleAssetActivitiesOrderBy, tokenActivitiesOrderBy, }: FetchAccountTransactionsParameters) => Promise<FetchAccountTransactionsResult>
fetchAccountCollections(this: AptosJSProClient, { network, limit, offset, orderBy, where, ...params }: FetchAccountCollectionsParameters) => Promise<FetchAccountCollectionsResult>
fetchAccountCoins(this: AptosJSProClient, { address, network, limit, offset, orderBy, where, }: FetchAccountCoinsParameters) => Promise<FetchAccountCoinsResult>
fetchAccountTokens(this: AptosJSProClient, { network, address, collectionId, limit, offset, orderBy, where, }: FetchAccountTokensParameters) => Promise<FetchAccountTokensResult>
fetchTransaction(this: AptosJSProClient, { network, ...params }: FetchTransactionParameters) => Promise<TransactionResponse>
fetchResources(this: AptosJSProClient, { network, ...params }: FetchResourcesParameters) => Promise<FetchResourcesResult>
fetchResourceType<T extends string | object>(this: AptosJSProClient, { network, accountAddress, ...params }: FetchResourceTypeParameters<T extends object ? string : T & string>) => Promise<...>
fetchProcessorStatus(this: AptosJSProClient, { network, processor }: FetchProcessorStatusParameters) => Promise<FetchProcessorStatusResult>
fetchTokenData(this: AptosJSProClient, params: FetchTokenDataParameters) => Promise<FetchTokenDataResult>
fetchFungibleAssetMetadata(this: AptosJSProClient, { network, ...params }: FetchFungibleAssetMetadataParameters) => Promise<FetchFungibleAssetMetadataResult>
fetchLedgerInfo(this: AptosJSProClient, { network }?: FetchLedgerInfoParameters | undefined) => Promise<FetchLedgerInfoResult>
fetchAddressFromName(this: AptosJSProClient, { network, name }: FetchAddressFromNameParameters) => Promise<FetchAddressFromNameResult>
fetchNameFromAddress(this: AptosJSProClient, { network, address }: FetchNameFromAddressParameters) => Promise<FetchNameFromAddressResult>
fetchAptBalance(this: AptosJSProClient, { address, network }: FetchAptBalanceParameters) => Promise<bigint>
fetchBalance(this: AptosJSProClient, { address, asset, network }: FetchBalanceParameters) => Promise<bigint>
fetchEstimatedGasPrice(this: AptosJSProClient, { network }?: FetchEstimatedGasPriceParameters | undefined) => Promise<FetchEstimatedGasPriceResult>
fetchViewModule<T extends Array<MoveValue>>(this: AptosJSProClient, params: FetchViewModuleParameters) => Promise<T>
fetchEvents(this: AptosJSProClient, { network, ...params }?: ({ minimumLedgerVersion?: AnyNumber; options?: PaginationArgs & OrderByArg<{ account_address: string; creation_number: any; data: any; event_index: any; sequence_number: any; transaction_block_height: any; transaction_version: any; type: string; indexed_type: string;...
fetchUserTransactions(this: AptosJSProClient, { network, limit, offset, orderBy, where, }?: FetchUserTransactionsParameters | undefined) => Promise<FetchUserTransactionsResult>
submitTransaction(this: AptosJSProClient, { network, transaction, ...params }: SubmitTransactionParameters) => Promise<PendingTransactionResponse>
waitForTransaction(this: AptosJSProClient, { network, ...params }: WaitForTransactionParameters) => Promise<CommittedTransactionResponse>
simulateTransaction{ (this: AptosJSProClient, params: SimulateSimpleTransactionParameters): Promise<UserTransactionResponse>; (this: AptosJSProClient, params: SimulateMultiAgentTransactionParameters): Promise<...>; }
signTransaction(this: AptosJSProClient, { network, ...params }: SignTransactionParameters) => Promise<{ rawTransaction: Uint8Array<ArrayBufferLike>; authenticator: AccountAuthenticator; }>
signAndSubmitTransaction(this: AptosJSProClient, params: SignAndSubmitTransactionParameters) => Promise<TransactionResponse>
buildTransaction{ (this: AptosJSProClient, args: BuildMultiAgentTransactionParameters): Promise<MultiAgentTransaction>; (this: AptosJSProClient, args: BuildSimpleTransactionParameters): Promise<...>; }
Last updated on