RichAptosClientWithContext

Class in @sentio/sdk/aptos

Defined in @sentio/sdk/aptos

Extends

Constructors

Constructor

new RichAptosClientWithContext(ctx: AptosBaseContext, config: AptosConfig): RichAptosClientWithContext;

Parameters

ParameterType
ctxAptosBaseContext
configAptosConfig

Returns

RichAptosClientWithContext

Overrides

RichAptosClient.constructor

Methods

getTypedAccountResource()

getTypedAccountResource<T>(args: object): Promise<T>;

Type Parameters

Type Parameter
T

Parameters

ParameterType
args{ accountAddress: AccountAddressInput; options?: LedgerVersionArg; resourceType: TypeDescriptor<T>; }
args.accountAddressAccountAddressInput
args.options?LedgerVersionArg
args.resourceTypeTypeDescriptor<T>

Returns

Promise<T>

Inherited from

RichAptosClient.getTypedAccountResource

Account

getAccountModule()

getAccountModule(args: object): Promise<MoveModuleBytecode>;

Queries for a specific account module given an account address and module name.

Parameters

ParameterTypeDescription
args{ accountAddress: AccountAddressInput; moduleName: string; options?: LedgerVersionArg; }-
args.accountAddressAccountAddressInputThe Aptos account address.
args.moduleNamestringThe name of the module.
args.options?LedgerVersionArg-

Returns

Promise<MoveModuleBytecode>

The account module associated with the specified account address and module name.

Example

import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

async function runExample() {
  // Get the account module for a specific account address and module name
  const module = await aptos.getAccountModule({
    accountAddress: "0x1", // replace with a real account address
    moduleName: "MyModule" // specify the module name
  });

  console.log(module);
}
runExample().catch(console.error);

Overrides

RichAptosClient.getAccountModule

getAccountModules()

getAccountModules(args: object): Promise<MoveModuleBytecode[]>;

Queries for all modules in an account given an account address. This function may call the API multiple times to auto paginate through results.

Parameters

ParameterTypeDescription
args{ accountAddress: AccountAddressInput; options?: PaginationArgs & LedgerVersionArg; }-
args.accountAddressAccountAddressInputThe Aptos account address to query modules for.
args.options?PaginationArgs & LedgerVersionArg-

Returns

Promise<MoveModuleBytecode[]>

  • The account modules associated with the specified address.

Example

import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

async function runExample() {
  // Fetching account modules for a specific account
  const accountModules = await aptos.getAccountModules({
    accountAddress: "0x1", // replace with a real account address
    options: {
      limit: 10, // limiting to 10 modules
    },
  });

  console.log(accountModules);
}
runExample().catch(console.error);

Overrides

RichAptosClient.getAccountModules

getAccountResource()

getAccountResource<T extends object>(args: object): Promise<T>;

Queries a specific account resource given an account address and resource type.

Type Parameters

Type ParameterDescription
T extends objectThe typed output of the resource.

Parameters

ParameterTypeDescription
args{ accountAddress: AccountAddressInput; options?: LedgerVersionArg; resourceType: `${string}::${string}::${string}`; }-
args.accountAddressAccountAddressInputThe Aptos account address to query.
args.options?LedgerVersionArg-
args.resourceType`${string}::${string}::${string}`The string representation of an on-chain Move struct type, e.g., "0x1::aptos_coin::AptosCoin".

Returns

Promise<T>

The account resource of the specified type.

Example

import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

async function runExample() {
  // Get the account resource for a specific account address and resource type
  const resource = await aptos.getAccountResource({
    accountAddress: "0x1", // replace with a real account address
    resourceType: "0x1::aptos_coin::AptosCoin"
  });

  console.log(resource);
}
runExample().catch(console.error);

Overrides

RichAptosClient.getAccountResource

getAccountResources()

getAccountResources(args: object): Promise<MoveResource[]>;

Queries all account resources given an account address. This function may call the API multiple times to auto paginate through results.

Parameters

ParameterTypeDescription
args{ accountAddress: AccountAddressInput; options?: PaginationArgs & LedgerVersionArg; }-
args.accountAddressAccountAddressInputThe Aptos account address to query resources for.
args.options?PaginationArgs & LedgerVersionArg-

Returns

Promise<MoveResource[]>

Account resources.

Example

import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

async function runExample() {
  // Fetching account resources for a specific account address
  const resources = await aptos.getAccountResources({ accountAddress: "0x1" }); // replace with a real account address
  console.log(resources);
}
runExample().catch(console.error);

Overrides

RichAptosClient.getAccountResources

lookupOriginalAccountAddress()

lookupOriginalAccountAddress(args: object): Promise<AccountAddress>;

Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.

Parameters

ParameterTypeDescription
args{ authenticationKey: AccountAddressInput; minimumLedgerVersion?: AnyNumber; options?: LedgerVersionArg; }-
args.authenticationKeyAccountAddressInputThe authentication key for which to look up the account address.
args.minimumLedgerVersion?AnyNumberOptional ledger version to sync up to before querying.
args.options?LedgerVersionArg-

Returns

Promise<AccountAddress>

Promise<AccountAddress> - The account address associated with the authentication key.

Example

import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";

const config = new AptosConfig({ network: Network.TESTNET });
const aptos = new Aptos(config);

async function runExample() {
  // Look up the original account address for a given authentication key
  const accountAddress = await aptos.lookupOriginalAccountAddress({
    authenticationKey: "0x1", // replace with a real authentication key
  });

  console.log("Original Account Address:", accountAddress);
}
runExample().catch(console.error);

Overrides

RichAptosClient.lookupOriginalAccountAddress

General

view()

view<T extends MoveValue[]>(args: object): Promise<T>;

Queries for a Move view function

Type Parameters

Type Parameter
T extends MoveValue[]

Parameters

ParameterTypeDescription
args{ options?: LedgerVersionArg; payload: InputViewFunctionData; }-
args.options?LedgerVersionArg-
args.payloadInputViewFunctionDataPayload for the view function

Returns

Promise<T>

an array of Move values

Example

const data = await aptos.view({
 payload: {
  function: "0x1::coin::balance",
  typeArguments: ["0x1::aptos_coin::AptosCoin"],
  functionArguments: [accountAddress],
 }
})

Overrides

RichAptosClient.view

viewJson()

viewJson<T extends MoveValue[]>(args: object): Promise<T>;

Queries for a Move view function with JSON, this provides compatability with the old aptos package

Type Parameters

Type Parameter
T extends MoveValue[]

Parameters

ParameterTypeDescription
args{ options?: LedgerVersionArg; payload: InputViewFunctionJsonData; }-
args.options?LedgerVersionArg-
args.payloadInputViewFunctionJsonDataPayload for the view function

Returns

Promise<T>

an array of Move values

Example

const data = await aptos.view({
 payload: {
  function: "0x1::coin::balance",
  typeArguments: ["0x1::aptos_coin::AptosCoin"],
  functionArguments: [accountAddress.toString()],
 }
})

Overrides

RichAptosClient.viewJson

On this page