RichAptosClientWithContext
Class in @sentio/sdk/aptos
Defined in @sentio/sdk/aptos
Extends
Constructors
Constructor
new RichAptosClientWithContext(ctx: AptosBaseContext, config: AptosConfig): RichAptosClientWithContext;Parameters
| Parameter | Type |
|---|---|
ctx | AptosBaseContext |
config | AptosConfig |
Returns
RichAptosClientWithContext
Overrides
Methods
getTypedAccountResource()
getTypedAccountResource<T>(args: object): Promise<T>;Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
args | { accountAddress: AccountAddressInput; options?: LedgerVersionArg; resourceType: TypeDescriptor<T>; } |
args.accountAddress | AccountAddressInput |
args.options? | LedgerVersionArg |
args.resourceType | TypeDescriptor<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
| Parameter | Type | Description |
|---|---|---|
args | { accountAddress: AccountAddressInput; moduleName: string; options?: LedgerVersionArg; } | - |
args.accountAddress | AccountAddressInput | The Aptos account address. |
args.moduleName | string | The 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.getAccountModulegetAccountModules()
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
| Parameter | Type | Description |
|---|---|---|
args | { accountAddress: AccountAddressInput; options?: PaginationArgs & LedgerVersionArg; } | - |
args.accountAddress | AccountAddressInput | The 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.getAccountModulesgetAccountResource()
getAccountResource<T extends object>(args: object): Promise<T>;Queries a specific account resource given an account address and resource type.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends object | The typed output of the resource. |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { accountAddress: AccountAddressInput; options?: LedgerVersionArg; resourceType: `${string}::${string}::${string}`; } | - |
args.accountAddress | AccountAddressInput | The 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.getAccountResourcegetAccountResources()
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
| Parameter | Type | Description |
|---|---|---|
args | { accountAddress: AccountAddressInput; options?: PaginationArgs & LedgerVersionArg; } | - |
args.accountAddress | AccountAddressInput | The 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.getAccountResourceslookupOriginalAccountAddress()
lookupOriginalAccountAddress(args: object): Promise<AccountAddress>;Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { authenticationKey: AccountAddressInput; minimumLedgerVersion?: AnyNumber; options?: LedgerVersionArg; } | - |
args.authenticationKey | AccountAddressInput | The authentication key for which to look up the account address. |
args.minimumLedgerVersion? | AnyNumber | Optional 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.lookupOriginalAccountAddressGeneral
view()
view<T extends MoveValue[]>(args: object): Promise<T>;Queries for a Move view function
Type Parameters
| Type Parameter |
|---|
T extends MoveValue[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { options?: LedgerVersionArg; payload: InputViewFunctionData; } | - |
args.options? | LedgerVersionArg | - |
args.payload | InputViewFunctionData | Payload 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.viewviewJson()
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
| Parameter | Type | Description |
|---|---|---|
args | { options?: LedgerVersionArg; payload: InputViewFunctionJsonData; } | - |
args.options? | LedgerVersionArg | - |
args.payload | InputViewFunctionJsonData | Payload 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