@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
5,702 lines • 240 kB
TypeScript
import { S as Serializable, T as TransactionArgument, H as HexInput, a as Serializer, D as Deserializer, E as EntryFunctionArgument, U as Uint8, b as Uint16, c as Uint32, A as AnyNumber, d as Deserializable, e as Hex, f as AuthenticationKeyScheme, g as AccountAddress, h as AnyPublicKeyVariant, N as Network, C as Client, i as ClientConfig, F as FullNodeConfig, I as IndexerConfig, j as FaucetConfig, k as AptosSettings, M as MoveModuleId, l as ScriptFunctionArgument, m as MoveFunctionId, n as AccountAddressInput, o as MoveFunctionGenericTypeParam, p as SigningSchemeInput, q as SigningScheme, r as AccountData, P as PaginationArgs, L as LedgerVersionArg, s as MoveModuleBytecode, t as TransactionResponse, u as MoveResource, v as MoveStructId, w as TokenStandardArg, O as OrderByArg, G as GetAccountOwnedTokensQueryResponse, x as GetAccountOwnedTokensFromCollectionResponse, y as GetAccountCollectionsWithOwnedTokenResponse, z as GetAccountCoinsDataResponse, W as WhereArg, B as GetAccountOwnedObjectsResponse, J as GetCollectionDataResponse, K as GetTokenDataResponse, Q as GetCurrentTokenOwnershipResponse, R as GetOwnedTokensResponse, V as GetTokenActivityResponse, X as GetEventsResponse, Y as WaitForTransactionOptions, Z as UserTransactionResponse, _ as MoveFunction, $ as GetFungibleAssetMetadataResponse, a0 as GetFungibleAssetActivitiesResponse, a1 as GetCurrentFungibleAssetBalancesResponse, a2 as LedgerInfo, a3 as Block, a4 as MoveValue, a5 as GetChainTopUserTransactionsResponse, a6 as GraphqlQuery, a7 as GetProcessorStatusResponse, a8 as GetANSNameResponse, a9 as GetNumberOfDelegatorsResponse, aa as GetDelegatedStakingActivitiesResponse, ab as PendingTransactionResponse, ac as CommittedTransactionResponse, ad as GasEstimation, ae as TableItemRequest, af as GetTableItemsDataResponse, ag as GetTableItemsMetadataResponse, ah as AptosRequest, ai as ClientRequest, aj as ClientResponse, ak as MimeType } from './accountAddress-ccLvlUQe.js';
export { ax as AccountAuthenticatorVariant, bc as AccountSignature, ao as AddressInvalidReason, ay as AnySignatureVariant, aL as BlockMetadataTransactionResponse, aC as ClientHeadersType, aV as DecodedTableData, aW as DeletedTableData, bz as DeriveScheme, bf as DirectWriteSet, aY as EntryFunctionPayloadResponse, bh as Event, bg as EventGuid, bC as GenerateAccount, bA as GenerateAccountWithEd25519, bB as GenerateAccountWithSingleSignerSecp256k1Key, a$ as GenesisPayload, aK as GenesisTransactionResponse, ar as HexInvalidReason, bu as MoveAbility, bo as MoveAddressType, bt as MoveFunctionVisibility, bw as MoveModule, bp as MoveObjectType, bq as MoveOptionType, b0 as MoveScriptBytecode, bx as MoveStruct, bv as MoveStructField, br as MoveStructType, bs as MoveType, bm as MoveUint128Type, bj as MoveUint16Type, bn as MoveUint256Type, bk as MoveUint32Type, bl as MoveUint64Type, bi as MoveUint8Type, a_ as MultisigPayloadResponse, bJ as NetworkToChainId, bI as NetworkToFaucetAPI, bG as NetworkToIndexerAPI, bK as NetworkToNetworkName, bH as NetworkToNodeAPI, bD as OrderBy, bE as OrderByValue, ap as ParsingError, aq as ParsingResult, by as RoleType, aZ as ScriptPayloadResponse, at as ScriptTransactionArgumentVariants, be as ScriptWriteSet, aM as StateCheckpointTransactionResponse, bF as TokenStandard, aw as TransactionAuthenticatorVariant, b7 as TransactionEd25519Signature, bb as TransactionFeePayerSignature, ba as TransactionMultiAgentSignature, b9 as TransactionMultiEd25519Signature, aX as TransactionPayloadResponse, au as TransactionPayloadVariants, aD as TransactionResponseType, b8 as TransactionSecp256k1Signature, b1 as TransactionSignature, av as TransactionVariants, as as TypeTagVariants, aA as Uint128, aB as Uint256, az as Uint64, aN as ValidatorTransactionResponse, bd as WriteSet, aO as WriteSetChange, aP as WriteSetChangeDeleteModule, aQ as WriteSetChangeDeleteResource, aR as WriteSetChangeDeleteTableItem, aS as WriteSetChangeWriteModule, aT as WriteSetChangeWriteResource, aU as WriteSetChangeWriteTableItem, al as ensureBoolean, aH as isBlockMetadataTransactionResponse, b2 as isEd25519Signature, b5 as isFeePayerSignature, aG as isGenesisTransactionResponse, b4 as isMultiAgentSignature, b6 as isMultiEd25519Signature, aE as isPendingTransactionResponse, b3 as isSecp256k1Signature, aI as isStateCheckpointTransactionResponse, aF as isUserTransactionResponse, aJ as isValidatorTransactionResponse, am as outOfRangeErrorMessage, an as validateNumberInRange } from './accountAddress-ccLvlUQe.js';
import EventEmitter from 'eventemitter3';
type Maybe<T> = T | null;
type InputMaybe<T> = Maybe<T>;
/** All built-in and custom scalars, mapped to their actual values */
type Scalars = {
ID: {
input: string;
output: string;
};
String: {
input: string;
output: string;
};
Boolean: {
input: boolean;
output: boolean;
};
Int: {
input: number;
output: number;
};
Float: {
input: number;
output: number;
};
bigint: {
input: any;
output: any;
};
jsonb: {
input: any;
output: any;
};
numeric: {
input: any;
output: any;
};
timestamp: {
input: any;
output: any;
};
timestamptz: {
input: any;
output: any;
};
};
/** Boolean expression to compare columns of type "Boolean". All fields are combined with logical 'AND'. */
type BooleanComparisonExp = {
_eq?: InputMaybe<Scalars["Boolean"]["input"]>;
_gt?: InputMaybe<Scalars["Boolean"]["input"]>;
_gte?: InputMaybe<Scalars["Boolean"]["input"]>;
_in?: InputMaybe<Array<Scalars["Boolean"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["Boolean"]["input"]>;
_lte?: InputMaybe<Scalars["Boolean"]["input"]>;
_neq?: InputMaybe<Scalars["Boolean"]["input"]>;
_nin?: InputMaybe<Array<Scalars["Boolean"]["input"]>>;
};
/** Boolean expression to compare columns of type "Int". All fields are combined with logical 'AND'. */
type IntComparisonExp = {
_eq?: InputMaybe<Scalars["Int"]["input"]>;
_gt?: InputMaybe<Scalars["Int"]["input"]>;
_gte?: InputMaybe<Scalars["Int"]["input"]>;
_in?: InputMaybe<Array<Scalars["Int"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["Int"]["input"]>;
_lte?: InputMaybe<Scalars["Int"]["input"]>;
_neq?: InputMaybe<Scalars["Int"]["input"]>;
_nin?: InputMaybe<Array<Scalars["Int"]["input"]>>;
};
/** Boolean expression to compare columns of type "String". All fields are combined with logical 'AND'. */
type StringComparisonExp = {
_eq?: InputMaybe<Scalars["String"]["input"]>;
_gt?: InputMaybe<Scalars["String"]["input"]>;
_gte?: InputMaybe<Scalars["String"]["input"]>;
/** does the column match the given case-insensitive pattern */
_ilike?: InputMaybe<Scalars["String"]["input"]>;
_in?: InputMaybe<Array<Scalars["String"]["input"]>>;
/** does the column match the given POSIX regular expression, case insensitive */
_iregex?: InputMaybe<Scalars["String"]["input"]>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
/** does the column match the given pattern */
_like?: InputMaybe<Scalars["String"]["input"]>;
_lt?: InputMaybe<Scalars["String"]["input"]>;
_lte?: InputMaybe<Scalars["String"]["input"]>;
_neq?: InputMaybe<Scalars["String"]["input"]>;
/** does the column NOT match the given case-insensitive pattern */
_nilike?: InputMaybe<Scalars["String"]["input"]>;
_nin?: InputMaybe<Array<Scalars["String"]["input"]>>;
/** does the column NOT match the given POSIX regular expression, case insensitive */
_niregex?: InputMaybe<Scalars["String"]["input"]>;
/** does the column NOT match the given pattern */
_nlike?: InputMaybe<Scalars["String"]["input"]>;
/** does the column NOT match the given POSIX regular expression, case sensitive */
_nregex?: InputMaybe<Scalars["String"]["input"]>;
/** does the column NOT match the given SQL regular expression */
_nsimilar?: InputMaybe<Scalars["String"]["input"]>;
/** does the column match the given POSIX regular expression, case sensitive */
_regex?: InputMaybe<Scalars["String"]["input"]>;
/** does the column match the given SQL regular expression */
_similar?: InputMaybe<Scalars["String"]["input"]>;
};
/** Boolean expression to compare columns of type "bigint". All fields are combined with logical 'AND'. */
type BigintComparisonExp = {
_eq?: InputMaybe<Scalars["bigint"]["input"]>;
_gt?: InputMaybe<Scalars["bigint"]["input"]>;
_gte?: InputMaybe<Scalars["bigint"]["input"]>;
_in?: InputMaybe<Array<Scalars["bigint"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["bigint"]["input"]>;
_lte?: InputMaybe<Scalars["bigint"]["input"]>;
_neq?: InputMaybe<Scalars["bigint"]["input"]>;
_nin?: InputMaybe<Array<Scalars["bigint"]["input"]>>;
};
type CurrentAptosNamesAggregateBoolExp = {
bool_and?: InputMaybe<CurrentAptosNamesAggregateBoolExpBoolAnd>;
bool_or?: InputMaybe<CurrentAptosNamesAggregateBoolExpBoolOr>;
count?: InputMaybe<CurrentAptosNamesAggregateBoolExpCount>;
};
type CurrentAptosNamesAggregateBoolExpBoolAnd = {
arguments: CurrentAptosNamesSelectColumnCurrentAptosNamesAggregateBoolExpBoolAndArgumentsColumns;
distinct?: InputMaybe<Scalars["Boolean"]["input"]>;
filter?: InputMaybe<CurrentAptosNamesBoolExp>;
predicate: BooleanComparisonExp;
};
type CurrentAptosNamesAggregateBoolExpBoolOr = {
arguments: CurrentAptosNamesSelectColumnCurrentAptosNamesAggregateBoolExpBoolOrArgumentsColumns;
distinct?: InputMaybe<Scalars["Boolean"]["input"]>;
filter?: InputMaybe<CurrentAptosNamesBoolExp>;
predicate: BooleanComparisonExp;
};
type CurrentAptosNamesAggregateBoolExpCount = {
arguments?: InputMaybe<Array<CurrentAptosNamesSelectColumn>>;
distinct?: InputMaybe<Scalars["Boolean"]["input"]>;
filter?: InputMaybe<CurrentAptosNamesBoolExp>;
predicate: IntComparisonExp;
};
/** Boolean expression to filter rows from the table "current_aptos_names". All fields are combined with a logical 'AND'. */
type CurrentAptosNamesBoolExp = {
_and?: InputMaybe<Array<CurrentAptosNamesBoolExp>>;
_not?: InputMaybe<CurrentAptosNamesBoolExp>;
_or?: InputMaybe<Array<CurrentAptosNamesBoolExp>>;
domain?: InputMaybe<StringComparisonExp>;
domain_expiration_timestamp?: InputMaybe<TimestampComparisonExp>;
domain_with_suffix?: InputMaybe<StringComparisonExp>;
expiration_timestamp?: InputMaybe<TimestampComparisonExp>;
is_active?: InputMaybe<BooleanComparisonExp>;
is_domain_owner?: InputMaybe<CurrentAptosNamesBoolExp>;
is_primary?: InputMaybe<BooleanComparisonExp>;
last_transaction_version?: InputMaybe<BigintComparisonExp>;
owner_address?: InputMaybe<StringComparisonExp>;
registered_address?: InputMaybe<StringComparisonExp>;
subdomain?: InputMaybe<StringComparisonExp>;
subdomain_expiration_policy?: InputMaybe<BigintComparisonExp>;
token_name?: InputMaybe<StringComparisonExp>;
token_standard?: InputMaybe<StringComparisonExp>;
};
/** select columns of table "current_aptos_names" */
declare enum CurrentAptosNamesSelectColumn {
/** column name */
Domain = "domain",
/** column name */
DomainExpirationTimestamp = "domain_expiration_timestamp",
/** column name */
DomainWithSuffix = "domain_with_suffix",
/** column name */
ExpirationTimestamp = "expiration_timestamp",
/** column name */
IsActive = "is_active",
/** column name */
IsPrimary = "is_primary",
/** column name */
LastTransactionVersion = "last_transaction_version",
/** column name */
OwnerAddress = "owner_address",
/** column name */
RegisteredAddress = "registered_address",
/** column name */
Subdomain = "subdomain",
/** column name */
SubdomainExpirationPolicy = "subdomain_expiration_policy",
/** column name */
TokenName = "token_name",
/** column name */
TokenStandard = "token_standard"
}
/** select "current_aptos_names_aggregate_bool_exp_bool_and_arguments_columns" columns of table "current_aptos_names" */
declare enum CurrentAptosNamesSelectColumnCurrentAptosNamesAggregateBoolExpBoolAndArgumentsColumns {
/** column name */
IsActive = "is_active",
/** column name */
IsPrimary = "is_primary"
}
/** select "current_aptos_names_aggregate_bool_exp_bool_or_arguments_columns" columns of table "current_aptos_names" */
declare enum CurrentAptosNamesSelectColumnCurrentAptosNamesAggregateBoolExpBoolOrArgumentsColumns {
/** column name */
IsActive = "is_active",
/** column name */
IsPrimary = "is_primary"
}
/** Boolean expression to filter rows from the table "current_fungible_asset_balances". All fields are combined with a logical 'AND'. */
type CurrentFungibleAssetBalancesBoolExp = {
_and?: InputMaybe<Array<CurrentFungibleAssetBalancesBoolExp>>;
_not?: InputMaybe<CurrentFungibleAssetBalancesBoolExp>;
_or?: InputMaybe<Array<CurrentFungibleAssetBalancesBoolExp>>;
amount?: InputMaybe<NumericComparisonExp>;
asset_type?: InputMaybe<StringComparisonExp>;
is_frozen?: InputMaybe<BooleanComparisonExp>;
is_primary?: InputMaybe<BooleanComparisonExp>;
last_transaction_timestamp?: InputMaybe<TimestampComparisonExp>;
last_transaction_version?: InputMaybe<BigintComparisonExp>;
metadata?: InputMaybe<FungibleAssetMetadataBoolExp>;
owner_address?: InputMaybe<StringComparisonExp>;
storage_id?: InputMaybe<StringComparisonExp>;
token_standard?: InputMaybe<StringComparisonExp>;
};
/** Boolean expression to filter rows from the table "events". All fields are combined with a logical 'AND'. */
type EventsBoolExp = {
_and?: InputMaybe<Array<EventsBoolExp>>;
_not?: InputMaybe<EventsBoolExp>;
_or?: InputMaybe<Array<EventsBoolExp>>;
account_address?: InputMaybe<StringComparisonExp>;
creation_number?: InputMaybe<BigintComparisonExp>;
data?: InputMaybe<JsonbComparisonExp>;
event_index?: InputMaybe<BigintComparisonExp>;
indexed_type?: InputMaybe<StringComparisonExp>;
sequence_number?: InputMaybe<BigintComparisonExp>;
transaction_block_height?: InputMaybe<BigintComparisonExp>;
transaction_version?: InputMaybe<BigintComparisonExp>;
type?: InputMaybe<StringComparisonExp>;
};
/** Boolean expression to filter rows from the table "fungible_asset_activities". All fields are combined with a logical 'AND'. */
type FungibleAssetActivitiesBoolExp = {
_and?: InputMaybe<Array<FungibleAssetActivitiesBoolExp>>;
_not?: InputMaybe<FungibleAssetActivitiesBoolExp>;
_or?: InputMaybe<Array<FungibleAssetActivitiesBoolExp>>;
amount?: InputMaybe<NumericComparisonExp>;
asset_type?: InputMaybe<StringComparisonExp>;
block_height?: InputMaybe<BigintComparisonExp>;
entry_function_id_str?: InputMaybe<StringComparisonExp>;
event_index?: InputMaybe<BigintComparisonExp>;
gas_fee_payer_address?: InputMaybe<StringComparisonExp>;
is_frozen?: InputMaybe<BooleanComparisonExp>;
is_gas_fee?: InputMaybe<BooleanComparisonExp>;
is_transaction_success?: InputMaybe<BooleanComparisonExp>;
metadata?: InputMaybe<FungibleAssetMetadataBoolExp>;
owner_address?: InputMaybe<StringComparisonExp>;
owner_aptos_names?: InputMaybe<CurrentAptosNamesBoolExp>;
owner_aptos_names_aggregate?: InputMaybe<CurrentAptosNamesAggregateBoolExp>;
storage_id?: InputMaybe<StringComparisonExp>;
storage_refund_amount?: InputMaybe<NumericComparisonExp>;
token_standard?: InputMaybe<StringComparisonExp>;
transaction_timestamp?: InputMaybe<TimestampComparisonExp>;
transaction_version?: InputMaybe<BigintComparisonExp>;
type?: InputMaybe<StringComparisonExp>;
};
/** Boolean expression to filter rows from the table "fungible_asset_metadata". All fields are combined with a logical 'AND'. */
type FungibleAssetMetadataBoolExp = {
_and?: InputMaybe<Array<FungibleAssetMetadataBoolExp>>;
_not?: InputMaybe<FungibleAssetMetadataBoolExp>;
_or?: InputMaybe<Array<FungibleAssetMetadataBoolExp>>;
asset_type?: InputMaybe<StringComparisonExp>;
creator_address?: InputMaybe<StringComparisonExp>;
decimals?: InputMaybe<IntComparisonExp>;
icon_uri?: InputMaybe<StringComparisonExp>;
last_transaction_timestamp?: InputMaybe<TimestampComparisonExp>;
last_transaction_version?: InputMaybe<BigintComparisonExp>;
name?: InputMaybe<StringComparisonExp>;
project_uri?: InputMaybe<StringComparisonExp>;
supply_aggregator_table_handle_v1?: InputMaybe<StringComparisonExp>;
supply_aggregator_table_key_v1?: InputMaybe<StringComparisonExp>;
symbol?: InputMaybe<StringComparisonExp>;
token_standard?: InputMaybe<StringComparisonExp>;
};
type JsonbCastExp = {
String?: InputMaybe<StringComparisonExp>;
};
/** Boolean expression to compare columns of type "jsonb". All fields are combined with logical 'AND'. */
type JsonbComparisonExp = {
_cast?: InputMaybe<JsonbCastExp>;
/** is the column contained in the given json value */
_contained_in?: InputMaybe<Scalars["jsonb"]["input"]>;
/** does the column contain the given json value at the top level */
_contains?: InputMaybe<Scalars["jsonb"]["input"]>;
_eq?: InputMaybe<Scalars["jsonb"]["input"]>;
_gt?: InputMaybe<Scalars["jsonb"]["input"]>;
_gte?: InputMaybe<Scalars["jsonb"]["input"]>;
/** does the string exist as a top-level key in the column */
_has_key?: InputMaybe<Scalars["String"]["input"]>;
/** do all of these strings exist as top-level keys in the column */
_has_keys_all?: InputMaybe<Array<Scalars["String"]["input"]>>;
/** do any of these strings exist as top-level keys in the column */
_has_keys_any?: InputMaybe<Array<Scalars["String"]["input"]>>;
_in?: InputMaybe<Array<Scalars["jsonb"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["jsonb"]["input"]>;
_lte?: InputMaybe<Scalars["jsonb"]["input"]>;
_neq?: InputMaybe<Scalars["jsonb"]["input"]>;
_nin?: InputMaybe<Array<Scalars["jsonb"]["input"]>>;
};
/** Boolean expression to compare columns of type "numeric". All fields are combined with logical 'AND'. */
type NumericComparisonExp = {
_eq?: InputMaybe<Scalars["numeric"]["input"]>;
_gt?: InputMaybe<Scalars["numeric"]["input"]>;
_gte?: InputMaybe<Scalars["numeric"]["input"]>;
_in?: InputMaybe<Array<Scalars["numeric"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["numeric"]["input"]>;
_lte?: InputMaybe<Scalars["numeric"]["input"]>;
_neq?: InputMaybe<Scalars["numeric"]["input"]>;
_nin?: InputMaybe<Array<Scalars["numeric"]["input"]>>;
};
/** Boolean expression to filter rows from the table "table_items". All fields are combined with a logical 'AND'. */
type TableItemsBoolExp = {
_and?: InputMaybe<Array<TableItemsBoolExp>>;
_not?: InputMaybe<TableItemsBoolExp>;
_or?: InputMaybe<Array<TableItemsBoolExp>>;
decoded_key?: InputMaybe<JsonbComparisonExp>;
decoded_value?: InputMaybe<JsonbComparisonExp>;
key?: InputMaybe<StringComparisonExp>;
table_handle?: InputMaybe<StringComparisonExp>;
transaction_version?: InputMaybe<BigintComparisonExp>;
write_set_change_index?: InputMaybe<BigintComparisonExp>;
};
/** Boolean expression to filter rows from the table "table_metadatas". All fields are combined with a logical 'AND'. */
type TableMetadatasBoolExp = {
_and?: InputMaybe<Array<TableMetadatasBoolExp>>;
_not?: InputMaybe<TableMetadatasBoolExp>;
_or?: InputMaybe<Array<TableMetadatasBoolExp>>;
handle?: InputMaybe<StringComparisonExp>;
key_type?: InputMaybe<StringComparisonExp>;
value_type?: InputMaybe<StringComparisonExp>;
};
/** Boolean expression to compare columns of type "timestamp". All fields are combined with logical 'AND'. */
type TimestampComparisonExp = {
_eq?: InputMaybe<Scalars["timestamp"]["input"]>;
_gt?: InputMaybe<Scalars["timestamp"]["input"]>;
_gte?: InputMaybe<Scalars["timestamp"]["input"]>;
_in?: InputMaybe<Array<Scalars["timestamp"]["input"]>>;
_is_null?: InputMaybe<Scalars["Boolean"]["input"]>;
_lt?: InputMaybe<Scalars["timestamp"]["input"]>;
_lte?: InputMaybe<Scalars["timestamp"]["input"]>;
_neq?: InputMaybe<Scalars["timestamp"]["input"]>;
_nin?: InputMaybe<Array<Scalars["timestamp"]["input"]>>;
};
/**
* This class exists to represent a contiguous sequence of already serialized BCS-bytes.
*
* It differs from most other Serializable classes in that its internal byte buffer is serialized to BCS
* bytes exactly as-is, without prepending the length of the bytes.
*
* If you want to write your own serialization function and pass the bytes as a transaction argument,
* you should use this class.
*
* This class is also more generally used to represent type-agnostic BCS bytes as a vector<u8>.
*
* An example of this is the bytes resulting from entry function arguments that have been serialized
* for an entry function.
*
* @example
* const yourCustomSerializedBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
* const fixedBytes = new FixedBytes(yourCustomSerializedBytes);
* const payload = await generateTransactionPayload({
* function: "0xbeefcafe::your_module::your_function_that_requires_custom_serialization",
* functionArguments: [yourCustomBytes],
* });
*
* For example, if you store each of the 32 bytes for an address as a U8 in a MoveVector<U8>, when you
* serialize that MoveVector<U8>, it will be serialized to 33 bytes. If you solely want to pass around
* the 32 bytes as a Serializable class that *does not* prepend the length to the BCS-serialized representation,
* use this class.
*
* @params value: HexInput representing a sequence of Uint8 bytes
* @returns a Serializable FixedBytes instance, which when serialized, does not prepend the length of the bytes
* @see EntryFunctionBytes
*/
declare class FixedBytes extends Serializable implements TransactionArgument {
value: Uint8Array;
constructor(value: HexInput);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer, length: number): FixedBytes;
}
/**
* This class exists solely to represent a sequence of fixed bytes as a serialized entry function, because
* serializing an entry function appends a prefix that's *only* used for entry function arguments.
*
* NOTE: Attempting to use this class for a serialized script function will result in erroneous
* and unexpected behavior.
*
* If you wish to convert this class back to a TransactionArgument, you must know the type
* of the argument beforehand, and use the appropriate class to deserialize the bytes within
* an instance of this class.
*/
declare class EntryFunctionBytes extends Serializable implements EntryFunctionArgument {
readonly value: FixedBytes;
private constructor();
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
/**
* The only way to create an instance of this class is to use this static method.
*
* This function should only be used when deserializing a sequence of EntryFunctionPayload arguments.
* @param deserializer the deserializer instance with the buffered bytes
* @param length the length of the bytes to deserialize
* @returns an instance of this class, which will now only be usable as an EntryFunctionArgument
*/
static deserialize(deserializer: Deserializer, length: number): EntryFunctionBytes;
}
declare class Bool extends Serializable implements TransactionArgument {
readonly value: boolean;
constructor(value: boolean);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Bool;
}
declare class U8 extends Serializable implements TransactionArgument {
readonly value: Uint8;
constructor(value: Uint8);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U8;
}
declare class U16 extends Serializable implements TransactionArgument {
readonly value: Uint16;
constructor(value: Uint16);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U16;
}
declare class U32 extends Serializable implements TransactionArgument {
readonly value: Uint32;
constructor(value: Uint32);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U32;
}
declare class U64 extends Serializable implements TransactionArgument {
readonly value: bigint;
constructor(value: AnyNumber);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U64;
}
declare class U128 extends Serializable implements TransactionArgument {
readonly value: bigint;
constructor(value: AnyNumber);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U128;
}
declare class U256 extends Serializable implements TransactionArgument {
readonly value: bigint;
constructor(value: AnyNumber);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): U256;
}
/**
* This class is the Aptos Typescript SDK representation of a Move `vector<T>`,
* where `T` represents either a primitive type (`bool`, `u8`, `u64`, ...)
* or a BCS-serializable struct itself.
*
* It is a BCS-serializable, array-like type that contains an array of values of type `T`,
* where `T` is a class that implements `Serializable`.
*
* The purpose of this class is to facilitate easy construction of BCS-serializable
* Move `vector<T>` types.
*
* @example
* // in Move: `vector<u8> [1, 2, 3, 4];`
* const vecOfU8s = new MoveVector<U8>([new U8(1), new U8(2), new U8(3), new U8(4)]);
* // in Move: `std::bcs::to_bytes(vector<u8> [1, 2, 3, 4]);`
* const bcsBytes = vecOfU8s.toUint8Array();
*
* // vector<vector<u8>> [ vector<u8> [1], vector<u8> [1, 2, 3, 4], vector<u8> [5, 6, 7, 8] ];
* const vecOfVecs = new MoveVector<MoveVector<U8>>([
* new MoveVector<U8>([new U8(1)]),
* MoveVector.U8([1, 2, 3, 4]),
* MoveVector.U8([5, 6, 7, 8]),
* ]);
*
* // vector<Option<u8>> [ std::option::some<u8>(1), std::option::some<u8>(2) ];
* const vecOfOptionU8s = new MoveVector<MoveOption<U8>>([
* MoveOption.U8(1),
* MoveOption.U8(2),
* ]);
*
* // vector<MoveString> [ std::string::utf8(b"hello"), std::string::utf8(b"world") ];
* const vecOfStrings = new MoveVector([new MoveString("hello"), new MoveString("world")]);
* const vecOfStrings2 = MoveVector.MoveString(["hello", "world"]);
*
* @params
* values: an Array<T> of values where T is a class that implements Serializable
* @returns a `MoveVector<T>` with the values `values`
*/
declare class MoveVector<T extends Serializable & EntryFunctionArgument> extends Serializable implements TransactionArgument {
values: Array<T>;
constructor(values: Array<T>);
serializeForEntryFunction(serializer: Serializer): void;
/**
* NOTE: This function will only work when the inner values in the `MoveVector` are `U8`s.
* @param serializer
*/
serializeForScriptFunction(serializer: Serializer): void;
/**
* Factory method to generate a MoveVector of U8s from an array of numbers.
*
* @example
* const v = MoveVector.U8([1, 2, 3, 4]);
* @params values: an array of `numbers` to convert to U8s
* @returns a `MoveVector<U8>`
*/
static U8(values: Array<number> | HexInput): MoveVector<U8>;
/**
* Factory method to generate a MoveVector of U16s from an array of numbers.
*
* @example
* const v = MoveVector.U16([1, 2, 3, 4]);
* @params values: an array of `numbers` to convert to U16s
* @returns a `MoveVector<U16>`
*/
static U16(values: Array<number>): MoveVector<U16>;
/**
* Factory method to generate a MoveVector of U32s from an array of numbers.
*
* @example
* const v = MoveVector.U32([1, 2, 3, 4]);
* @params values: an array of `numbers` to convert to U32s
* @returns a `MoveVector<U32>`
*/
static U32(values: Array<number>): MoveVector<U32>;
/**
* Factory method to generate a MoveVector of U64s from an array of numbers or bigints.
*
* @example
* const v = MoveVector.U64([1, 2, 3, 4]);
* @params values: an array of numbers of type `number | bigint` to convert to U64s
* @returns a `MoveVector<U64>`
*/
static U64(values: Array<AnyNumber>): MoveVector<U64>;
/**
* Factory method to generate a MoveVector of U128s from an array of numbers or bigints.
*
* @example
* const v = MoveVector.U128([1, 2, 3, 4]);
* @params values: an array of numbers of type `number | bigint` to convert to U128s
* @returns a `MoveVector<U128>`
*/
static U128(values: Array<AnyNumber>): MoveVector<U128>;
/**
* Factory method to generate a MoveVector of U256s from an array of numbers or bigints.
*
* @example
* const v = MoveVector.U256([1, 2, 3, 4]);
* @params values: an array of numbers of type `number | bigint` to convert to U256s
* @returns a `MoveVector<U256>`
*/
static U256(values: Array<AnyNumber>): MoveVector<U256>;
/**
* Factory method to generate a MoveVector of Bools from an array of booleans.
*
* @example
* const v = MoveVector.Bool([true, false, true, false]);
* @params values: an array of `bools` to convert to Bools
* @returns a `MoveVector<Bool>`
*/
static Bool(values: Array<boolean>): MoveVector<Bool>;
/**
* Factory method to generate a MoveVector of MoveStrings from an array of strings.
*
* @example
* const v = MoveVector.MoveString(["hello", "world"]);
* @params values: an array of `strings` to convert to MoveStrings
* @returns a `MoveVector<MoveString>`
*/
static MoveString(values: Array<string>): MoveVector<MoveString>;
serialize(serializer: Serializer): void;
/**
* Deserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.
*
* NOTE: This only works with a depth of one. Generics will not work.
*
* NOTE: This will not work with types that aren't of the Serializable class.
*
* If you're looking for a more flexible deserialization function, you can use the deserializeVector function
* in the Deserializer class.
*
* @example
* const vec = MoveVector.deserialize(deserializer, U64);
* @params deserializer: the Deserializer instance to use, with bytes loaded into it already.
* cls: the class to typecast the input values to, must be a Serializable and Deserializable type.
* @returns a MoveVector of the corresponding class T
* *
*/
static deserialize<T extends Serializable & EntryFunctionArgument>(deserializer: Deserializer, cls: Deserializable<T>): MoveVector<T>;
}
declare class MoveString extends Serializable implements TransactionArgument {
value: string;
constructor(value: string);
serialize(serializer: Serializer): void;
serializeForEntryFunction(serializer: Serializer): void;
serializeForScriptFunction(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MoveString;
}
declare class MoveOption<T extends Serializable & EntryFunctionArgument> extends Serializable implements EntryFunctionArgument {
private vec;
readonly value?: T;
constructor(value?: T | null);
serializeForEntryFunction(serializer: Serializer): void;
/**
* Retrieves the inner value of the MoveOption.
*
* This method is inspired by Rust's `Option<T>.unwrap()`.
* In Rust, attempting to unwrap a `None` value results in a panic.
*
* Similarly, this method will throw an error if the value is not present.
*
* @example
* const option = new MoveOption<Bool>(new Bool(true));
* const value = option.unwrap(); // Returns the Bool instance
*
* @throws {Error} Throws an error if the MoveOption does not contain a value.
*
* @returns {T} The contained value if present.
*/
unwrap(): T;
isSome(): boolean;
serialize(serializer: Serializer): void;
/**
* Factory method to generate a MoveOption<U8> from a `number` or `undefined`.
*
* @example
* MoveOption.U8(1).isSome() === true;
* MoveOption.U8().isSome() === false;
* MoveOption.U8(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U8> with an inner value `value`
*/
static U8(value?: number | null): MoveOption<U8>;
/**
* Factory method to generate a MoveOption<U16> from a `number` or `undefined`.
*
* @example
* MoveOption.U16(1).isSome() === true;
* MoveOption.U16().isSome() === false;
* MoveOption.U16(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U16> with an inner value `value`
*/
static U16(value?: number | null): MoveOption<U16>;
/**
* Factory method to generate a MoveOption<U32> from a `number` or `undefined`.
*
* @example
* MoveOption.U32(1).isSome() === true;
* MoveOption.U32().isSome() === false;
* MoveOption.U32(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U32> with an inner value `value`
*/
static U32(value?: number | null): MoveOption<U32>;
/**
* Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.
*
* @example
* MoveOption.U64(1).isSome() === true;
* MoveOption.U64().isSome() === false;
* MoveOption.U64(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U64> with an inner value `value`
*/
static U64(value?: AnyNumber | null): MoveOption<U64>;
/**
* Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.
*
* @example
* MoveOption.U128(1).isSome() === true;
* MoveOption.U128().isSome() === false;
* MoveOption.U128(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U128> with an inner value `value`
*/
static U128(value?: AnyNumber | null): MoveOption<U128>;
/**
* Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.
*
* @example
* MoveOption.U256(1).isSome() === true;
* MoveOption.U256().isSome() === false;
* MoveOption.U256(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<U256> with an inner value `value`
*/
static U256(value?: AnyNumber | null): MoveOption<U256>;
/**
* Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.
*
* @example
* MoveOption.Bool(true).isSome() === true;
* MoveOption.Bool().isSome() === false;
* MoveOption.Bool(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<Bool> with an inner value `value`
*/
static Bool(value?: boolean | null): MoveOption<Bool>;
/**
* Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.
*
* @example
* MoveOption.MoveString("hello").isSome() === true;
* MoveOption.MoveString("").isSome() === true;
* MoveOption.MoveString().isSome() === false;
* MoveOption.MoveString(undefined).isSome() === false;
* @params value: the value used to fill the MoveOption. If `value` is undefined
* the resulting MoveOption's .isSome() method will return false.
* @returns a MoveOption<MoveString> with an inner value `value`
*/
static MoveString(value?: string | null): MoveOption<MoveString>;
static deserialize<U extends Serializable & EntryFunctionArgument>(deserializer: Deserializer, cls: Deserializable<U>): MoveOption<U>;
}
/**
* Each account stores an authentication key. Authentication key enables account owners to rotate
* their private key(s) associated with the account without changing the address that hosts their account.
* @see {@link https://aptos.dev/concepts/accounts | Account Basics}
*
* Account addresses can be derived from AuthenticationKey
*/
declare class AuthenticationKey extends Serializable {
/**
* An authentication key is always a SHA3-256 hash of data, and is always 32 bytes.
*
* The data to hash depends on the underlying public key type and the derivation scheme.
*/
static readonly LENGTH: number;
/**
* The raw bytes of the authentication key.
*/
readonly data: Hex;
constructor(args: {
data: HexInput;
});
serialize(serializer: Serializer): void;
/**
* Deserialize an AuthenticationKey from the byte buffer in a Deserializer instance.
* @param deserializer The deserializer to deserialize the AuthenticationKey from.
* @returns An instance of AuthenticationKey.
*/
static deserialize(deserializer: Deserializer): AuthenticationKey;
toString(): string;
toUint8Array(): Uint8Array;
static fromSchemeAndBytes(args: {
scheme: AuthenticationKeyScheme;
input: HexInput;
}): AuthenticationKey;
/**
* @deprecated Use `fromPublicKey` instead
* Derives an AuthenticationKey from the public key seed bytes and an explicit derivation scheme.
*
* This facilitates targeting a specific scheme for deriving an authentication key from a public key.
*
* @param args - the public key and scheme to use for the derivation
*/
static fromPublicKeyAndScheme(args: {
publicKey: AccountPublicKey;
scheme: AuthenticationKeyScheme;
}): AuthenticationKey;
/**
* Converts a PublicKey(s) to an AuthenticationKey, using the derivation scheme inferred from the
* instance of the PublicKey type passed in.
*
* @param args.publicKey
* @returns AuthenticationKey
*/
static fromPublicKey(args: {
publicKey: AccountPublicKey;
}): AuthenticationKey;
/**
* Derives an account address from an AuthenticationKey. Since an AccountAddress is also 32 bytes,
* the AuthenticationKey bytes are directly translated to an AccountAddress.
*
* @returns AccountAddress
*/
derivedAddress(): AccountAddress;
}
/**
* An abstract representation of a crypto signature,
* associated to a specific signature scheme e.g. Ed25519 or Secp256k1
*
* This is the product of signing a message directly from a PrivateKey
* and can be verified against a CryptoPublicKey.
*/
declare abstract class Signature extends Serializable {
/**
* Get the raw signature bytes
*/
abstract toUint8Array(): Uint8Array;
/**
* Get the signature as a hex string with a 0x prefix e.g. 0x123456...
*/
toString(): string;
}
/**
* Arguments for verifying a signature
*/
interface VerifySignatureArgs {
message: HexInput;
signature: Signature;
}
/**
* An abstract representation of a public key.
*
* Provides a common interface for verifying any signature.
*/
declare abstract class PublicKey extends Serializable {
/**
* Verifies that the private key associated with this public key signed the message with the given signature.
* @param args.message The message that was signed
* @param args.signature The signature to verify
*/
abstract verifySignature(args: VerifySignatureArgs): boolean;
/**
* Get the raw public key bytes
*/
abstract toUint8Array(): Uint8Array;
/**
* Get the public key as a hex string with a 0x prefix e.g. 0x123456...
*/
toString(): string;
}
/**
* An abstract representation of an account public key.
*
* Provides a common interface for deriving an authentication key.
*/
declare abstract class AccountPublicKey extends PublicKey {
/**
* Get the authentication key associated with this public key
*/
abstract authKey(): AuthenticationKey;
}
/**
* An abstract representation of a private key.
* It is associated to a signature scheme and provides signing capabilities.
*/
interface PrivateKey {
/**
* Sign the given message with the private key.
* @param message in HexInput format
*/
sign(message: HexInput): Signature;
/**
* Derive the public key associated with the private key
*/
publicKey(): PublicKey;
/**
* Get the private key in bytes (Uint8Array).
*/
toUint8Array(): Uint8Array;
}
/**
* Represents the public key of an Ed25519 key pair.
*
* Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
* `Legacy` and `Unified` authentication keys.
*
* Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also
* as `AnyPublicKey` that represents any `Unified authentication key`
*/
declare class Ed25519PublicKey extends AccountPublicKey {
/**
* Length of an Ed25519 public key
*/
static readonly LENGTH: number;
/**
* Bytes of the public key
* @private
*/
private readonly key;
/**
* Create a new PublicKey instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/
constructor(hexInput: HexInput);
/**
* Verifies a signed data with a public key
* @param args.message a signed message as a Hex string or Uint8Array
* @param args.signature the signature of the message
*/
verifySignature(args: VerifySignatureArgs): boolean;
authKey(): AuthenticationKey;
/**
* Get the public key in bytes (Uint8Array).
*
* @returns Uint8Array representation of the public key
*/
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Ed25519PublicKey;
/**
* @deprecated use `instanceof Ed25519PublicKey` instead.
*/
static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey;
}
/**
* Represents the private key of an Ed25519 key pair.
*/
declare class Ed25519PrivateKey extends Serializable implements PrivateKey {
/**
* Length of an Ed25519 private key
*/
static readonly LENGTH: number;
/**
* The Ed25519 key seed to use for BIP-32 compatibility
* See more {@link https://github.com/satoshilabs/slips/blob/master/slip-0010.md}
*/
static readonly SLIP_0010_SEED = "ed25519 seed";
/**
* The Ed25519 signing key
* @private
*/
private readonly signingKey;
/**
* Create a new PrivateKey instance from a Uint8Array or String.
*
* @param hexInput HexInput (string or Uint8Array)
*/
constructor(hexInput: HexInput);
/**
* Generate a new random private key.
*
* @returns Ed25519PrivateKey
*/
static generate(): Ed25519PrivateKey;
/**
* Derives a private key from a mnemonic seed phrase.
*
* To derive multiple keys from the same phrase, change the path
*
* IMPORTANT: Ed25519 supports hardened derivation only (since it lacks a key homomorphism,
* so non-hardened derivation cannot work)
*
* @param path the BIP44 path
* @param mnemonics the mnemonic seed phrase
*/
static fromDerivationPath(path: string, mnemonics: string): Ed25519PrivateKey;
/**
* A private inner function so we can separate from the main fromDerivationPath() method
* to add tests to verify we create the keys correctly.
*
* @param path the BIP44 path
* @param seed the seed phrase created by the mnemonics
* @param offset the offset used for key derivation, defaults to 0x80000000
* @returns
*/
private static fromDerivationPathInner;
/**
* Derive the Ed25519PublicKey for this private key.
*
* @returns Ed25519PublicKey
*/
publicKey(): Ed25519PublicKey;
/**
* Sign the given message with the private key.
*
* @param message a message as a string or Uint8Array
* @returns Signature
*/
sign(message: HexInput): Ed25519Signature;
/**
* Get the private key in bytes (Uint8Array).
*
* @returns Uint8Array representation of the private key
*/
toUint8Array(): Uint8Array;
/**
* Get the private key as a hex string with the 0x prefix.
*
* @returns string representation of the private key
*/
toString(): string;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Ed25519PrivateKey;
/**
* @deprecated use `instanceof Ed25519PrivateKey` instead.
*/
static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey;
}
/**
* A signature of a message signed using an Ed25519 private key
*/
declare class Ed25519Signature extends Signature {
/**
* Length of an Ed25519 signature
*/
static readonly LENGTH = 64;
/**
* The signature bytes
* @private
*/
private readonly data;
constructor(hexInput: HexInput);
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Ed25519Signature;
/**
* Checks if an ED25519 signature is non-canonical.
*
* Comes from Aptos Core
* https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-crypto/src/ed25519/ed25519_sigs.rs#L47-L85
*/
isCanonicalSignature(): boolean;
}
type DerivedKeys = {
key: Uint8Array;
chainCode: Uint8Array;
};
/**
* Aptos derive path is 637
*/
declare const APTOS_HARDENED_REGEX: RegExp;
declare const APTOS_BIP44_REGEX: RegExp;
/**
* A list of supported key types and associated seeds
*/
declare enum KeyType {
ED25519 = "ed25519 seed"
}
declare const HARDENED_OFFSET = 2147483648;
/**
* Aptos derive path is 637
*
* Parse and validate a path that is compliant to BIP-44 in form m/44'/637'/{account_index}'/{change_index}/{address_index}
* for Secp256k1
*
* Note that for secp256k1, last two components must be non-hardened.
*
* @param path path string (e.g. `m/44'/637'/0'/0/0`).
*/
declare function isValidBIP44Path(path: string): boolean;
/**
* Aptos derive path is 637
*
* Parse and validate a path that is compliant to SLIP-0010 and BIP-44
* in form m/44'/637'/{account_index}'/{change_index}'/{address_index}'.
* See SLIP-0010 {@link https://github.com/satoshilabs/slips/blob/master/slip-0044.md}
* See BIP-44 {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
*
* Note that for Ed25519, all components must be hardened.
* This is because non-hardened [PK] derivation would not work due to Ed25519's lack of a key homomorphism.
* Specifically, you cannot derive the PK associated with derivation path a/b/c given the PK of a/b.
* This is because the PK in Ed25519 is, more or less, computed as 𝑔𝐻(𝑠𝑘),
* with the hash function breaking the homomorphism.
*
* @param path path string (e.g. `m/44'/637'/0'/0'/0'`).
*/
declare function isValidHardenedPath(path: string): boolean;
declare const deriveKey: (hashSeed: Uint8Array | string, data: Uint8Array | string) => DerivedKeys;
/**
* Derive a child key from the private key
* @param key
* @param chainCode
* @param index
* @constructor
*/
declare const CKDPriv: ({ key, chainCode }: DerivedKeys, index: number) => DerivedKeys;
/**
* Splits derive path into segments
* @param path
*/
declare const splitPath: (path: string) => Array<string>;
/**
* Normalizes the mnemonic by removing extra whitespace and making it lowercase
* @param mnemonic the mnemonic seed phrase
*/
declare const mnemonicToSeed: (mnemonic: string) => Uint8Array;
/**
* Represents the public key of a K-of-N Ed25519 multi-sig transaction.
*/
declare class MultiEd25519PublicKey extends AccountPublicKey {
/**
* Maximum number of public keys supported
*/
static readonly MAX_KEYS = 32;
/**
* Minimum number of public keys needed
*/
static readonly MIN_KEYS = 2;
/**
* Minimum threshold for the number of valid signatures required
*/
static readonly MIN_THRESHOLD = 1;
/**
* List of Ed25519 public keys for this LegacyMultiEd25519PublicKey
*/
readonly publicKeys: Ed25519PublicKey[];
/**
* The minimum number of valid signatures required, for the number of public keys specified
*/
readonly threshold: number;
/**
* Public key for a K-of-N multi-sig transaction. A K-of-N multi-sig transaction means that for such a
* transaction to be executed, at least K out of the N authorized signers have signed the transaction
* and passed the check conducted by the chain.
*
* @see {@link
* https://aptos.dev/integration/creating-a-signed-transaction/ | Creating a Signed Transaction}
*
* @param args.publicKeys A list of public keys
* @param args.threshold At least "threshold" signatures must be valid
*/
constructor(args: {
publicKeys: Ed25519PublicKey[];
threshold: number;
});
verifySignature(args: VerifySignatureArgs): boolean;
authKey(): AuthenticationKey;
/**
* Converts a PublicKeys into Uint8Array (bytes) with: bytes = p1_bytes | ... | pn_bytes | threshold
*/
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiEd25519PublicKey;
}
/**
* Represents the signature of a K-of-N Ed25519 multi-sig transaction.
*/
declare class MultiEd25519Signature extends Signature {
/**
* Maximum number of Ed25519 signatures supported
*/
static MAX_SIGNATURES_SUPPORTED: number;
/**
* Number of bytes in the bitmap representing who signed the transaction (32-bits)
*/
static BITMAP_LEN: number;
/**
* The list of underlying Ed25519 signatures
*/
readonly signatures: Ed25519Signature[];
/**
* 32-bit Bitmap representing who signed the transaction
*
* This is represented where each public key can be masked to determine whether the message was signed by that key.
*/
readonly bitmap: Uint8Array;
/**
* Signature for a K-of-N multi-sig transaction.
*
* @see {@link
* https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}
*
* @param args.signatures A list of signatures
* @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth
* signature should be provided in `signatures`. Bits are read from left to right.
* Alternatively, you can specify an array of bitmap positions.
* Valid position should range between 0 and 31.
* @see MultiEd25519Signature.createBitmap
*/
constructor(args: {
signatures: Ed25519Signature[];
bitmap: Uint8Array | number[];
});
/**
* Converts a MultiSignature into Uint8Array (bytes) with `bytes = s1_bytes | ... | sn_bytes | bitmap`
*/
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiEd25519Signature;
/**
* Helper method to create a bitmap out of the specified bit positions
* @param args.bits The bitmap positions that should be set. A position starts at index 0.
* Valid position should range between 0 and 31.
* @example
* Here's an example of valid `bits`
* ```
* [0, 2, 31]
* ```
* `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.
* The result bitmap should be 0b1010000000000000000000000000001
*
* @returns bitmap that is 32bit long
*/
static createBitmap(args: {
bits: number[];
}): Uint8Array;
}
/**
* Represents any public key supported by Aptos.
*
* Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
* `Legacy` and `Unified` authentication keys.
*
* Any unified authentication key is represented in the SDK as `AnyPublicKey`.
*/
declare class AnyPublicKey extends AccountPublicKey {
/**
* Reference to the inner public key
*/
readonly publicKey: PublicKey;
/**
* Index of the underlying enum variant
*/
readonly variant: AnyPublicKeyVariant;
constructor(publicKey: PublicKey);
verifySignature(args: VerifySignatureArgs): boolean;
authKey(): AuthenticationKey;
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): AnyPublicKey;
/**
* @deprecated use `instanceof AnyPublicKey` instead.
*/
static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey;
/**
* @deprecated use `publicKey instanceof Ed25519PublicKey` instead.
*/
isEd25519(): boolean;
/**
* @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.
*/
isSecp256k1PublicKey(): boolean;
}
/**
* Instance of signature that uses the SingleKey authentication scheme.
* This signature can only be generated by a `SingleKeySigner`, since it uses the
* same authentication scheme.
*/
declare class AnySignature extends Signature {
readonly signature: Signature;
/**
* Index of the underlying enum variant
*/
private readonly variant;
constructor(signature: Signature);
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): AnySignature;
}
/**
* Represents the public key of a multi-agent account.
*
* The public keys of each individual agent can be any type of public key supported by Aptos.
* Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports
* `Legacy` and `Unified` authentication keys.
*/
declare class MultiKey extends AccountPublicKey {
/**
* List of any public keys
*/
readonly publicKeys: AnyPublicKey[];
/**
* The minimum number of valid signatures required, for the number of public keys specified
*/
readonly signaturesRequired: number;
constructor(args: {
publicKeys: Array<PublicKey>;
signaturesRequired: number;
});
verifySignature(args: VerifySignatureArgs): boolean;
authKey(): AuthenticationKey;
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiKey;
/**
* Create a bitmap that holds the mapping from the original public keys
* to the signatures passed in
*
* @param args.bits array of the index mapping to the matching public keys
* @returns Uint8array bit map
*/
createBitmap(args: {
bits: number[];
}): Uint8Array;
/**
* Get the index of the provided public key.
*
* @param publicKey array of the index mapping to the matching public keys
* @returns the corresponding index of the publicKey, if it exists
*/
getIndex(publicKey: PublicKey): number;
}
declare class MultiKeySignature extends Signature {
/**
* Number of bytes in the bitmap representing who signed the transaction (32-bits)
*/
static BITMAP_LEN: number;
/**
* Maximum number of Ed25519 signatures supported
*/
static MAX_SIGNATURES_SUPPORTED: number;
/**
* The list of underlying Ed25519 signatures
*/
readonly signatures: AnySignature[];
/**
* 32-bit Bitmap representing who signed the transaction
*
* This is represented where each public key can be masked to determine whether the message was signed by that key.
*/
readonly bitmap: Uint8Array;
/**
* Signature for a K-of-N multi-sig transaction.
*
* @see {@link
* https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}
*
* @param args.signatures A list of signatures
* @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth
* signature should be provided in `signatures`. Bits are read from left to right
*/
constructor(args: {
signatures: Array<Signature | AnySignature>;
bitmap: Uint8Array | number[];
});
/**
* Helper method to create a bitmap out of the specified bit positions
* @param args.bits The bitmap positions that should be set. A position starts at index 0.
* Valid position should range between 0 and 31.
* @example
* Here's an example of valid `bits`
* ```
* [0, 2, 31]
* ```
* `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.
* The result bitmap should be 0b1010000000000000000000000000001
*
* @returns bitmap that is 32bit long
*/
static createBitmap(args: {
bits: number[];
}): Uint8Array;
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiKeySignature;
}
/**
* Represents the Secp256k1 ecdsa public key
*
* Secp256k1 authentication key is represented in the SDK as `AnyPublicKey`.
*/
declare class Secp256k1PublicKey extends PublicKey {
static readonly LENGTH: number;
private readonly key;
/**
* Create a new PublicKey instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/
constructor(hexInput: HexInput);
/**
* Verifies a Secp256k1 signature against the public key
*
* Note signatures are validated to be canonical as a malleability check
*/
verifySignature(args: VerifySignatureArgs): boolean;
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Secp256k1PublicKey;
/**
* @deprecated use `instanceof Secp256k1PublicKey` instead
* @param publicKey
*/
static isPublicKey(publicKey: PublicKey): publicKey is Secp256k1PublicKey;
}
/**
* A Secp256k1 ecdsa private key
*/
declare class Secp256k1PrivateKey extends Serializable implements PrivateKey {
/**
* Length of Secp256k1 ecdsa private key
*/
static readonly LENGTH: number;
/**
* The private key bytes
* @private
*/
private readonly key;
/**
* Create a new PrivateKey instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/
constructor(hexInput: HexInput);
/**
* Generate a new random private key.
*
* @returns Secp256k1PrivateKey
*/
static generate(): Secp256k1PrivateKey;
/**
* Derives a private key from a mnemonic seed phrase.
*
* @param path the BIP44 path
* @param mnemonics the mnemonic seed phrase
*
* @returns The generated key
*/
static fromDerivationPath(path: string, mnemonics: string): Secp256k1PrivateKey;
/**
* A private inner function so we can separate from the main fromDerivationPath() method
* to add tests to verify we create the keys correctly.
*
* @param path the BIP44 path
* @param seed the seed phrase created by the mnemonics
*
* @returns The generated key
*/
private static fromDerivationPathInner;
/**
* Sign the given message with the private key.
*
* Note: signatures are canonical, and non-malleable
*
* @param message a message as a string or Uint8Array
* @returns Signature
*/
sign(message: HexInput): Secp256k1Signature;
/**
* Derive the Secp256k1PublicKey from this private key.
*
* @returns Secp256k1PublicKey
*/
publicKey(): Secp256k1PublicKey;
/**
* Get the private key in bytes (Uint8Array).
*
* @returns
*/
toUint8Array(): Uint8Array;
/**
* Get the private key as a hex string with the 0x prefix.
*
* @returns string representation of the private key
*/
toString(): string;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Secp256k1PrivateKey;
/**
* @deprecated use `instanceof Secp256k1PrivateKey` instead
*/
static isPrivateKey(privateKey: PrivateKey): privateKey is Secp256k1PrivateKey;
}
/**
* A signature of a message signed using a Secp256k1 ecdsa private key
*/
declare class Secp256k1Signature extends Signature {
/**
* Secp256k1 ecdsa signatures are 256-bit.
*/
static readonly LENGTH = 64;
/**
* The signature bytes
* @private
*/
private readonly data;
/**
* Create a new Signature instance from a Uint8Array or String.
*
* @param hexInput A HexInput (string or Uint8Array)
*/
constructor(hexInput: HexInput);
toUint8Array(): Uint8Array;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Secp256k1Signature;
}
declare abstract class AccountAuthenticator extends Serializable {
abstract serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): AccountAuthenticator;
isEd25519(): this is AccountAuthenticatorEd25519;
isMultiEd25519(): this is AccountAuthenticatorMultiEd25519;
isSingleKey(): this is AccountAuthenticatorSingleKey;
isMultiKey(): this is AccountAuthenticatorMultiKey;
}
/**
* Transaction authenticator Ed25519 for a multi signer transaction
*
* @param public_key Account's Ed25519 public key.
* @param signature Account's Ed25519 signature
*
*/
declare class AccountAuthenticatorEd25519 extends AccountAuthenticator {
readonly public_key: Ed25519PublicKey;
readonly signature: Ed25519Signature;
constructor(public_key: Ed25519PublicKey, signature: Ed25519Signature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): AccountAuthenticatorEd25519;
}
/**
* Transaction authenticator Multi Ed25519 for a multi signers transaction
*
* @param public_key Account's MultiEd25519 public key.
* @param signature Account's MultiEd25519 signature
*
*/
declare class AccountAuthenticatorMultiEd25519 extends AccountAuthenticator {
readonly public_key: MultiEd25519PublicKey;
readonly signature: MultiEd25519Signature;
constructor(public_key: MultiEd25519PublicKey, signature: MultiEd25519Signature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): AccountAuthenticatorMultiEd25519;
}
/**
* AccountAuthenticatorSingleKey for a single signer
*
* @param public_key AnyPublicKey
* @param signature AnySignature
*
*/
declare class AccountAuthenticatorSingleKey extends AccountAuthenticator {
readonly public_key: AnyPublicKey;
readonly signature: AnySignature;
constructor(public_key: AnyPublicKey, signature: AnySignature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): AccountAuthenticatorSingleKey;
}
/**
* AccountAuthenticatorMultiKey for a multi signer
*
* @param public_keys MultiKey
* @param signatures Signature
*
*/
declare class AccountAuthenticatorMultiKey extends AccountAuthenticator {
readonly public_keys: MultiKey;
readonly signatures: MultiKeySignature;
constructor(public_keys: MultiKey, signatures: MultiKeySignature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): AccountAuthenticatorMultiKey;
}
/**
* Type of API endpoint for request routing
*/
declare enum AptosApiType {
FULLNODE = "Fullnode",
INDEXER = "Indexer",
FAUCET = "Faucet"
}
/**
* The default max gas amount when none is given.
*
* This is the maximum number of gas units that will be used by a transaction before being rejected.
*
* Note that max gas amount varies based on the transaction. A larger transaction will go over this
* default gas amount, and the value will need to be changed for the specific transaction.
*/
declare const DEFAULT_MAX_GAS_AMOUNT = 200000;
/**
* The default transaction expiration seconds from now.
*
* This time is how long until the blockchain nodes will reject the transaction.
*
* Note that the transaction expiration time varies based on network connection and network load. It may need to be
* increased for the transaction to be processed.
*/
declare const DEFAULT_TXN_EXP_SEC_FROM_NOW = 20;
/**
* The default number of seconds to wait for a transaction to be processed.
*
* This time is the amount of time that the SDK will wait for a transaction to be processed when waiting for
* the results of the transaction. It may take longer based on network connection and network load.
*/
declare const DEFAULT_TXN_TIMEOUT_SEC = 20;
/**
* The default gas currency for the network.
*/
declare const APTOS_COIN = "0x1::aptos_coin::AptosCoin";
declare const RAW_TRANSACTION_SALT = "APTOS::RawTransaction";
declare const RAW_TRANSACTION_WITH_DATA_SALT = "APTOS::RawTransactionWithData";
/**
* The list of supported Processor types for our indexer api.
*
* These can be found from the processor_status table in the indexer database.
* {@link https://cloud.hasura.io/public/graphiql?endpoint=https://api.mainnet.aptoslabs.com/v1/graphql}
*/
declare enum ProcessorType {
ACCOUNT_TRANSACTION_PROCESSOR = "account_transactions_processor",
DEFAULT = "default_processor",
EVENTS_PROCESSOR = "events_processor",
FUNGIBLE_ASSET_PROCESSOR = "fungible_asset_processor",
STAKE_PROCESSOR = "stake_processor",
TOKEN_V2_PROCESSOR = "token_v2_processor",
USER_TRANSACTION_PROCESSOR = "user_transaction_processor"
}
/**
* This class holds the config information for the SDK client instance.
*
* @example
*
* const aptosConfig = new AptosConfig({network:Network.TESTNET})
*/
declare class AptosConfig {
/**
* The Network that this SDK is associated with. Defaults to DEVNET
*/
readonly network: Network;
/**
* The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client
*/
readonly client: Client;
/**
* The optional hardcoded fullnode URL to send requests to instead of using the network
*/
readonly fullnode?: string;
/**
* The optional hardcoded faucet URL to send requests to instead of using the network
*/
readonly faucet?: string;
/**
* The optional hardcoded indexer URL to send requests to instead of using the network
*/
readonly indexer?: string;
/**
* Optional client configurations
*/
readonly clientConfig?: ClientConfig;
/**
* Optional specific Fullnode configurations
*/
readonly fullnodeConfig?: FullNodeConfig;
/**
* Optional specific Indexer configurations
*/
readonly indexerConfig?: IndexerConfig;
/**
* Optional specific Faucet configurations
*/
readonly faucetConfig?: FaucetConfig;
constructor(settings?: AptosSettings);
/**
* Returns the URL endpoint to send the request to.
* If a custom URL was provided in the config, that URL is returned.
* If a custom URL was provided but not URL endpoints, an error is thrown.
* Otherwise, the URL endpoint is derived from the network.
*
* @param apiType - The type of Aptos API to get the URL for.
*
* @internal
*/
getRequestUrl(apiType: AptosApiType): string;
}
/**
* Representation of a ChainId that can serialized and deserialized
*/
declare class ChainId extends Serializable {
readonly chainId: number;
constructor(chainId: number);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): ChainId;
}
/**
* Representation of an Identifier that can serialized and deserialized.
* We use Identifier to represent the module "name" in "ModuleId" and
* the "function name" in "EntryFunction"
*/
declare class Identifier extends Serializable {
identifier: string;
constructor(identifier: string);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Identifier;
}
/**
* Representation of a ModuleId that can serialized and deserialized
* ModuleId means the module address (e.g "0x1") and the module name (e.g "coin")
*/
declare class ModuleId extends Serializable {
readonly address: AccountAddress;
readonly name: Identifier;
/**
* Full name of a module.
* @param address The account address. e.g "0x1"
* @param name The module name under the "address". e.g "coin"
*/
constructor(address: AccountAddress, name: Identifier);
/**
* Converts a string literal to a ModuleId
* @param moduleId String literal in format "account_address::module_name", e.g. "0x1::coin"
* @returns ModuleId
*/
static fromStr(moduleId: MoveModuleId): ModuleId;
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): ModuleId;
}
declare abstract class TypeTag extends Serializable {
abstract serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): TypeTag;
abstract toString(): string;
isBool(): this is TypeTagBool;
isAddress(): this is TypeTagAddress;
isGeneric(): this is TypeTagGeneric;
isSigner(): this is TypeTagSigner;
isVector(): this is TypeTagVector;
isStruct(): this is TypeTagStruct;
isU8(): this is TypeTagU8;
isU16(): this is TypeTagU16;
isU32(): this is TypeTagU32;
isU64(): this is TypeTagU64;
isU128(): this is TypeTagU128;
isU256(): this is TypeTagU256;
}
declare class TypeTagBool extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagBool;
}
declare class TypeTagU8 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU8;
}
declare class TypeTagU16 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU16;
}
declare class TypeTagU32 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU32;
}
declare class TypeTagU64 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU64;
}
declare class TypeTagU128 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU128;
}
declare class TypeTagU256 extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagU256;
}
declare class TypeTagAddress extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagAddress;
}
declare class TypeTagSigner extends TypeTag {
toString(): string;
serialize(serializer: Serializer): void;
static load(_deserializer: Deserializer): TypeTagSigner;
}
declare class TypeTagReference extends TypeTag {
readonly value: TypeTag;
toString(): `&${string}`;
constructor(value: TypeTag);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TypeTagReference;
}
/**
* Generics are used for type parameters in entry functions. However,
* they are not actually serialized into a real type, so they cannot be
* used as a type directly.
*/
declare class TypeTagGeneric extends TypeTag {
readonly value: number;
toString(): `T${number}`;
constructor(value: number);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TypeTagGeneric;
}
declare class TypeTagVector extends TypeTag {
readonly value: TypeTag;
toString(): `vector<${string}>`;
constructor(value: TypeTag);
static u8(): TypeTagVector;
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TypeTagVector;
}
declare class TypeTagStruct extends TypeTag {
readonly value: StructTag;
toString(): `0x${string}::${string}::${string}`;
constructor(value: StructTag);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TypeTagStruct;
isTypeTag(address: AccountAddress, moduleName: string, structName: string): boolean;
isString(): boolean;
isOption(): boolean;
isObject(): boolean;
}
declare class StructTag extends Serializable {
readonly address: AccountAddress;
readonly moduleName: Identifier;
readonly name: Identifier;
readonly typeArgs: Array<TypeTag>;
constructor(address: AccountAddress, module_name: Identifier, name: Identifier, type_args: Array<TypeTag>);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): StructTag;
}
declare function aptosCoinStructTag(): StructTag;
declare function stringStructTag(): StructTag;
declare function optionStructTag(typeArg: TypeTag): StructTag;
declare function objectStructTag(typeArg: TypeTag): StructTag;
/**
* Deserialize a Script Transaction Argument
*/
declare function deserializeFromScriptArgument(deserializer: Deserializer): TransactionArgument;
/**
* Representation of the supported Transaction Payload
* that can serialized and deserialized
*/
declare abstract class TransactionPayload extends Serializable {
/**
* Serialize a Transaction Payload
*/
abstract serialize(serializer: Serializer): void;
/**
* Deserialize a Transaction Payload
*/
static deserialize(deserializer: Deserializer): TransactionPayload;
}
/**
* Representation of a Transaction Payload Script that can serialized and deserialized
*/
declare class TransactionPayloadScript extends TransactionPayload {
readonly script: Script;
constructor(script: Script);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionPayloadScript;
}
/**
* Representation of a Transaction Payload Entry Function that can serialized and deserialized
*/
declare class TransactionPayloadEntryFunction extends TransactionPayload {
readonly entryFunction: EntryFunction;
constructor(entryFunction: EntryFunction);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionPayloadEntryFunction;
}
/**
* Representation of a Transaction Payload Multi-sig that can serialized and deserialized
*/
declare class TransactionPayloadMultiSig extends TransactionPayload {
readonly multiSig: MultiSig;
constructor(multiSig: MultiSig);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionPayloadMultiSig;
}
/**
* Representation of a EntryFunction that can serialized and deserialized
*/
declare class EntryFunction {
readonly module_name: ModuleId;
readonly function_name: Identifier;
readonly type_args: Array<TypeTag>;
readonly args: Array<EntryFunctionArgument>;
/**
* Contains the payload to run a function within a module.
* @param module_name Fully qualified module name in format "account_address::module_name" e.g. "0x1::coin"
* @param function_name The function name. e.g "transfer"
* @param type_args Type arguments that move function requires.
*
* @example
* A coin transfer function has one type argument "CoinType".
* ```
* public entry fun transfer<CoinType>(from: &signer, to: address, amount: u64)
* ```
* @param args arguments to the move function.
*
* @example
* A coin transfer function has three arguments "from", "to" and "amount".
* ```
* public entry fun transfer<CoinType>(from: &signer, to: address, amount: u64)
* ```
*/
constructor(module_name: ModuleId, function_name: Identifier, type_args: Array<TypeTag>, args: Array<EntryFunctionArgument>);
/**
* A helper function to build a EntryFunction payload from raw primitive values
*
* @param module_id Fully qualified module name in format "AccountAddress::module_id" e.g. "0x1::coin"
* @param function_name Function name
* @param type_args Type arguments that move function requires.
*
* @example
* A coin transfer function has one type argument "CoinType".
* ```
* public(script) fun transfer<CoinType>(from: &signer, to: address, amount: u64,)
* ```
* @param args Arguments to the move function.
*
* @example
* A coin transfer function has three arguments "from", "to" and "amount".
* ```
* public(script) fun transfer<CoinType>(from: &signer, to: address, amount: u64,)
* ```
* @returns EntryFunction
*/
static build(module_id: MoveModuleId, function_name: string, type_args: Array<TypeTag>, args: Array<EntryFunctionArgument>): EntryFunction;
serialize(serializer: Serializer): void;
/**
* Deserializes an entry function payload with the arguments represented as EntryFunctionBytes instances.
* @see EntryFunctionBytes
*
* NOTE: When you deserialize an EntryFunction payload with this method, the entry function
* arguments are populated into the deserialized instance as type-agnostic, raw fixed bytes
* in the form of the EntryFunctionBytes class.
*
* In order to correctly deserialize these arguments as their actual type representations, you
* must know the types of the arguments beforehand and deserialize them yourself individually.
*
* One way you could achieve this is by using the ABIs for an entry function and deserializing each
* argument as its given, corresponding type.
*
* @param deserializer
* @returns A deserialized EntryFunction payload for a transaction.
*
*/
static deserialize(deserializer: Deserializer): EntryFunction;
}
/**
* Representation of a Script that can serialized and deserialized
*/
declare class Script {
/**
* The move module bytecode
*/
readonly bytecode: Uint8Array;
/**
* The type arguments that the bytecode function requires.
*/
readonly type_args: Array<TypeTag>;
/**
* The arguments that the bytecode function requires.
*/
readonly args: Array<ScriptFunctionArgument>;
/**
* Scripts contain the Move bytecodes payload that can be submitted to Aptos chain for execution.
*
* @param bytecode The move module bytecode
* @param type_args The type arguments that the bytecode function requires.
*
* @example
* A coin transfer function has one type argument "CoinType".
* ```
* public(script) fun transfer<CoinType>(from: &signer, to: address, amount: u64,)
* ```
* @param args The arguments that the bytecode function requires.
*
* @example
* A coin transfer function has three arguments "from", "to" and "amount".
* ```
* public(script) fun transfer<CoinType>(from: &signer, to: address, amount: u64,)
* ```
*/
constructor(bytecode: Uint8Array, type_args: Array<TypeTag>, args: Array<ScriptFunctionArgument>);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): Script;
}
/**
* Representation of a MultiSig that can serialized and deserialized
*/
declare class MultiSig {
readonly multisig_address: AccountAddress;
readonly transaction_payload?: MultiSigTransactionPayload;
/**
* Contains the payload to run a multi-sig account transaction.
*
* @param multisig_address The multi-sig account address the transaction will be executed as.
*
* @param transaction_payload The payload of the multi-sig transaction. This is optional when executing a multi-sig
* transaction whose payload is already stored on chain.
*/
constructor(multisig_address: AccountAddress, transaction_payload?: MultiSigTransactionPayload);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiSig;
}
/**
* Representation of a MultiSig Transaction Payload from `multisig_account.move`
* that can be serialized and deserialized
* This class exists right now to represent an extensible transaction payload class for
* transactions used in `multisig_account.move`. Eventually, this class will be able to
* support script payloads when the `multisig_account.move` module supports them.
*/
declare class MultiSigTransactionPayload extends Serializable {
readonly transaction_payload: EntryFunction;
/**
* Contains the payload to run a multi-sig account transaction.
*
* @param transaction_payload The payload of the multi-sig transaction.
* This can only be EntryFunction for now but,
* Script might be supported in the future.
*/
constructor(transaction_payload: EntryFunction);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiSigTransactionPayload;
}
/**
* Representation of a Raw Transaction that can serialized and deserialized
*/
declare class RawTransaction extends Serializable {
readonly sender: AccountAddress;
readonly sequence_number: bigint;
readonly payload: TransactionPayload;
readonly max_gas_amount: bigint;
readonly gas_unit_price: bigint;
readonly expiration_timestamp_secs: bigint;
readonly chain_id: ChainId;
/**
* RawTransactions contain the metadata and payloads that can be submitted to Aptos chain for execution.
* RawTransactions must be signed before Aptos chain can execute them.
*
* @param sender The sender Account Address
* @param sequence_number Sequence number of this transaction. This must match the sequence number stored in
* the sender's account at the time the transaction executes.
* @param payload Instructions for the Aptos Blockchain, including publishing a module,
* execute an entry function or execute a script payload.
* @param max_gas_amount Maximum total gas to spend for this transaction. The account must have more
* than this gas or the transaction will be discarded during validation.
* @param gas_unit_price Price to be paid per gas unit.
* @param expiration_timestamp_secs The blockchain timestamp at which the blockchain would discard this transaction.
* @param chain_id The chain ID of the blockchain that this transaction is intended to be run on.
*/
constructor(sender: AccountAddress, sequence_number: bigint, payload: TransactionPayload, max_gas_amount: bigint, gas_unit_price: bigint, expiration_timestamp_secs: bigint, chain_id: ChainId);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): RawTransaction;
}
/**
* Representation of a Raw Transaction With Data that can serialized and deserialized
*/
declare abstract class RawTransactionWithData extends Serializable {
/**
* Serialize a Raw Transaction With Data
*/
abstract serialize(serializer: Serializer): void;
/**
* Deserialize a Raw Transaction With Data
*/
static deserialize(deserializer: Deserializer): RawTransactionWithData;
}
/**
* Representation of a Multi Agent Transaction that can serialized and deserialized
*/
declare class MultiAgentRawTransaction extends RawTransactionWithData {
/**
* The raw transaction
*/
readonly raw_txn: RawTransaction;
/**
* The secondary signers on this transaction
*/
readonly secondary_signer_addresses: Array<AccountAddress>;
constructor(raw_txn: RawTransaction, secondary_signer_addresses: Array<AccountAddress>);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): MultiAgentRawTransaction;
}
/**
* Representation of a Fee Payer Transaction that can serialized and deserialized
*/
declare class FeePayerRawTransaction extends RawTransactionWithData {
/**
* The raw transaction
*/
readonly raw_txn: RawTransaction;
/**
* The secondary signers on this transaction - optional and can be empty
*/
readonly secondary_signer_addresses: Array<AccountAddress>;
/**
* The fee payer account address
*/
readonly fee_payer_address: AccountAddress;
constructor(raw_txn: RawTransaction, secondary_signer_addresses: Array<AccountAddress>, fee_payer_address: AccountAddress);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): FeePayerRawTransaction;
}
/**
* Representation of the challenge which is needed to sign by owner of the account
* to rotate the authentication key.
*/
declare class RotationProofChallenge extends Serializable {
readonly accountAddress: AccountAddress;
readonly moduleName: MoveString;
readonly structName: MoveString;
readonly originator: AccountAddress;
readonly currentAuthKey: AccountAddress;
readonly newPublicKey: MoveVector<U8>;
readonly sequenceNumber: U64;
constructor(args: {
sequenceNumber: AnyNumber;
originator: AccountAddress;
currentAuthKey: AccountAddress;
newPublicKey: PublicKey;
});
serialize(serializer: Serializer): void;
}
declare abstract class TransactionAuthenticator extends Serializable {
abstract serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): TransactionAuthenticator;
}
/**
* Transaction authenticator Ed25519 for a single signer transaction
*
* @param public_key Client's public key.
* @param signature Ed25519 signature of a raw transaction.
* @see {@link https://aptos.dev/integration/creating-a-signed-transaction | Creating a Signed Transaction}
* for details about generating a signature.
*/
declare class TransactionAuthenticatorEd25519 extends TransactionAuthenticator {
readonly public_key: Ed25519PublicKey;
readonly signature: Ed25519Signature;
constructor(public_key: Ed25519PublicKey, signature: Ed25519Signature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionAuthenticatorEd25519;
}
/**
* Transaction authenticator Ed25519 for a multi signers transaction
*
* @param public_key Client's public key.
* @param signature Multi Ed25519 signature of a raw transaction.
*
*/
declare class TransactionAuthenticatorMultiEd25519 extends TransactionAuthenticator {
readonly public_key: MultiEd25519PublicKey;
readonly signature: MultiEd25519Signature;
constructor(public_key: MultiEd25519PublicKey, signature: MultiEd25519Signature);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionAuthenticatorMultiEd25519;
}
/**
* Transaction authenticator for a multi-agent transaction
*
* @param sender Sender account authenticator
* @param secondary_signer_addresses Secondary signers address
* @param secondary_signers Secondary signers account authenticators
*
*/
declare class TransactionAuthenticatorMultiAgent extends TransactionAuthenticator {
readonly sender: AccountAuthenticator;
readonly secondary_signer_addresses: Array<AccountAddress>;
readonly secondary_signers: Array<AccountAuthenticator>;
constructor(sender: AccountAuthenticator, secondary_signer_addresses: Array<AccountAddress>, secondary_signers: Array<AccountAuthenticator>);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionAuthenticatorMultiAgent;
}
/**
* Transaction authenticator for a fee payer transaction
*
* @param sender Sender account authenticator
* @param secondary_signer_addresses Secondary signers address
* @param secondary_signers Secondary signers account authenticators
* @param fee_payer Object of the fee payer account address and the fee payer authentication
*
*/
declare class TransactionAuthenticatorFeePayer extends TransactionAuthenticator {
readonly sender: AccountAuthenticator;
readonly secondary_signer_addresses: Array<AccountAddress>;
readonly secondary_signers: Array<AccountAuthenticator>;
readonly fee_payer: {
address: AccountAddress;
authenticator: AccountAuthenticator;
};
constructor(sender: AccountAuthenticator, secondary_signer_addresses: Array<AccountAddress>, secondary_signers: Array<AccountAuthenticator>, fee_payer: {
address: AccountAddress;
authenticator: AccountAuthenticator;
});
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionAuthenticatorMultiAgent;
}
/**
* Single Sender authenticator for a single signer transaction
*
* @param sender AccountAuthenticator
*/
declare class TransactionAuthenticatorSingleSender extends TransactionAuthenticator {
readonly sender: AccountAuthenticator;
constructor(sender: AccountAuthenticator);
serialize(serializer: Serializer): void;
static load(deserializer: Deserializer): TransactionAuthenticatorSingleSender;
}
declare class SignedTransaction extends Serializable {
readonly raw_txn: RawTransaction;
readonly authenticator: TransactionAuthenticator;
/**
* A SignedTransaction consists of a raw transaction and an authenticator. The authenticator
* contains a client's public key and the signature of the raw transaction.
*
* @see {@link https://aptos.dev/integration/creating-a-signed-transaction | Creating a Signed Transaction}
*
* @param raw_txn
* @param authenticator Contains a client's public key and the signature of the raw transaction.
* Authenticator has 3 flavors: single signature, multi-signature and multi-agent.
* @see {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs} for details.
*/
constructor(raw_txn: RawTransaction, authenticator: TransactionAuthenticator);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): SignedTransaction;
}
/**
* Representation of a SimpleTransaction that can serialized and deserialized
*/
declare class SimpleTransaction extends Serializable {
rawTransaction: RawTransaction;
feePayerAddress?: AccountAddress | undefined;
readonly secondarySignerAddresses: undefined;
/**
* SimpleTransaction represents a simple transaction type of a single signer that
* can be submitted to Aptos chain for execution.
*
* SimpleTransaction metadata contains the Raw Transaction and an optional
* sponsor Account Address to pay the gas fees.
*
* @param rawTransaction The Raw Tranasaction
* @param feePayerAddress The sponsor Account Address
*/
constructor(rawTransaction: RawTransaction, feePayerAddress?: AccountAddress);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): SimpleTransaction;
}
/**
* Representation of a Raw Transaction that can serialized and deserialized
*/
declare class MultiAgentTransaction extends Serializable {
rawTransaction: RawTransaction;
feePayerAddress?: AccountAddress | undefined;
secondarySignerAddresses: AccountAddress[];
/**
* SimpleTransaction represents a simple transaction type of a single signer that
* can be submitted to Aptos chain for execution.
*
* SimpleTransaction metadata contains the Raw Transaction and an optional
* sponsor Account Address to pay the gas fees.
*
* @param rawTransaction The Raw Tranasaction
* @param feePayerAddress The sponsor Account Address
*/
constructor(rawTransaction: RawTransaction, secondarySignerAddresses: AccountAddress[], feePayerAddress?: AccountAddress);
serialize(serializer: Serializer): void;
static deserialize(deserializer: Deserializer): MultiAgentTransaction;
}
/**
* Entry function arguments to be used when building a raw transaction using remote ABI
*/
type SimpleEntryFunctionArgumentTypes = boolean | number | bigint | string | null | undefined | Uint8Array | ArrayBuffer | Array<SimpleEntryFunctionArgumentTypes | EntryFunctionArgumentTypes>;
/**
* Entry function arguments to be used when building a raw transaction using BCS serialized arguments
*/
type EntryFunctionArgumentTypes = Bool | U8 | U16 | U32 | U64 | U128 | U256 | AccountAddress | MoveVector<EntryFunctionArgumentTypes> | MoveOption<EntryFunctionArgumentTypes> | MoveString | FixedBytes;
/**
* Script function arguments to be used when building a raw transaction using BCS serialized arguments
*/
type ScriptFunctionArgumentTypes = Bool | U8 | U16 | U32 | U64 | U128 | U256 | AccountAddress | MoveVector<U8> | MoveString | FixedBytes;
/**
* Type that holds all raw transaction instances Aptos SDK supports
*/
type AnyRawTransactionInstance = RawTransaction | MultiAgentRawTransaction | FeePayerRawTransaction;
/**
* Optional options to set when generating a transaction
*/
type InputGenerateTransactionOptions = {
maxGasAmount?: number;
gasUnitPrice?: number;
expireTimestamp?: number;
accountSequenceNumber?: AnyNumber;
};
/**
* The generated transaction payload type that was produces from `generateTransactionPayload()` function.
*/
type AnyTransactionPayloadInstance = TransactionPayloadEntryFunction | TransactionPayloadScript | TransactionPayloadMultiSig;
/**
* Unified type for the data needed to generate a transaction payload of types:
* Entry Function | Script | Multi Sig
*/
type InputGenerateTransactionPayloadData = InputEntryFunctionData | InputScriptData | InputMultiSigData;
type InputGenerateTransactionPayloadDataWithRemoteABI = InputScriptData | InputEntryFunctionDataWithRemoteABI | InputMultiSigDataWithRemoteABI;
/**
* The data needed to generate an Entry Function payload
*/
type InputEntryFunctionData = {
function: MoveFunctionId;
typeArguments?: Array<TypeTag | string>;
functionArguments: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
abi?: EntryFunctionABI;
};
type InputGenerateTransactionPayloadDataWithABI = InputEntryFunctionDataWithABI | InputMultiSigDataWithABI;
type InputEntryFunctionDataWithABI = Omit<InputEntryFunctionData, "abi"> & {
abi: EntryFunctionABI;
};
type InputMultiSigDataWithABI = {
multisigAddress: AccountAddressInput;
} & InputEntryFunctionDataWithABI;
type InputEntryFunctionDataWithRemoteABI = InputEntryFunctionData & {
aptosConfig: AptosConfig;
};
/**
* The data needed to generate a Multi Sig payload
*/
type InputMultiSigData = {
multisigAddress: AccountAddressInput;
} & InputEntryFunctionData;
/**
* The data needed to generate a Multi Sig payload
*/
type InputMultiSigDataWithRemoteABI = {
multisigAddress: AccountAddressInput;
} & InputEntryFunctionDataWithRemoteABI;
/**
* The data needed to generate a Script payload
*/
type InputScriptData = {
bytecode: HexInput;
typeArguments?: Array<TypeTag>;
functionArguments: Array<ScriptFunctionArgumentTypes>;
};
/**
* The data needed to generate a View Function payload
*/
type InputViewFunctionData = {
function: MoveFunctionId;
typeArguments?: Array<TypeTag | string>;
functionArguments?: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
abi?: ViewFunctionABI;
};
/**
* Data needed to generate a view function payload and fetch the remote ABI
*/
type InputViewFunctionDataWithRemoteABI = InputViewFunctionData & {
aptosConfig: AptosConfig;
};
/**
* Data needed to generate a view function, with an already fetched ABI
*/
type InputViewFunctionDataWithABI = InputViewFunctionData & {
abi: ViewFunctionABI;
};
/**
* Data need for a generic function ABI, both view and entry
*/
type FunctionABI = {
typeParameters: Array<MoveFunctionGenericTypeParam>;
parameters: Array<TypeTag>;
};
/**
* Interface of an Entry function's ABI.
*
* This is used to provide type checking and simple input conversion on ABI based transaction submission.
*/
type EntryFunctionABI = FunctionABI & {
signers?: number;
};
/**
* Interface of an View function's ABI.
*
* This is used to provide type checking and simple input conversion on ABI based transaction submission.
*/
type ViewFunctionABI = FunctionABI & {
returnTypes: Array<TypeTag>;
};
/**
* Interface of the arguments to generate a single signer transaction.
* Used to provide to `generateTransaction()` method in the transaction builder flow
*/
interface InputGenerateSingleSignerRawTransactionArgs {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
payload: AnyTransactionPayloadInstance;
options?: InputGenerateTransactionOptions;
feePayerAddress?: AccountAddressInput;
}
/**
* Interface of the arguments to generate a multi-agent transaction.
* Used to provide to `generateTransaction()` method in the transaction builder flow
*/
interface InputGenerateMultiAgentRawTransactionArgs {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
payload: AnyTransactionPayloadInstance;
secondarySignerAddresses: AccountAddressInput[];
options?: InputGenerateTransactionOptions;
feePayerAddress?: AccountAddressInput;
}
/**
* Unified type that holds all the interfaces to generate different transaction types
*/
type InputGenerateRawTransactionArgs = InputGenerateSingleSignerRawTransactionArgs | InputGenerateMultiAgentRawTransactionArgs;
/**
* Unified type that holds all the return interfaces when generating different transaction types
*/
type AnyRawTransaction = SimpleTransaction | MultiAgentTransaction;
type InputSimulateTransactionData = {
/**
* The transaction to simulate, probably generated by `generateTransaction()`
*/
transaction: AnyRawTransaction;
/**
* For a single signer transaction
*/
signerPublicKey: PublicKey;
/**
* For a fee payer or multi-agent transaction that requires additional signers in
*/
secondarySignersPublicKeys?: Array<PublicKey>;
/**
* For a fee payer transaction (aka Sponsored Transaction)
*/
feePayerPublicKey?: PublicKey;
options?: InputSimulateTransactionOptions;
};
type InputSimulateTransactionOptions = {
estimateGasUnitPrice?: boolean;
estimateMaxGasAmount?: boolean;
estimatePrioritizedGasUnitPrice?: boolean;
};
/**
* Interface that holds the user data input when generating a single signer transaction
*/
interface InputGenerateSingleSignerRawTransactionData {
sender: AccountAddressInput;
data: InputGenerateTransactionPayloadData;
options?: InputGenerateTransactionOptions;
withFeePayer?: boolean;
secondarySignerAddresses?: undefined;
}
/**
* Interface that holds the user data input when generating a multi-agent transaction
*/
interface InputGenerateMultiAgentRawTransactionData {
sender: AccountAddressInput;
data: InputGenerateTransactionPayloadData;
secondarySignerAddresses: AccountAddressInput[];
options?: InputGenerateTransactionOptions;
withFeePayer?: boolean;
}
/**
* Unified type that holds all the user data input interfaces when generating different transaction types
*/
type InputGenerateTransactionData = InputGenerateSingleSignerRawTransactionData | InputGenerateMultiAgentRawTransactionData;
/**
* Interface that holds the user data input when submitting a transaction
*/
interface InputSubmitTransactionData {
transaction: AnyRawTransaction;
senderAuthenticator: AccountAuthenticator;
feePayerAuthenticator?: AccountAuthenticator;
additionalSignersAuthenticators?: Array<AccountAuthenticator>;
}
interface SingleKeySignerConstructorArgs {
privateKey: PrivateKey;
address?: AccountAddressInput;
}
interface SingleKeySignerGenerateArgs {
scheme?: SigningSchemeInput;
}
type SingleKeySignerFromDerivationPathArgs = SingleKeySignerGenerateArgs & {
path: string;
mnemonic: string;
};
interface VerifySingleKeySignatureArgs {
message: HexInput;
signature: AnySignature;
}
/**
* Signer implementation for the SingleKey authentication scheme.
* This extends a SingleKeyAccount by adding signing capabilities through a valid private key.
* Currently, the only supported signature schemes are Ed25519 and Secp256k1.
*
* Note: Generating a signer instance does not create the account on-chain.
*/
declare class SingleKeyAccount implements Account$1 {
/**
* Private key associated with the account
*/
readonly privateKey: PrivateKey;
readonly publicKey: AnyPublicKey;
readonly accountAddress: AccountAddress;
readonly signingScheme = SigningScheme.SingleKey;
constructor(args: SingleKeySignerConstructorArgs);
/**
* Derives an account from a randomly generated private key.
* Default generation is using an Ed25519 key
* @returns Account with the given signature scheme
*/
static generate(args?: SingleKeySignerGenerateArgs): SingleKeyAccount;
/**
* Derives an account with bip44 path and mnemonics,
* Default to using an Ed25519 signature scheme.
*
* @param args.scheme The signature scheme to derive the private key with
* @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
* or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
* @param args.mnemonic the mnemonic seed phrase of the account
*/
static fromDerivationPath(args: SingleKeySignerFromDerivationPathArgs): SingleKeyAccount;
/**
* Verify the given message and signature with the public key.
*
* @param args.message raw message data in HexInput format
* @param args.signature signed message Signature
* @returns
*/
verifySignature(args: VerifySingleKeySignatureArgs): boolean;
/**
* Sign a message using the account's private key.
* @param message the signing message, as binary input
* @return the AccountAuthenticator containing the signature, together with the account's public key
*/
signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey;
/**
* Sign a transaction using the account's private key.
* @param transaction the raw transaction
* @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
*/
signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey;
/**
* Sign the given message using the account's private key.
* @param message in HexInput format
* @returns Signature
*/
sign(message: HexInput): AnySignature;
/**
* Sign the given transaction using the account's private key.
* @param transaction the transaction to be signed
* @returns Signature
*/
signTransaction(transaction: AnyRawTransaction): AnySignature;
}
/**
* Arguments for creating an `Ed25519Account` from an `Ed25519PrivateKey`.
* This is the default input type when passing an `Ed25519PrivateKey`.
* In order to use the SingleKey authentication scheme, `legacy` needs to be explicitly set to false.
*/
interface CreateEd25519AccountFromPrivateKeyArgs {
privateKey: Ed25519PrivateKey;
address?: AccountAddressInput;
legacy?: true;
}
/**
* Arguments for creating an `SingleKeyAccount` from an `Ed25519PrivateKey`.
* The `legacy` argument needs to be explicitly set to false in order to
* use the `SingleKey` authentication scheme.
*/
interface CreateEd25519SingleKeyAccountFromPrivateKeyArgs {
privateKey: Ed25519PrivateKey;
address?: AccountAddressInput;
legacy: false;
}
/**
* Arguments for creating an `SingleKeyAccount` from any supported private key
* that is not an `Ed25519PrivateKey`.
* The `legacy` argument defaults to false and cannot be explicitly set to true.
*/
interface CreateSingleKeyAccountFromPrivateKeyArgs {
privateKey: Exclude<PrivateKey, Ed25519PrivateKey>;
address?: AccountAddressInput;
legacy?: false;
}
/**
* Arguments for creating an opaque `Account` from any supported private key.
* This is used when the private key type is not known at compilation time.
*/
interface CreateAccountFromPrivateKeyArgs {
privateKey: PrivateKey;
address?: AccountAddressInput;
legacy?: boolean;
}
/**
* Arguments for generating an `Ed25519Account`.
* This is the input type used by default.
*/
interface GenerateEd25519AccountArgs {
scheme?: SigningSchemeInput.Ed25519;
legacy?: true;
}
/**
* Arguments for generating an `SingleKeyAccount` with ah underlying `Ed25519PrivateKey`.
* The `legacy` argument needs to be explicitly set to false,
* otherwise an `Ed25519Account` will be returned instead.
*/
interface GenerateEd25519SingleKeyAccountArgs {
scheme?: SigningSchemeInput.Ed25519;
legacy: false;
}
/**
* Arguments for generating an `SingleKeyAccount` with any supported private key
* that is not an `Ed25519PrivateKey`.
* The `legacy` argument defaults to false and cannot be explicitly set to true.
*/
interface GenerateSingleKeyAccountArgs {
scheme: Exclude<SigningSchemeInput, SigningSchemeInput.Ed25519>;
legacy?: false;
}
/**
* Arguments for generating an opaque `Account`.
* This is used when the input signature scheme is not known at compilation time.
*/
interface GenerateAccountArgs {
scheme?: SigningSchemeInput;
legacy?: boolean;
}
/**
* Arguments for deriving a private key from a mnemonic phrase and a BIP44 path.
*/
interface PrivateKeyFromDerivationPathArgs {
path: string;
mnemonic: string;
}
/**
* Interface for a generic Aptos account.
*
* The interface is defined as abstract class to provide a single entrypoint for account generation,
* either through `Account.generate()` or `Account.fromDerivationPath`.
* Despite this being an abstract class, it should be treated as an interface and enforced using
* the `implements` keyword.
*
* Note: Generating an account instance does not create the account on-chain.
*/
declare abstract class Account$1 {
/**
* Public key associated with the account
*/
abstract readonly publicKey: AccountPublicKey;
/**
* Account address associated with the account
*/
abstract readonly accountAddress: AccountAddress;
/**
* Signing scheme used to sign transactions
*/
abstract signingScheme: SigningScheme;
/**
* Derives an account from a randomly generated private key.
* @param args.scheme The signature scheme to use, to generate the private key
* @param args.legacy Whether to use a legacy authentication scheme, when applicable
* @returns An account compatible with the provided signature scheme
*/
static generate(args?: GenerateEd25519AccountArgs): Ed25519Account;
static generate(args: GenerateEd25519SingleKeyAccountArgs): SingleKeyAccount;
static generate(args: GenerateSingleKeyAccountArgs): SingleKeyAccount;
static generate(args: GenerateAccountArgs): Account$1;
/**
* Creates an account from the provided private key.
*
* @param args.privateKey a valid private key
* @param args.address the account's address. If not provided, it will be derived from the public key.
* @param args.legacy Whether to use a legacy authentication scheme, when applicable
*/
static fromPrivateKey(args: CreateEd25519AccountFromPrivateKeyArgs): Ed25519Account;
static fromPrivateKey(args: CreateEd25519SingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;
static fromPrivateKey(args: CreateSingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;
static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs): Account$1;
/**
* @deprecated use `fromPrivateKey` instead.
* Instantiates an account given a private key and a specified account address.
* This is primarily used to instantiate an `Account` that has had its authentication key rotated.
*
* @param args.privateKey PrivateKey - the underlying private key for the account
* @param args.address AccountAddress - The account address the `Account` will sign for
* @param args.legacy optional. If set to false, the keypair generated is a Unified keypair. Defaults
* to generating a Legacy Ed25519 keypair
*
* @returns Account
*/
static fromPrivateKeyAndAddress(args: CreateAccountFromPrivateKeyArgs): Account$1;
/**
* Derives an account with bip44 path and mnemonics
*
* @param args.scheme The signature scheme to derive the private key with
* @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,
* or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
* @param args.mnemonic the mnemonic seed phrase of the account
*/
static fromDerivationPath(args: GenerateEd25519AccountArgs & PrivateKeyFromDerivationPathArgs): Ed25519Account;
static fromDerivationPath(args: GenerateEd25519SingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs): SingleKeyAccount;
static fromDerivationPath(args: GenerateSingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs): SingleKeyAccount;
static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs): Account$1;
/**
* @deprecated use `publicKey.authKey()` instead.
* This key enables account owners to rotate their private key(s)
* associated with the account without changing the address that hosts their account.
* See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}
*
* @param args.publicKey PublicKey - public key of the account
* @returns The authentication key for the associated account
*/
static authKey(args: {
publicKey: AccountPublicKey;
}): AuthenticationKey;
/**
* Sign a message using the available signing capabilities.
* @param message the signing message, as binary input
* @return the AccountAuthenticator containing the signature, together with the account's public key
*/
abstract signWithAuthenticator(message: HexInput): AccountAuthenticator;
/**
* Sign a transaction using the available signing capabilities.
* @param transaction the raw transaction
* @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
*/
abstract signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticator;
/**
* Sign the given message using the available signing capabilities.
* @param message in HexInput format
* @returns Signature
*/
abstract sign(message: HexInput): Signature;
/**
* Sign the given transaction using the available signing capabilities.
* @param transaction the transaction to be signed
* @returns Signature
*/
abstract signTransaction(transaction: AnyRawTransaction): Signature;
/**
* Verify the given message and signature with the public key.
* @param args.message raw message data in HexInput format
* @param args.signature signed message Signature
* @returns
*/
verifySignature(args: VerifySignatureArgs): boolean;
}
interface Ed25519SignerConstructorArgs {
privateKey: Ed25519PrivateKey;
address?: AccountAddressInput;
}
interface Ed25519SignerFromDerivationPathArgs {
path: string;
mnemonic: string;
}
interface VerifyEd25519SignatureArgs {
message: HexInput;
signature: Ed25519Signature;
}
/**
* Signer implementation for the Ed25519 authentication scheme.
* This extends an {@link Ed25519Account} by adding signing capabilities through an {@link Ed25519PrivateKey}.
*
* Note: Generating a signer instance does not create the account on-chain.
*/
declare class Ed25519Account implements Account$1 {
/**
* Private key associated with the account
*/
readonly privateKey: Ed25519PrivateKey;
readonly publicKey: Ed25519PublicKey;
readonly accountAddress: AccountAddress;
readonly signingScheme = SigningScheme.Ed25519;
constructor(args: Ed25519SignerConstructorArgs);
/**
* Derives a signer from a randomly generated private key
*/
static generate(): Ed25519Account;
/**
* Derives an account with bip44 path and mnemonics
*
* @param args.path the BIP44 derive hardened path e.g. m/44'/637'/0'/0'/0'
* Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}
* @param args.mnemonic the mnemonic seed phrase of the account
*/
static fromDerivationPath(args: Ed25519SignerFromDerivationPathArgs): Ed25519Account;
/**
* Verify the given message and signature with the public key.
*
* @param args.message raw message data in HexInput format
* @param args.signature signed message Signature
* @returns
*/
verifySignature(args: VerifyEd25519SignatureArgs): boolean;
/**
* Sign a message using the account's Ed25519 private key.
* @param message the signing message, as binary input
* @return the AccountAuthenticator containing the signature, together with the account's public key
*/
signWithAuthenticator(message: HexInput): AccountAuthenticatorEd25519;
/**
* Sign a transaction using the account's Ed25519 private key.
* @param transaction the raw transaction
* @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
*/
signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorEd25519;
/**
* Sign the given message using the account's Ed25519 private key.
* @param message in HexInput format
* @returns Signature
*/
sign(message: HexInput): Ed25519Signature;
/**
* Sign the given transaction using the available signing capabilities.
* @param transaction the transaction to be signed
* @returns Signature
*/
signTransaction(transaction: AnyRawTransaction): Ed25519Signature;
}
interface VerifyMultiKeySignatureArgs {
message: HexInput;
signature: MultiKeySignature;
}
/**
* Signer implementation for the MultiKey authentication scheme.
*
* This accounts to use a M of N signing scheme. M and N are specified in the {@link MultiKey}
* It signs messages via the array of M number of Accounts that individually correspond to a public key in the {@link MultiKey}.
*
* Note: Generating a signer instance does not create the account on-chain.
*/
declare class MultiKeyAccount implements Account$1 {
/**
* Public key associated with the account
*/
readonly publicKey: MultiKey;
/**
* Account address associated with the account
*/
readonly accountAddress: AccountAddress;
/**
* Signing scheme used to sign transactions
*/
readonly signingScheme: SigningScheme;
/**
* The signers used to sign messages. These signers should correspond to public keys in the
* MultiKeyAccount's public key. The number of signers should be equal or greater
* than this.publicKey.signaturesRequired
*/
readonly signers: Account$1[];
/**
* An array of indicies where for signer[i], signerIndicies[i] is the index of the corresponding public key in
* publicKey.publicKeys. Used to derive the right public key to use for verification.
*/
readonly signerIndicies: number[];
readonly signaturesBitmap: Uint8Array;
/**
* constructor for MultiKeyAccount
*
* @param args.multiKey the multikey of the account which consists of N public keys and a number M which is
* the number of required signatures.
* @param args.signers an array of M signers that will be used to sign the transaction
* @returns MultiKeyAccount
*/
constructor(args: {
multiKey: MultiKey;
signers: Account$1[];
});
/**
* Static constructor for MultiKeyAccount
*
* @param args.publicKeys the N public keys of the MultiKeyAccount
* @param args.signaturesRequired the number of signatures required
* @param args.signers an array of M signers that will be used to sign the transaction
* @returns MultiKeyAccount
*/
static fromPublicKeysAndSigners(args: {
publicKeys: PublicKey[];
signaturesRequired: number;
signers: Account$1[];
}): MultiKeyAccount;
static isMultiKeySigner(account: Account$1): account is MultiKeyAccount;
/**
* Sign a message using the account's signers.
* @param message the signing message, as binary input
* @return the AccountAuthenticator containing the signature, together with the account's public key
*/
signWithAuthenticator(message: HexInput): AccountAuthenticatorMultiKey;
/**
* Sign a transaction using the account's signers.
* @param transaction the raw transaction
* @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
*/
signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorMultiKey;
/**
* Sign the given message using the MultiKeyAccount's signers
* @param message in HexInput format
* @returns MultiKeySignature
*/
sign(data: HexInput): MultiKeySignature;
/**
* Sign the given transaction using the MultiKeyAccount's signers
* @param transaction the transaction to be signed
* @returns MultiKeySignature
*/
signTransaction(transaction: AnyRawTransaction): MultiKeySignature;
/**
* Verify the given message and signature with the public key.
*
* @param args.message raw message data in HexInput format
* @param args.signatures signed message MultiKeySignature
* @returns boolean
*/
verifySignature(args: VerifyMultiKeySignatureArgs): boolean;
}
/**
* A class to query all `Account` related queries on Aptos.
*/
declare class Account {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries the current state for an Aptos account given its account address
*
* @param args.accountAddress Aptos account address
*
* @returns The account data
*
* @example An example of the returned account
* ```
* {
* sequence_number: "1",
* authentication_key: "0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69"
* }
* ```
*/
getAccountInfo(args: {
accountAddress: AccountAddressInput;
}): Promise<AccountData>;
/**
* Queries for all modules in an account given an account address
*
* Note: In order to get all account modules, this function may call the API
* multiple times as it auto paginates.
*
* @param args.accountAddress Aptos account address
* @param args.options.offset The number module to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
*
* @returns Account modules
*/
getAccountModules(args: {
accountAddress: AccountAddressInput;
options?: PaginationArgs & LedgerVersionArg;
}): Promise<MoveModuleBytecode[]>;
/**
* Queries for a specific account module given account address and module name
*
* @param args.accountAddress Aptos account address
* @param args.moduleName The name of the module
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
*
* @returns Account module
*
* @example
* const module = await aptos.getAccountModule({accountAddress:"0x456"})
* // An example of an account module response
* ```
* {
* bytecode: "0xa11ceb0b0600000006010002030206050807070f0d081c200",
* abi: { address: "0x1" }
* }
* ```
*/
getAccountModule(args: {
accountAddress: AccountAddressInput;
moduleName: string;
options?: LedgerVersionArg;
}): Promise<MoveModuleBytecode>;
/**
* Queries account transactions given an account address
*
* Note: In order to get all account transactions, this function may call the API
* multiple times as it auto paginates.
*
* @example
* const transactions = await aptos.getAccountTransactions({accountAddress:"0x456"})
*
* @param args.accountAddress Aptos account address
* @param args.options.offset The number transaction to start returning results from
* @param args.options.limit The number of results to return
*
* @returns The account transactions
*/
getAccountTransactions(args: {
accountAddress: AccountAddressInput;
options?: PaginationArgs;
}): Promise<TransactionResponse[]>;
/**
* Queries all account resources given an account address
*
* Note: In order to get all account resources, this function may call the API
* multiple times as it auto paginates.
*
* @example
* const resources = await aptos.getAccountResources({accountAddress:"0x456"})
*
* @param args.accountAddress Aptos account address
* @param args.options.offset The number resource to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
* @returns Account resources
*/
getAccountResources(args: {
accountAddress: AccountAddressInput;
options?: PaginationArgs & LedgerVersionArg;
}): Promise<MoveResource[]>;
/**
* Queries a specific account resource given account address and resource type. Note that the default is `any` in order
* to allow for ease of accessing properties of the object.
*
* @type The typed output of the resource
* @param args.accountAddress Aptos account address
* @param args.resourceType String representation of an on-chain Move struct type, i.e "0x1::aptos_coin::AptosCoin"
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
*
* @returns Account resource
*
* @example
* const resource = await aptos.getAccountResource({accountAddress:"0x456"})
*
*/
getAccountResource<T extends {} = any>(args: {
accountAddress: AccountAddressInput;
resourceType: MoveStructId;
options?: LedgerVersionArg;
}): Promise<T>;
/**
* Looks up the account address for a given authentication key
*
* This handles both if the account's authentication key has been rotated or not.
*
* @example
* const accountAddress = await aptos.lookupOriginalAccountAddress({authenticationKey:account.accountAddress})
*
* @param args.authenticationKey The authentication key
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
* @returns Promise<AccountAddress> The accountAddress associated with the authentication key
*/
lookupOriginalAccountAddress(args: {
authenticationKey: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: LedgerVersionArg;
}): Promise<AccountAddress>;
/**
* Queries the current count of tokens owned by an account
*
* @example
* const tokensCount = await aptos.getAccountTokensCount({accountAddress:"0x456"})
*
* @param args.accountAddress The account address
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns Current count of tokens owned by the account
*/
getAccountTokensCount(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries the account's current owned tokens.
*
* This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.
* If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
*
* @example
* const accountOwnedTokens = await aptos.getAccountOwnedTokens({accountAddress:"0x456"})
*
* @param args.accountAddress The account address we want to get the tokens for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.tokenStandard The NFT standard to query for
* @param args.options.offset The number token to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.orderBy The order to sort the tokens by
* @returns Tokens array with the token data
*/
getAccountOwnedTokens(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensQueryResponse[0]>;
}): Promise<GetAccountOwnedTokensQueryResponse>;
/**
* Queries all current tokens of a specific collection that an account owns by the collection address
*
* This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.
* If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
*
* @example
* const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({accountAddress:"0x123", collectionAddress:"0x456"})
*
* @param args.accountAddress The account address we want to get the tokens for
* @param args.collectionAddress The address of the collection being queried
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.tokenStandard The NFT standard to query for
* @param args.options.offset The number token to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.orderBy The order to sort the tokens by
* @returns Tokens array with the token data
*/
getAccountOwnedTokensFromCollectionAddress(args: {
accountAddress: AccountAddressInput;
collectionAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensFromCollectionResponse[0]>;
}): Promise<GetAccountOwnedTokensFromCollectionResponse>;
/**
* Queries for all collections that an account currently has tokens for.
*
* This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.
* If you want to get only the token from a specific standard, you can pass an optional tokenStandard param
*
* @example
* const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the collections for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.tokenStandard The NFT standard to query for
* @param args.options.offset The number collection to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.orderBy The order to sort the tokens by
* @returns Collections array with the collections data
*/
getAccountCollectionsWithOwnedTokens(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountCollectionsWithOwnedTokenResponse[0]>;
}): Promise<GetAccountCollectionsWithOwnedTokenResponse>;
/**
* Queries the current count of transactions submitted by an account
*
* @example
* const accountTransactionsCount = await aptos.getAccountTransactionsCount({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the total count for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns Current count of transactions made by an account
*/
getAccountTransactionsCount(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries an account's coins data
*
* @example
* const accountCoinsData = await aptos.getAccountCoinsData({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the coins data for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.offset optional. The number coin to start returning results from
* @param args.options.limit optional. The number of results to return
* @param args.options.orderBy optional. The order to sort the coins by
* @param args.options.where optional. Filter the results by
* @returns Array with the coins data
*/
getAccountCoinsData(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetAccountCoinsDataResponse[0]> & WhereArg<CurrentFungibleAssetBalancesBoolExp>;
}): Promise<GetAccountCoinsDataResponse>;
/**
* Queries the current count of an account's coins aggregated
*
* @example
* const accountCoinsCount = await aptos.getAccountCoinsCount({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the total count for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns Current count of the aggregated count of all account's coins
*/
getAccountCoinsCount(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries the account's APT amount
*
* @example
* const accountAPTAmount = await aptos.getAccountAPTAmount({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the total count for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns Current amount of account's APT
*/
getAccountAPTAmount(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries the account's coin amount by the coin type
*
* @example
* const accountCoinAmount = await aptos.getAccountCoinAmount({accountAddress:"0x123", coinType:"0x1::aptos_coin::AptosCoin"})
*
* @param args.accountAddress The account address we want to get the total count for
* @param args.coinType The coin type to query
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns Current amount of account's coin
*/
getAccountCoinAmount(args: {
accountAddress: AccountAddressInput;
coinType: MoveStructId;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries an account's owned objects
*
* @example
* const accountOwnedObjects = await aptos.getAccountOwnedObjects({accountAddress:"0x123"})
*
* @param args.accountAddress The account address we want to get the objects for
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.offset The starting position to start returning results from
* @param args.options.limit The number of results to return
* @param args.options.orderBy The order to sort the objects by
* @returns Objects array with the object data
*/
getAccountOwnedObjects(args: {
accountAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetAccountOwnedObjectsResponse[0]>;
}): Promise<GetAccountOwnedObjectsResponse>;
/**
* Derives an account by providing a private key.
* This functions resolves the provided private key type and derives the public key from it.
*
* If the privateKey is a Secp256k1 type, it derives the account using the derived public key and
* auth key using the SingleKey scheme locally.
*
* If the privateKey is a ED25519 type, it looks up the authentication key on chain, and uses it to resolve
* whether it is a Legacy ED25519 key or a Unified ED25519 key. It then derives the account based
* on that.
*
* @example
* const account = await aptos.deriveAccountFromPrivateKey({privateKey:new Ed25519PrivateKey("0x123")})
*
* @param args.privateKey An account private key
* @returns Account type
*/
deriveAccountFromPrivateKey(args: {
privateKey: PrivateKey;
}): Promise<Account$1>;
}
/**
* A class to handle all `Coin` operations
*/
declare class Coin {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Generate a transfer coin transaction that can be simulated and/or signed and submitted
*
* @example
* const transferCoinTransaction = await aptos.transferCoinTransaction({
* sender: "0x123",
* recipient:"0x456",
* amount: 10,
* })
*
* @param args.sender The sender account
* @param args.recipient The recipient address
* @param args.amount The amount to transfer
* @param args.coinType optional. The coin struct type to transfer. Defaults to 0x1::aptos_coin::AptosCoin
*
* @returns SimpleTransaction
*/
transferCoinTransaction(args: {
sender: AccountAddressInput;
recipient: AccountAddressInput;
amount: AnyNumber;
coinType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
}
/**
* This file contains the underlying implementations for exposed API surface in
* the {@link api/digitalAsset}. By moving the methods out into a separate file,
* other namespaces and processes can access these methods without depending on the entire
* digitalAsset namespace and without having a dependency cycle error.
*/
declare const PropertyTypeMap: {
BOOLEAN: string;
U8: string;
U16: string;
U32: string;
U64: string;
U128: string;
U256: string;
ADDRESS: string;
STRING: string;
ARRAY: string;
};
type PropertyType = keyof typeof PropertyTypeMap;
type PropertyValue = boolean | number | bigint | string | AccountAddress | Uint8Array;
interface CreateCollectionOptions {
maxSupply?: AnyNumber;
mutableDescription?: boolean;
mutableRoyalty?: boolean;
mutableURI?: boolean;
mutableTokenDescription?: boolean;
mutableTokenName?: boolean;
mutableTokenProperties?: boolean;
mutableTokenURI?: boolean;
tokensBurnableByCreator?: boolean;
tokensFreezableByCreator?: boolean;
royaltyNumerator?: number;
royaltyDenominator?: number;
}
/**
* A class to query all `DigitalAsset` related queries on Aptos.
*/
declare class DigitalAsset {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries data of a specific collection by the collection creator address and the collection name.
*
* If, for some reason, a creator account has 2 collections with the same name in v1 and v2,
* can pass an optional `tokenStandard` parameter to query a specific standard
*
* @example
* const collection = await aptos.getCollectionData({creatorAddress:"0x123",collectionName:"myCollection"})
*
* @param args.creatorAddress the address of the collection's creator
* @param args.collectionName the name of the collection
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.tokenStandard the token standard to query
* @returns GetCollectionDataResponse response type
*/
getCollectionData(args: {
creatorAddress: AccountAddressInput;
collectionName: string;
minimumLedgerVersion?: AnyNumber;
options?: TokenStandardArg;
}): Promise<GetCollectionDataResponse>;
/**
* Queries data of a specific collection by the collection ID.
*
* @example
* const collection = await aptos.getCollectionDataByCollectionId({collectionId:"0x123"})
*
* @param args.collectionId the ID of the collection, it's the same thing as the address of the collection object
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns GetCollectionDataResponse response type
*/
getCollectionDataByCollectionId(args: {
collectionId: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetCollectionDataResponse>;
/**
* Queries a collection's ID.
*
* This is the same as the collection's object address in V2, but V1 does
* not use objects, and does not have an address
*
* @example
* const collection = await aptos.getCollectionId({creatorAddress:"0x123",collectionName:"myCollection"})
*
* @param args.creatorAddress the address of the collection's creator
* @param args.collectionName the name of the collection
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options.tokenStandard the token standard to query
* @returns the collection id
*/
getCollectionId(args: {
creatorAddress: AccountAddressInput;
collectionName: string;
minimumLedgerVersion?: AnyNumber;
options?: TokenStandardArg;
}): Promise<string>;
/**
* Gets digital asset data given the address of a digital asset.
*
* @example
* const digitalAsset = await aptos.getDigitalAssetData({digitalAssetAddress:"0x123"})
*
* @param args.tokenAddress The address of the digital asset
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns GetTokenDataResponse containing relevant data to the digital asset.
*/
getDigitalAssetData(args: {
digitalAssetAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetTokenDataResponse>;
/**
* Gets digital asset ownership data given the address of a digital asset.
*
* @example
* const digitalAssetOwner = await aptos.getCurrentDigitalAssetOwnership({digitalAssetAddress:"0x123"})
*
* @param args.tokenAddress The address of the digital asset
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns GetCurrentTokenOwnershipResponse containing relevant ownership data of the digital asset.
*/
getCurrentDigitalAssetOwnership(args: {
digitalAssetAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetCurrentTokenOwnershipResponse>;
/**
* Gets the digital assets that the given address owns.
*
* @example
* const digitalAssets = await aptos.getOwnedDigitalAssets({ownerAddress:"0x123"})
*
* @param args.ownerAddress The address of the owner
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns GetOwnedTokensResponse containing ownership data of the digital assets belonging to the ownerAddresss.
*/
getOwnedDigitalAssets(args: {
ownerAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetOwnedTokensResponse[0]>;
}): Promise<GetOwnedTokensResponse>;
/**
* Gets the activity data given the address of a digital asset.
*
* @example
* const digitalAssetActivity = await aptos.getDigitalAssetActivity({digitalAssetAddress:"0x123"})
*
* @param args.tokenAddress The address of the digital asset
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns GetTokenActivityResponse containing relevant activity data to the digital asset.
*/
getDigitalAssetActivity(args: {
digitalAssetAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetTokenActivityResponse[0]>;
}): Promise<GetTokenActivityResponse>;
/**
* Creates a new collection within the specified account
*
* @example
* const transaction = await aptos.createCollectionTransaction({
* creator: alice,
* description: "collectionDescription",
* name: "collectionName",
* uri: "collection-uri.com",
* });
*
* @param args.creator the account of the collection's creator
* @param args.description the description of the collection
* @param args.name the name of the collection
* @param args.uri the URI to additional info about the collection
*
* The parameters below are optional.
* @param args.maxSupply controls the max supply of the digital assets - defaults MAX_U64_BIG_INT
* @param args.mutableDescription controls mutability of the collection's description - defaults true
* @param args.mutableRoyalty controls mutability of the collection's description - defaults true
* @param args.mutableUri controls mutability of the collection's URI - defaults true
* @param args.mutableTokenDescription controls mutability of the digital asset's description - defaults true
* @param args.mutableTokenName controls mutability of the digital asset's name - defaults true
* @param args.mutableTokenProperties controls mutability of digital asset's properties - defaults true
* @param args.mutableTokenUri controls mutability of the digital asset's URI - defaults true
* @param args.tokensBurnableByCreator controls whether digital assets can be burnable by the creator - defaults true
* @param args.tokensFreezableByCreator controls whether digital assets can be frozen by the creator - defaults true
* @param args.royaltyNumerator the numerator of the royalty to be paid to the creator when
* a digital asset is transferred - defaults 0
* @param args.royaltyDenominator the denominator of the royalty to be paid to the creator
* when a digital asset is transferred - defaults 1
*
* @returns A SimpleTransaction that when submitted will create the collection.
*/
createCollectionTransaction(args: {
creator: Account$1;
description: string;
name: string;
uri: string;
options?: InputGenerateTransactionOptions;
} & CreateCollectionOptions): Promise<SimpleTransaction>;
/**
* Create a transaction to mint a digital asset into the creators account within an existing collection.
*
* @example
* const transaction = await aptos.mintDigitalAssetTransaction({
* creator: alice,
* description: "collectionDescription",
* collection: "collectionName",
* name: "digitalAssetName",
* uri: "digital-asset-uri.com",
* });
*
* @param args.creator the creator of the collection
* @param args.collection the name of the collection the digital asset belongs to
* @param args.description the description of the digital asset
* @param args.name the name of the digital asset
* @param args.uri the URI to additional info about the digital asset
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
mintDigitalAssetTransaction(args: {
creator: Account$1;
collection: string;
description: string;
name: string;
uri: string;
propertyKeys?: Array<string>;
propertyTypes?: Array<PropertyType>;
propertyValues?: Array<PropertyValue>;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Transfer a digital asset (non fungible digital asset) ownership.
*
* We can transfer a digital asset only when the digital asset is not frozen
* (i.e. owner transfer is not disabled such as for soul bound digital assets)
*
* @example
* const transaction = await aptos.transferDigitalAssetTransaction({
* sender: alice,
* digitalAssetAddress: "0x123",
* recipient: "0x456",
* });
*
* @param args.sender The sender account of the current digital asset owner
* @param args.digitalAssetAddress The digital asset address
* @param args.recipient The recipient account address
* @param args.digitalAssetType optional. The digital asset type, default to "0x4::token::Token"
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
transferDigitalAssetTransaction(args: {
sender: Account$1;
digitalAssetAddress: AccountAddressInput;
recipient: AccountAddress;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Mint a soul bound digital asset into a recipient's account
*
* @example
* const transaction = await aptos.mintSoulBoundTransaction({
* account: alice,
* collection: "collectionName",
* description: "collectionDescription",
* name: "digitalAssetName",
* uri: "digital-asset-uri.com",
* recipient: "0x123"
* });
*
* @param args.account The account that mints the digital asset
* @param args.collection The collection name that the digital asset belongs to
* @param args.description The digital asset description
* @param args.name The digital asset name
* @param args.uri The digital asset URL
* @param args.recipient The account address where the digital asset will be created
* @param args.propertyKeys The property keys for storing on-chain properties
* @param args.propertyTypes The type of property values
* @param args.propertyValues The property values to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
mintSoulBoundTransaction(args: {
account: Account$1;
collection: string;
description: string;
name: string;
uri: string;
recipient: AccountAddressInput;
propertyKeys?: Array<string>;
propertyTypes?: Array<PropertyType>;
propertyValues?: Array<PropertyValue>;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Burn a digital asset by its creator
*
* @example
* const transaction = await aptos.burnDigitalAssetTransaction({
* creator: alice,
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
burnDigitalAssetTransaction(args: {
creator: Account$1;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Freeze digital asset transfer ability
*
* @example
* const transaction = await aptos.freezeDigitalAssetTransaferTransaction({
* creator: alice,
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
freezeDigitalAssetTransaferTransaction(args: {
creator: Account$1;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Unfreeze digital asset transfer ability
*
* @example
* const transaction = await aptos.unfreezeDigitalAssetTransaferTransaction({
* creator: alice,
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
unfreezeDigitalAssetTransaferTransaction(args: {
creator: Account$1;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Set the digital asset description
*
* @example
* const transaction = await aptos.setDigitalAssetDescriptionTransaction({
* creator: alice,
* description: "digitalAssetDescription",
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.description The digital asset description
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
setDigitalAssetDescriptionTransaction(args: {
creator: Account$1;
description: string;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Set the digital asset name
*
* @example
* const transaction = await aptos.setDigitalAssetNameTransaction({
* creator: alice,
* name: "digitalAssetName",
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.name The digital asset name
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
setDigitalAssetNameTransaction(args: {
creator: Account$1;
name: string;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Set the digital asset name
*
* @example
* const transaction = await aptos.setDigitalAssetURITransaction({
* creator: alice,
* uri: "digital-asset-uri.com",
* digitalAssetAddress: "0x123",
* });
*
* @param args.creator The creator account
* @param args.uri The digital asset uri
* @param args.digitalAssetAddress The digital asset address
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
setDigitalAssetURITransaction(args: {
creator: Account$1;
uri: string;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Add a digital asset property
*
* @example
* const transaction = await aptos.addDigitalAssetPropertyTransaction({
* creator: alice,
* propertyKey: "newKey",
* propertyType: "BOOLEAN",
* propertyValue: true,
* digitalAssetAddress: "0x123",
* });
*
* @param args.account The account that mints the digital asset
* @param args.digitalAssetAddress The digital asset address
* @param args.propertyKey The property key for storing on-chain properties
* @param args.propertyType The type of property value
* @param args.propertyValue The property value to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
addDigitalAssetPropertyTransaction(args: {
creator: Account$1;
propertyKey: string;
propertyType: PropertyType;
propertyValue: PropertyValue;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Remove a digital asset property
*
* @example
* const transaction = await aptos.removeDigitalAssetPropertyTransaction({
* creator: alice,
* propertyKey: "newKey",
* propertyType: "BOOLEAN",
* propertyValue: true,
* digitalAssetAddress: "0x123",
* });
*
* @param args.account The account that mints the digital asset
* @param args.digitalAssetAddress The digital asset address
* @param args.propertyKey The property key for storing on-chain properties
* @param args.propertyType The type of property value
* @param args.propertyValue The property value to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
removeDigitalAssetPropertyTransaction(args: {
creator: Account$1;
propertyKey: string;
propertyType: PropertyType;
propertyValue: PropertyValue;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Update a digital asset property
*
* @example
* const transaction = await aptos.updateDigitalAssetPropertyTransaction({
* creator: alice,
* propertyKey: "newKey",
* propertyType: "BOOLEAN",
* propertyValue: false,
* digitalAssetAddress: "0x123",
* });
*
* @param args.account The account that mints the digital asset
* @param args.digitalAssetAddress The digital asset address
* @param args.propertyKey The property key for storing on-chain properties
* @param args.propertyType The type of property value
* @param args.propertyValue The property value to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
updateDigitalAssetPropertyTransaction(args: {
creator: Account$1;
propertyKey: string;
propertyType: PropertyType;
propertyValue: PropertyValue;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Add a typed digital asset property
*
* @example
* const transaction = await aptos.addDigitalAssetTypedPropertyTransaction({
* creator: alice,
* propertyKey: "typedKey",
* propertyType: "STRING",
* propertyValue: "hello",
* digitalAssetAddress: "0x123",
* });
*
* @param args.account The account that mints the digital asset
* @param args.digitalAssetAddress The digital asset address
* @param args.propertyKey The property key for storing on-chain properties
* @param args.propertyType The type of property value
* @param args.propertyValue The property value to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
addDigitalAssetTypedPropertyTransaction(args: {
creator: Account$1;
propertyKey: string;
propertyType: PropertyType;
propertyValue: PropertyValue;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Update a typed digital asset property
*
* @example
* const transaction = await aptos.updateDigitalAssetTypedPropertyTransaction({
* creator: alice,
* propertyKey: "typedKey",
* propertyType: "U8",
* propertyValue: 2,
* digitalAssetAddress: "0x123",
* });
*
* @param args.account The account that mints the digital asset
* @param args.digitalAssetAddress The digital asset address
* @param args.propertyKey The property key for storing on-chain properties
* @param args.propertyType The type of property value
* @param args.propertyValue The property value to be stored on-chain
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
updateDigitalAssetTypedPropertyTransaction(args: {
creator: Account$1;
propertyKey: string;
propertyType: PropertyType;
propertyValue: PropertyValue;
digitalAssetAddress: AccountAddressInput;
digitalAssetType?: MoveStructId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
}
/**
* A class to query all `Event` Aptos related queries
*/
declare class Event {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Get module events by event type
*
* @example
* const events = await aptos.getModuleEventsByEventType({eventType:"0x1::transaction_fee::FeeStatement"})
*
* @param args.eventType - The event type
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns Promise<GetEventsResponse>
*/
getModuleEventsByEventType(args: {
eventType: MoveStructId;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetEventsResponse[0]>;
}): Promise<GetEventsResponse>;
/**
* Get events by creation number and an account address
*
* @example
* const events = await aptos.getAccountEventsByCreationNumber({accountAddress:"0x123",creationNumber: 0})
*
* @param args.accountAddress - The account address
* @param args.creationNumber - The event creation number
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns Promise<GetEventsResponse>
*/
getAccountEventsByCreationNumber(args: {
accountAddress: AccountAddressInput;
creationNumber: AnyNumber;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetEventsResponse>;
/**
* Get events by event type and an account address
*
* @example
* const events = await aptos.getAccountEventsByEventType({accountAddress:"0x123",eventType: "0x1::transaction_fee::FeeStatement"})
*
* @param args.accountAddress - The account address
* @param args.eventType - The event type
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
*
* @returns Promise<GetEventsResponse>
*/
getAccountEventsByEventType(args: {
accountAddress: AccountAddressInput;
eventType: MoveStructId;
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetEventsResponse[0]>;
}): Promise<GetEventsResponse>;
/**
* Get all events
*
* An optional `where` can be passed in to filter out the response.
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @example
* const events = await aptos.getEvents()
* // with filtering
* const events = await aptos.getEvents({options: { where: { account_address: { _eq: "0x123" } } }});
*
* @returns GetEventsQuery response type
*/
getEvents(args?: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & OrderByArg<GetEventsResponse[0]> & WhereArg<EventsBoolExp>;
}): Promise<GetEventsResponse>;
}
/**
* A class to query all `Faucet` related queries on Aptos.
*/
declare class Faucet {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* This creates an account if it does not exist and mints the specified amount of
* coins into that account
*
* @example
* const transaction = await aptos.fundAccount({accountAddress:"0x123", amount: 100})
*
* @param args.accountAddress Address of the account to fund
* @param args.amount Amount of tokens to fund the account with
* @param args.options Configuration options for waitForTransaction
* @returns Transaction hash of the transaction that funded the account
*/
fundAccount(args: {
accountAddress: AccountAddressInput;
amount: number;
options?: WaitForTransactionOptions;
}): Promise<UserTransactionResponse>;
}
declare function isBool(arg: SimpleEntryFunctionArgumentTypes): arg is boolean;
declare function isString(arg: any): arg is string;
declare function isNumber(arg: SimpleEntryFunctionArgumentTypes): arg is number;
declare function isLargeNumber(arg: SimpleEntryFunctionArgumentTypes): arg is number | bigint | string;
declare function isNull(arg: SimpleEntryFunctionArgumentTypes): arg is null | undefined;
declare function isEncodedEntryFunctionArgument(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is EntryFunctionArgumentTypes;
declare function isBcsBool(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is Bool;
declare function isBcsAddress(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is AccountAddress;
declare function isBcsString(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is MoveString;
declare function isBcsFixedBytes(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is FixedBytes;
declare function isBcsU8(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U8;
declare function isBcsU16(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U16;
declare function isBcsU32(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U32;
declare function isBcsU64(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U64;
declare function isBcsU128(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U128;
declare function isBcsU256(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U256;
declare function isScriptDataInput(arg: InputGenerateTransactionPayloadDataWithRemoteABI | InputGenerateTransactionPayloadData): arg is InputScriptData;
declare function throwTypeMismatch(expectedType: string, position: number): void;
/**
* Finds first non-signer arg.
*
* A function is often defined with a `signer` or `&signer` arguments at the start, which are filled in
* by signatures, and not by the caller.
* @param functionAbi
*/
declare function findFirstNonSignerArg(functionAbi: MoveFunction): number;
declare function getFunctionParts(functionArg: MoveFunctionId): {
moduleAddress: string;
moduleName: string;
functionName: string;
};
/**
* We are defining function signatures, each with its specific input and output.
* These are the possible function signature for our `generateTransactionPayload` function.
* When we call our `generateTransactionPayload` function with the relevant type properties,
* Typescript can infer the return type based on the appropriate function overload.
*/
declare function generateTransactionPayload(args: InputScriptData): Promise<TransactionPayloadScript>;
declare function generateTransactionPayload(args: InputEntryFunctionDataWithRemoteABI): Promise<TransactionPayloadEntryFunction>;
declare function generateTransactionPayload(args: InputMultiSigDataWithRemoteABI): Promise<TransactionPayloadMultiSig>;
declare function generateTransactionPayloadWithABI(args: InputEntryFunctionDataWithABI): TransactionPayloadEntryFunction;
declare function generateTransactionPayloadWithABI(args: InputMultiSigDataWithABI): TransactionPayloadMultiSig;
declare function generateViewFunctionPayload(args: InputViewFunctionDataWithRemoteABI): Promise<EntryFunction>;
declare function generateViewFunctionPayloadWithABI(args: InputViewFunctionDataWithABI): EntryFunction;
/**
* Generates a raw transaction
*
* @param args.aptosConfig AptosConfig
* @param args.sender The transaction's sender account address as a hex input
* @param args.payload The transaction payload - can create by using generateTransactionPayload()
*
* @returns RawTransaction
*/
declare function generateRawTransaction(args: {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
payload: AnyTransactionPayloadInstance;
options?: InputGenerateTransactionOptions;
feePayerAddress?: AccountAddressInput;
}): Promise<RawTransaction>;
/**
* We are defining function signatures, each with its specific input and output.
* These are the possible function signature for our `generateTransaction` function.
* When we call our `generateTransaction` function with the relevant type properties,
* Typescript can infer the return type based on the appropriate function overload.
*/
declare function buildTransaction(args: InputGenerateSingleSignerRawTransactionArgs): Promise<SimpleTransaction>;
declare function buildTransaction(args: InputGenerateMultiAgentRawTransactionArgs): Promise<MultiAgentTransaction>;
/**
* Simulate a transaction before signing and submit to chain
*
* @param args.transaction A aptos transaction type to sign
* @param args.signerPublicKey The signer public key
* @param args.secondarySignersPublicKeys optional. The secondary signers public keys if multi signers transaction
* @param args.feePayerPublicKey optional. The fee payer public key is a fee payer (aka sponsored) transaction
* @param args.options optional. SimulateTransactionOptions
*
* @returns A signed serialized transaction that can be simulated
*/
declare function generateSignedTransactionForSimulation(args: InputSimulateTransactionData): Uint8Array;
declare function getAuthenticatorForSimulation(publicKey: PublicKey): AccountAuthenticatorEd25519 | AccountAuthenticatorSingleKey;
/**
* Prepare a transaction to be submitted to chain
*
* @param args.transaction A aptos transaction type
* @param args.senderAuthenticator The account authenticator of the transaction sender
* @param args.secondarySignerAuthenticators optional. For when the transaction is a multi signers transaction
*
* @returns A SignedTransaction
*/
declare function generateSignedTransaction(args: InputSubmitTransactionData): Uint8Array;
/**
* Hashes the set of values with a SHA-3 256 hash
* @param input array of UTF-8 strings or Uint8array byte arrays
*/
declare function hashValues(input: (Uint8Array | string)[]): Uint8Array;
/**
* Generates a user transaction hash for the given transaction payload. It must already have an authenticator
* @param args InputSubmitTransactionData
*/
declare function generateUserTransactionHash(args: InputSubmitTransactionData): string;
/**
* Convert type arguments to only type tags, allowing for string representations of type tags
*/
declare function standardizeTypeTags(typeArguments?: Array<TypeTag | string>): Array<TypeTag>;
/**
* Fetches a function ABI from the on-chain module ABI. It doesn't validate whether it's a view or entry function.
* @param moduleAddress
* @param moduleName
* @param functionName
* @param aptosConfig
*/
declare function fetchFunctionAbi(moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig): Promise<MoveFunction | undefined>;
/**
* Fetches the ABI for an entry function from the module
*
* @param moduleAddress
* @param moduleName
* @param functionName
* @param aptosConfig
*/
declare function fetchEntryFunctionAbi(moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig): Promise<EntryFunctionABI>;
/**
* Fetches the ABI for a view function from the module
*
* @param moduleAddress
* @param moduleName
* @param functionName
* @param aptosConfig
*/
declare function fetchViewFunctionAbi(moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig): Promise<ViewFunctionABI>;
/**
* Converts a non-BCS encoded argument into BCS encoded, if necessary
* @param functionName
* @param functionAbi
* @param arg
* @param position
*/
declare function convertArgument(functionName: string, functionAbi: FunctionABI, arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes, position: number, genericTypeParams: Array<TypeTag>): EntryFunctionArgumentTypes;
declare function checkOrConvertArgument(arg: SimpleEntryFunctionArgumentTypes | EntryFunctionArgumentTypes, param: TypeTag, position: number, genericTypeParams: Array<TypeTag>): EntryFunctionArgumentTypes;
/**
* Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction
*
* @param transaction A aptos transaction type
*
* @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction
*/
declare function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance;
/**
* Generates the 'signing message' form of a message to be signed.
*
* @param bytes The byte representation of the message to be signed and sent to the chain
* @param domainSeparator A domain separator that starts with 'APTOS::'
*
* @returns The Uint8Array of the signing message
*/
declare function generateSigningMessage(bytes: Uint8Array, domainSeparator: string): Uint8Array;
/**
* Generates the 'signing message' form of a serilizable value. It bcs serializes the value and uses the name of
* its constructor as the domain separator.
*
* @param serializable An object that has a bcs serialized form
*
* @returns The Uint8Array of the signing message
*/
declare function generateSigningMessageForSerializable(serializable: Serializable): Uint8Array;
/**
* Generates the 'signing message' form of a transaction. It derives the type of transaction and
* applies the appropriate domain separator based on if there is extra data such as a fee payer or
* secondary signers.
*
* @param transaction A transaction that is to be signed
*
* @returns The Uint8Array of the signing message
*/
declare function generateSigningMessageForTransaction(transaction: AnyRawTransaction): Uint8Array;
declare enum TypeTagParserErrorType {
InvalidTypeTag = "unknown type",
UnexpectedGenericType = "unexpected generic type",
UnexpectedTypeArgumentClose = "unexpected '>'",
UnexpectedWhitespaceCharacter = "unexpected whitespace character",
UnexpectedComma = "unexpected ','",
TypeArgumentCountMismatch = "type argument count doesn't match expected amount",
MissingTypeArgumentClose = "no matching '>' for '<'",
UnexpectedPrimitiveTypeArguments = "primitive types not expected to have type arguments",
UnexpectedVectorTypeArgumentCount = "vector type expected to have exactly one type argument",
UnexpectedStructFormat = "unexpected struct format, must be of the form 0xaddress::module_name::struct_name",
InvalidModuleNameCharacter = "module name must only contain alphanumeric or '_' characters",
InvalidStructNameCharacter = "struct name must only contain alphanumeric or '_' characters"
}
declare class TypeTagParserError extends Error {
constructor(typeTagStr: string, invalidReason: TypeTagParserErrorType);
}
/**
* All types are made of a few parts they're either:
* 1. A simple type e.g. u8
* 2. A standalone struct e.g. 0x1::account::Account
* 3. A nested struct e.g. 0x1::coin::Coin<0x1234::coin::MyCoin>
*
* There are a few more special cases that need to be handled, however.
* 1. Multiple generics e.g 0x1::pair::Pair<u8, u16>
* 2. Spacing in the generics e.g. 0x1::pair::Pair< u8 , u16>
* 3. Nested generics of different depths e.g. 0x1::pair::Pair<0x1::coin::Coin<0x1234::coin::MyCoin>, u8>
* 4. Generics for types in ABIs are filled in with placeholders e.g T1, T2, T3
*/
declare function parseTypeTag(typeStr: string, options?: {
allowGenerics?: boolean;
}): TypeTag;
/**
* A class to query all `FungibleAsset` related queries on Aptos.
*/
declare class FungibleAsset {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries all fungible asset metadata.
*
* @example
* const fungibleAsset = await aptos.getFungibleAssetMetadata()
*
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options Optional configuration for pagination and filtering
*
* @returns A list of fungible asset metadata
*/
getFungibleAssetMetadata(args?: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & WhereArg<FungibleAssetMetadataBoolExp>;
}): Promise<GetFungibleAssetMetadataResponse>;
/**
* Queries a fungible asset metadata
*
* This query returns the fungible asset metadata for a specific fungible asset.
*
* @example
* const fungibleAsset = await aptos.getFungibleAssetMetadataByAssetType({assetType:"0x123::test_coin::TestCoin"})
*
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.assetType The asset type of the fungible asset.
* e.g
* "0x1::aptos_coin::AptosCoin" for Aptos Coin
* "0xc2948283c2ce03aafbb294821de7ee684b06116bb378ab614fa2de07a99355a8" - address format if this is fungible asset
*
* @returns A fungible asset metadata item
*/
getFungibleAssetMetadataByAssetType(args: {
assetType: string;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetFungibleAssetMetadataResponse[0]>;
/**
* Queries all fungible asset activities
*
* @example
* const fungibleAssetActivities = await aptos.getFungibleAssetActivities()
*
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options Optional configuration for pagination and filtering
*
* @returns A list of fungible asset metadata
*/
getFungibleAssetActivities(args?: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & WhereArg<FungibleAssetActivitiesBoolExp>;
}): Promise<GetFungibleAssetActivitiesResponse>;
/**
* Queries all fungible asset balances
*
* @example
* const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances()
*
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @param args.options Optional configuration for pagination and filtering
*
* @returns A list of fungible asset metadata
*/
getCurrentFungibleAssetBalances(args?: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & WhereArg<CurrentFungibleAssetBalancesBoolExp>;
}): Promise<GetCurrentFungibleAssetBalancesResponse>;
/**
* Transfer `amount` of fungible asset from sender's primary store to recipient's primary store.
*
* Use this method to transfer any fungible asset including fungible token.
*
* @example
* const transaction = await aptos.transferFungibleAsset({
* sender: alice,
* fungibleAssetMetadataAddress: "0x123",
* recipient: "0x456",
* amount: 5
* })
*
* @param sender The sender account
* @param fungibleAssetMetadataAddress The fungible asset account address.
* For example if you’re transferring USDT this would be the USDT address
* @param recipient The recipient account address
* @param amount Number of assets to transfer
*
* @returns A SimpleTransaction that can be simulated or submitted to chain.
*/
transferFungibleAsset(args: {
sender: Account$1;
fungibleAssetMetadataAddress: AccountAddressInput;
recipient: AccountAddressInput;
amount: AnyNumber;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
}
/**
* A class to query all `General` Aptos related queries
*/
declare class General {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries for the Aptos ledger info
*
* @returns Aptos Ledger Info
*
* @example
* const ledgerInfo = await aptos.getLedgerInfo()
* // an example of the returned data
* ```
* {
* "chain_id": 4,
* "epoch": "8",
* "ledger_version": "714",
* "oldest_ledger_version": "0",
* "ledger_timestamp": "1694695496521775",
* "node_role": "validator",
* "oldest_block_height": "0",
* "block_height": "359",
* "git_hash": "c82193f36f4e185fed9f68c4ad21f6c6dd390c6e"
* }
* ```
*/
getLedgerInfo(): Promise<LedgerInfo>;
/**
* Queries for the chain id
*
* @example
* const chainId = await aptos.getChainId()
*
* @returns The chain id
*/
getChainId(): Promise<number>;
/**
* Queries for block by transaction version
*
* @example
* const block = await aptos.getBlockByVersion({ledgerVersion:5})
*
* @param args.ledgerVersion Ledger version to lookup block information for
* @param args.options.withTransactions If set to true, include all transactions in the block
*
* @returns Block information with optional transactions
*/
getBlockByVersion(args: {
ledgerVersion: AnyNumber;
options?: {
withTransactions?: boolean;
};
}): Promise<Block>;
/**
* Get block by block height
*
* @example
* const block = await aptos.getBlockByVersion({blockHeight:5})
*
* @param args.blockHeight Block height to lookup. Starts at 0
* @param args.options.withTransactions If set to true, include all transactions in the block
*
* @returns Block with optional transactions
*/
getBlockByHeight(args: {
blockHeight: AnyNumber;
options?: {
withTransactions?: boolean;
};
}): Promise<Block>;
/**
* Queries for a Move view function
* @param args.payload Payload for the view function
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
*
* @example
* const data = await aptos.view({
* payload: {
* function: "0x1::coin::balance",
* typeArguments: ["0x1::aptos_coin::AptosCoin"],
* functionArguments: [accountAddress],
* }
* })
*
* @returns an array of Move values
*/
view<T extends Array<MoveValue>>(args: {
payload: InputViewFunctionData;
options?: LedgerVersionArg;
}): Promise<T>;
/**
* Queries top user transactions
*
* @example
* const topUserTransactions = await aptos.getChainTopUserTransactions({limit:5})
*
* @param args.limit The number of transactions to return
* @returns GetChainTopUserTransactionsResponse
*/
getChainTopUserTransactions(args: {
limit: number;
}): Promise<GetChainTopUserTransactionsResponse>;
/**
* A generic function for retrieving data from Aptos Indexer.
* For more detailed queries specification see
* {@link https://cloud.hasura.io/public/graphiql?endpoint=https://api.mainnet.aptoslabs.com/v1/graphql}
*
* @example
* const topUserTransactions = await aptos.queryIndexer({
* query: `query MyQuery {
* ledger_infos {
* chain_id
* }}`;
* })
*
* @param args.query.query A GraphQL query
* @param args.query.variables The variables for the query
*
* @return The provided T type
*/
queryIndexer<T extends {}>(args: {
query: GraphqlQuery;
}): Promise<T>;
/**
* Queries for the last successful indexer version
*
* This is useful to tell what ledger version the indexer is updated to, as it can be behind the full nodes.
*
* @example
* const version = await aptos.getIndexerLastSuccessVersion()
*/
getIndexerLastSuccessVersion(): Promise<bigint>;
/**
* Query the processor status for a specific processor type.
*
* @example
* const status = await aptos.getProcessorStatus({processorType:"account_transactions_processor"})
*
* @param processorType The processor type to query
* @returns
*/
getProcessorStatus(processorType: ProcessorType): Promise<GetProcessorStatusResponse[0]>;
}
/**
* This file contains the underlying implementations for exposed API surface in
* the {@link api/name}. By moving the methods out into a separate file,
* other namespaces and processes can access these methods without depending on the entire
* name namespace and without having a dependency cycle error.
*/
interface RegisterNameParameters {
aptosConfig: AptosConfig;
sender: Account$1;
name: string;
expiration: {
policy: "domain";
years?: 1;
} | {
policy: "subdomain:follow-domain";
} | {
policy: "subdomain:independent";
expirationDate: number;
};
transferable?: boolean;
toAddress?: AccountAddressInput;
targetAddress?: AccountAddressInput;
options?: InputGenerateTransactionOptions;
}
interface QueryNamesOptions {
options?: PaginationArgs & OrderByArg<GetANSNameResponse[0]> & WhereArg<CurrentAptosNamesBoolExp>;
}
interface GetAccountNamesArgs extends QueryNamesOptions {
accountAddress: AccountAddressInput;
}
interface GetAccountDomainsArgs extends QueryNamesOptions {
accountAddress: AccountAddressInput;
}
interface GetAccountSubdomainsArgs extends QueryNamesOptions {
accountAddress: AccountAddressInput;
}
interface GetDomainSubdomainsArgs extends QueryNamesOptions {
domain: string;
}
/**
* A class to handle all `ANS` operations
*/
declare class ANS {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Retrieve the owner address of a domain name or subdomain name from the contract.
*
* @example
* // Will return the owner address of "test.aptos.apt" or undefined
* const owner = await aptos.getOwnerAddress({name: "test.aptos"})
* // owner = 0x123...
*
* @param args.name - A string of the name to retrieve
*
* @returns AccountAddress if the name is owned, undefined otherwise
*/
getOwnerAddress(args: {
name: string;
}): Promise<AccountAddress | undefined>;
/**
* Retrieve the expiration time of a domain name or subdomain name from the contract.
*
* @example
* // Will return the expiration of "test.aptos.apt" or undefined
* const exp = await aptos.getExpiration({name: "test.aptos"})
* // new Date(exp) would give you the date in question: 2021-01-01T00:00:00.000Z
*
* @param args.name - A string of the name to retrieve
*
* @returns number as a unix timestamp in milliseconds.
*/
getExpiration(args: {
name: string;
}): Promise<number | undefined>;
/**
* Retrieve the target address of a domain or subdomain name. This is the
* address the name points to for use on chain. Note, the target address can
* point to addresses that are not the owner of the name
*
* @example
* const targetAddr = await aptos.getTargetAddress({name: "test.aptos"})
* // targetAddr = 0x123...
*
* @param args.name - A string of the name: primary, primary.apt, secondary.primary, secondary.primary.apt, etc.
*
* @returns AccountAddress if the name has a target, undefined otherwise
*/
getTargetAddress(args: {
name: string;
}): Promise<AccountAddress | undefined>;
/**
* Sets the target address of a domain or subdomain name. This is the
* address the name points to for use on chain. Note, the target address can
* point to addresses that are not the owner of the name
*
* @example
* await aptos.setTargetAddress({sender: alice, name: "test.aptos", address: bob.accountAddress})
* const address = await aptos.getTargetAddress({name: "test.aptos"})
* // address = bob.accountAddress
*
* @param args.name - A string of the name: test.aptos.apt, test.apt, test, test.aptos, etc.
* @param args.address - A AccountAddressInput of the address to set the domain or subdomain to
*
* @returns SimpleTransaction
*/
setTargetAddress(args: {
sender: Account$1;
name: string;
address: AccountAddressInput;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Retrieve the primary name for an account. An account can have
* multiple names that target it, but only a single name that is primary. An
* account also may not have a primary name.
*
* @example
* const name = await aptos.getPrimaryName({address: alice.accountAddress})
* // name = test.aptos
*
* @param args.address - A AccountAddressInput (address) of the account
*
* @returns a string if the account has a primary name, undefined otherwise
*/
getPrimaryName(args: {
address: AccountAddressInput;
}): Promise<string | undefined>;
/**
* Sets the primary name for the sender. An account can have
* multiple names that target it, but only a single name that is primary. An
* account also may not have a primary name.
*
* @example
* await aptos.setPrimaryName({sender: alice, name: "test.aptos"})
* const primaryName = await aptos.getPrimaryName({address: alice.accountAddress})
* // primaryName = test.aptos
*
* @param args.sender - The sender account
* @param args.name - A string of the name: test, test.apt, test.aptos, test.aptos.apt, etc.
*
* @returns SimpleTransaction
*/
setPrimaryName(args: {
sender: Account$1;
name?: string;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Registers a new name
*
* @example
* // An example of registering a subdomain name assuming def.apt is already registered
* // and belongs to the sender alice.
* const txn = aptos.registerName({
* sender: alice,
* name: "test.aptos.apt",
* expiration: {
* policy: "subdomain:independent",
* expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000,
* },
* });
*
* @param args.sender - The sender account
* @param args.name - A string of the name to register. This can be inclusive or exclusive of the .apt suffix.
* Examples include: "test", "test.apt", "test.aptos.apt", etc.
* @param args.expiration - An object with the expiration policy of the name.
* @param args.expiration.policy - 'domain' | 'subdomain:follow-domain' | 'subdomain:independent'
* - domain: Years is required and the name will expire after the given number of years.
* - subdomain:follow-domain: The name will expire at the same time as the domain name.
* - subdomain:independent: The name will expire at the given date.
* @param args.expiration.expirationDate - An epoch number in milliseconds of
* the date when the subdomain will expire. Only applicable when the policy is
* set to 'subdomain:independent'.
* @param args.transferable - Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.
* @param args.targetAddress optional - The address the domain name will resolve to. If not provided,
* the sender's address will be used.
* @param args.toAddress optional - The address to send the domain name to. If not provided,
* the transaction will be sent to the router.
*
* @returns SimpleTransaction
*/
registerName(args: Omit<RegisterNameParameters, "aptosConfig">): Promise<SimpleTransaction>;
/**
* Renews a domain name
*
* Note: If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.
*
* @example
* await aptos.renewDomain({sender: alice, name: "test"})
* // test.apt will be renewed for one year
*
* @param args.sender - The sender account
* @param args.name - A string of the domain the subdomain will be under. The signer must be the domain owner.
* Subdomains cannot be renewed.
* @param args.years - The number of years to renew the name. Currently only one year is permitted.
*
* @returns SimpleTransaction
*/
renewDomain(args: {
sender: Account$1;
name: string;
years?: 1;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Fetches a single name from the indexer
* @param args.name - A string of the name to retrieve, e.g. "test.aptos.apt"
* or "test.apt" or "test". Can be inclusive or exclusive of the .apt suffix.
* Can be a subdomain.
*
* @returns A promise of an ANSName or undefined
*/
getName(args: {
name: string;
}): Promise<GetANSNameResponse[0] | undefined>;
/**
* Fetches all names for an account (both top level domains and subdomains)
*
* @param args
* @param args.accountAddress - A AccountAddressInput of the address to retrieve names for.
* @param args.options.offset - Optional, the offset to start from when fetching names
* @param args.options.limit - Optional, A number of the names to fetch per request
* @param args.options.orderBy - The order to sort the names by
* @param args.options.where - Additional filters to apply to the query
*
* @returns a promise of an array of ANSName
*/
getAccountNames(args: GetAccountNamesArgs): Promise<GetANSNameResponse>;
/**
* Fetches all top level domain names for an account
*
* @param args
* @param args.accountAddress - A AccountAddressInput of the address to retrieve domain names for.
* @param args.options.offset - Optional, the offset to start from when fetching names
* @param args.options.limit - Optional, A number of the names to fetch per request
* @param args.options.orderBy - The order to sort the names by
* @param args.options.where - Additional filters to apply to the query
*
* @returns a promise of an array of ANSName
*/
getAccountDomains(args: GetAccountDomainsArgs): Promise<GetANSNameResponse>;
/**
* Fetches all subdomains names for an account
*
* @param args
* @param args.accountAddress - A AccountAddressInput of the address to retrieve subdomains names for.
* @param args.options.offset - Optional, the offset to start from when fetching names
* @param args.options.limit - Optional, A number of the names to fetch per request
* @param args.options.orderBy - The order to sort the names by
* @param args.options.where - Additional filters to apply to the query
*
* @returns a promise of an array of ANSName
*/
getAccountSubdomains(args: GetAccountSubdomainsArgs): Promise<GetANSNameResponse>;
/**
* Fetches all subdomains names for a given domain. Note, this will not return the domain itself.
*
* @param args
* @param args.domain - A string of the domain name: eg. "test.apt" or "test" (without the suffix of .apt)
* @param args.options.offset - Optional, the offset to start from when fetching names
* @param args.options.limit - Optional, A number of the names to fetch per request
* @param args.options.orderBy - The order to sort the names by
* @param args.options.where - Additional filters to apply to the query
*
* @returns a promise of an array of ANSName
*/
getDomainSubdomains(args: GetDomainSubdomainsArgs): Promise<GetANSNameResponse>;
}
/**
* A class to query all `Staking` related queries on Aptos.
*/
declare class Staking {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries current number of delegators in a pool. Throws an error if the pool is not found.
*
* @example
* const delegators = await aptos.getNumberOfDelegators({poolAddress:"0x123"})
*
* @param args.poolAddress Pool address
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns The number of delegators for the given pool
*/
getNumberOfDelegators(args: {
poolAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<number>;
/**
* Queries current number of delegators in a pool. Throws an error if the pool is not found.
*
* @example
* const delegators = await aptos.getNumberOfDelegatorsForAllPools()
*
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns GetNumberOfDelegatorsForAllPoolsResponse response type
*/
getNumberOfDelegatorsForAllPools(args?: {
minimumLedgerVersion?: AnyNumber;
options?: OrderByArg<GetNumberOfDelegatorsResponse[0]>;
}): Promise<GetNumberOfDelegatorsResponse>;
/**
* Queries delegated staking activities
*
* @example
* const delegators = await aptos.getDelegatedStakingActivities({delegatorAddress:"0x123",poolAddress:"0x456"})
*
* @param args.delegatorAddress Delegator address
* @param args.poolAddress Pool address
* @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying
* @returns GetDelegatedStakingActivitiesResponse response type
*/
getDelegatedStakingActivities(args: {
delegatorAddress: AccountAddressInput;
poolAddress: AccountAddressInput;
minimumLedgerVersion?: AnyNumber;
}): Promise<GetDelegatedStakingActivitiesResponse>;
}
/**
* A class to handle all `Build` transaction operations
*/
declare class Build {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Build a simple transaction
*
* @param args.sender The sender account address
* @param args.data The transaction data
* @param args.options optional. Optional transaction configurations
* @param args.withFeePayer optional. Whether there is a fee payer for the transaction
*
* @returns SimpleTransaction
*/
simple(args: {
sender: AccountAddressInput;
data: InputGenerateTransactionPayloadData;
options?: InputGenerateTransactionOptions;
withFeePayer?: boolean;
}): Promise<SimpleTransaction>;
/**
* Build a multi agent transaction
*
* @param args.sender The sender account address
* @param args.data The transaction data
* @param args.secondarySignerAddresses An array of the secondary signers account addresses
* @param args.options optional. Optional transaction configurations
* @param args.withFeePayer optional. Whether there is a fee payer for the transaction
*
* @returns MultiAgentTransaction
*/
multiAgent(args: {
sender: AccountAddressInput;
data: InputGenerateTransactionPayloadData;
secondarySignerAddresses: AccountAddressInput[];
options?: InputGenerateTransactionOptions;
withFeePayer?: boolean;
}): Promise<MultiAgentTransaction>;
}
/**
* A class to handle all `Simulate` transaction operations
*/
declare class Simulate {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Simulate a simple transaction
*
* @param args.signerPublicKey The signer public key
* @param args.transaction An instance of a raw transaction
* @param args.options optional. Optional transaction configurations
* @param args.feePayerPublicKey optional. The fee payer public key if it is a fee payer transaction
*
* @returns Array<UserTransactionResponse>
*/
simple(args: {
signerPublicKey: PublicKey;
transaction: AnyRawTransaction;
feePayerPublicKey?: PublicKey;
options?: InputSimulateTransactionOptions;
}): Promise<Array<UserTransactionResponse>>;
/**
* Simulate a multi agent transaction
*
* @param args.signerPublicKey The signer public key
* @param args.transaction An instance of a raw transaction
* @param args.secondarySignersPublicKeys An array of the secondary signers public keys
* @param args.options optional. Optional transaction configurations
* @param args.feePayerPublicKey optional. The fee payer public key if it is a fee payer transaction
*
* @returns Array<UserTransactionResponse>
*/
multiAgent(args: {
signerPublicKey: PublicKey;
transaction: AnyRawTransaction;
secondarySignersPublicKeys: Array<PublicKey>;
feePayerPublicKey?: PublicKey;
options?: InputSimulateTransactionOptions;
}): Promise<Array<UserTransactionResponse>>;
}
/**
* A class to handle all `Submit` transaction operations
*/
declare class Submit {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Submit a simple transaction
*
* @param args.transaction An instance of a raw transaction
* @param args.senderAuthenticator optional. The sender account authenticator
* @param args.feePayerAuthenticator optional. The fee payer account authenticator if it is a fee payer transaction
*
* @returns PendingTransactionResponse
*/
simple(args: {
transaction: AnyRawTransaction;
senderAuthenticator: AccountAuthenticator;
feePayerAuthenticator?: AccountAuthenticator;
}): Promise<PendingTransactionResponse>;
/**
* Submit a multi agent transaction
*
* @param args.transaction An instance of a raw transaction
* @param args.senderAuthenticator optional. The sender account authenticator
* @param args.additionalSignersAuthenticators An array of the secondary signers account authenticators
* @param args.feePayerAuthenticator optional. The fee payer account authenticator if it is a fee payer transaction
*
* @returns PendingTransactionResponse
*/
multiAgent(args: {
transaction: AnyRawTransaction;
senderAuthenticator: AccountAuthenticator;
additionalSignersAuthenticators: Array<AccountAuthenticator>;
feePayerAuthenticator?: AccountAuthenticator;
}): Promise<PendingTransactionResponse>;
}
/**
* A wrapper that handles and manages an account sequence number.
*
* Submit up to `maximumInFlight` transactions per account in parallel with a timeout of `sleepTime`
* If local assumes `maximumInFlight` are in flight, determine the actual committed state from the network
* If there are less than `maximumInFlight` due to some being committed, adjust the window
* If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating
* If ever waiting more than `maxWaitTime` restart the sequence number to the current on-chain state
*
* Assumptions:
* Accounts are expected to be managed by a single AccountSequenceNumber and not used otherwise.
* They are initialized to the current on-chain state, so if there are already transactions in
* flight, they may take some time to reset.
* Accounts are automatically initialized if not explicitly
*
* Notes:
* This is co-routine safe, that is many async tasks can be reading from this concurrently.
* The state of an account cannot be used across multiple AccountSequenceNumber services.
* The synchronize method will create a barrier that prevents additional nextSequenceNumber
* calls until it is complete.
* This only manages the distribution of sequence numbers it does not help handle transaction
* failures.
* If a transaction fails, you should call synchronize and wait for timeouts.
*/
declare class AccountSequenceNumber {
readonly aptosConfig: AptosConfig;
readonly account: Account$1;
lastUncommintedNumber: bigint | null;
currentNumber: bigint | null;
/**
* We want to guarantee that we preserve ordering of workers to requests.
*
* `lock` is used to try to prevent multiple coroutines from accessing a shared resource at the same time,
* which can result in race conditions and data inconsistency.
* This code actually doesn't do it though, since we aren't giving out a slot, it is still somewhat a race condition.
*
* The ideal solution is likely that each thread grabs the next number from a incremental integer.
* When they complete, they increment that number and that entity is able to enter the `lock`.
* That would guarantee ordering.
*/
lock: boolean;
maxWaitTime: number;
maximumInFlight: number;
sleepTime: number;
constructor(aptosConfig: AptosConfig, account: Account$1, maxWaitTime: number, maximumInFlight: number, sleepTime: number);
/**
* Returns the next available sequence number for this account
*
* @returns next available sequence number
*/
nextSequenceNumber(): Promise<bigint | null>;
/**
* Initializes this account with the sequence number on chain
*/
initialize(): Promise<void>;
/**
* Updates this account sequence number with the one on-chain
*
* @returns on-chain sequence number for this account
*/
update(): Promise<bigint>;
/**
* Synchronizes local sequence number with the seqeunce number on chain for this account.
*
* Poll the network until all submitted transactions have either been committed or until
* the maximum wait time has elapsed
*/
synchronize(): Promise<void>;
}
/**
* The AsyncQueue class is an async-aware data structure that provides a queue-like
* behavior for managing asynchronous tasks or operations.
* It allows to enqueue items and dequeue them asynchronously.
* This is not thread-safe but it is async concurrency safe and
* it does not guarantee ordering for those that call into and await on enqueue.
*/
declare class AsyncQueue<T> {
readonly queue: T[];
private pendingDequeue;
private cancelled;
/**
* The enqueue method adds an item to the queue. If there are pending dequeued promises,
* in the pendingDequeue, it resolves the oldest promise with the enqueued item immediately.
* Otherwise, it adds the item to the queue.
*
* @param item T
*/
enqueue(item: T): void;
/**
* The dequeue method returns a promise that resolves to the next item in the queue.
* If the queue is not empty, it resolves the promise immediately with the next item.
* Otherwise, it creates a new promise. The promise's resolve function is stored
* in the pendingDequeue with a unique counter value as the key.
* The newly created promise is then returned, and it will be resolved later when an item is enqueued.
*
* @returns Promise<T>
*/
dequeue(): Promise<T>;
/**
* The isEmpty method returns whether the queue is empty or not.
*
* @returns boolean
*/
isEmpty(): boolean;
/**
* The cancel method cancels all pending promises in the queue.
* It rejects the promises with a AsyncQueueCancelledError error,
* ensuring that any awaiting code can handle the cancellation appropriately.
*/
cancel(): void;
/**
* The isCancelled method returns whether the queue is cancelled or not.
*
* @returns boolean
*/
isCancelled(): boolean;
/**
* The pendingDequeueLength method returns the length of the pendingDequeue.
*
* @returns number
*/
pendingDequeueLength(): number;
}
declare const promiseFulfilledStatus = "fulfilled";
declare enum TransactionWorkerEventsEnum {
TransactionSent = "transactionSent",
TransactionSendFailed = "transactionSendFailed",
TransactionExecuted = "transactionExecuted",
TransactionExecutionFailed = "transactionExecutionFailed",
ExecutionFinish = "executionFinish"
}
interface TransactionWorkerEvents {
transactionSent: (data: SuccessEventData) => void;
transactionSendFailed: (data: FailureEventData) => void;
transactionExecuted: (data: SuccessEventData) => void;
transactionExecutionFailed: (data: FailureEventData) => void;
executionFinish: (data: ExecutionFinishEventData) => void;
}
type ExecutionFinishEventData = {
message: string;
};
type SuccessEventData = {
message: string;
transactionHash: string;
};
type FailureEventData = {
message: string;
error: string;
};
/**
* TransactionWorker provides a simple framework for receiving payloads to be processed.
*
* Once one `start()` the process and pushes a new transaction, the worker acquires
* the current account's next sequence number (by using the AccountSequenceNumber class),
* generates a signed transaction and pushes an async submission process into the `outstandingTransactions` queue.
* At the same time, the worker processes transactions by reading the `outstandingTransactions` queue
* and submits the next transaction to chain, it
* 1) waits for resolution of the submission process or get pre-execution validation error
* and 2) waits for the resolution of the execution process or get an execution error.
* The worker fires events for any submission and/or execution success and/or failure.
*/
declare class TransactionWorker extends EventEmitter<TransactionWorkerEvents> {
readonly aptosConfig: AptosConfig;
readonly account: Account$1;
readonly accountSequnceNumber: AccountSequenceNumber;
readonly taskQueue: AsyncQueue<() => Promise<void>>;
started: boolean;
/**
* transactions payloads waiting to be generated and signed
*
* TODO support entry function payload from ABI builder
*/
transactionsQueue: AsyncQueue<[InputGenerateTransactionPayloadData, InputGenerateTransactionOptions | undefined]>;
/**
* signed transactions waiting to be submitted
*/
outstandingTransactions: AsyncQueue<[Promise<PendingTransactionResponse>, bigint]>;
/**
* transactions that have been submitted to chain
*/
sentTransactions: Array<[string, bigint, any]>;
/**
* transactions that have been committed to chain
*/
executedTransactions: Array<[string, bigint, any]>;
/**
* Provides a simple framework for receiving payloads to be processed.
*
* @param aptosConfig - a config object
* @param sender - a sender as Account
* @param maxWaitTime - the max wait time to wait before resyncing the sequence number
* to the current on-chain state, default to 30
* @param maximumInFlight - submit up to `maximumInFlight` transactions per account.
* Mempool limits the number of transactions per account to 100, hence why we default to 100.
* @param sleepTime - If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating, default to 10
*/
constructor(aptosConfig: AptosConfig, account: Account$1, maxWaitTime?: number, maximumInFlight?: number, sleepTime?: number);
/**
* Gets the current account sequence number,
* generates the transaction with the account sequence number,
* adds the transaction to the outstanding transaction queue
* to be processed later.
*/
submitNextTransaction(): Promise<void>;
/**
* Reads the outstanding transaction queue and submits the transaction to chain.
*
* If the transaction has fulfilled, it pushes the transaction to the processed
* transactions queue and fires a transactionsFulfilled event.
*
* If the transaction has failed, it pushes the transaction to the processed
* transactions queue with the failure reason and fires a transactionsFailed event.
*/
processTransactions(): Promise<void>;
/**
* Once transaction has been sent to chain, we check for its execution status.
* @param sentTransaction transactions that were sent to chain and are now waiting to be executed
* @param sequenceNumber the account's sequence number that was sent with the transaction
*/
checkTransaction(sentTransaction: PromiseFulfilledResult<PendingTransactionResponse>, sequenceNumber: bigint): Promise<void>;
/**
* Push transaction to the transactions queue
*
* @param transactionData Transaction payload
* @param transactionData.abi For all entry function payloads, the ABI to skip remote ABI lookups
* @param options.maxGasAmount Maximum gas amount for the transaction
* @param options.gasUnitPrice Gas unit price for the transaction
* @param options.expireTimestamp expiration timestamp on the transaction
* @param options.accountSequenceNumber the sequence number for the transaction
*/
push(transactionData: InputGenerateTransactionPayloadData, options?: InputGenerateTransactionOptions): Promise<void>;
/**
* Generates a signed transaction that can be submitted to chain
* @param account an Aptos account
* @param sequenceNumber a sequence number the transaction will be generated with
* @returns
*/
generateNextTransaction(account: Account$1, sequenceNumber: bigint): Promise<SimpleTransaction | undefined>;
/**
* Starts transaction submission and transaction processing.
*/
run(): Promise<void>;
/**
* Starts the transaction management process.
*/
start(): void;
/**
* Stops the the transaction management process.
*/
stop(): void;
}
declare class TransactionManagement extends EventEmitter<TransactionWorkerEvents> {
account: Account$1;
transactionWorker: TransactionWorker;
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Internal function to start the transaction worker and
* listen to worker events
*
* @param args.sender The sender account to sign and submit the transaction
*/
private start;
/**
* Internal function to push transaction data to the transaction worker.
*
* @param args.data An array of transaction payloads
* @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)
*
* TODO - make this public once worker supports adding transactions to existing queue
*/
private push;
/**
* Internal function to start listening to transaction worker events
*
* TODO - should we ask events to listen to as an input?
*/
private registerToEvents;
/**
* Send batch transactions for a single account.
*
* This function uses a transaction worker that receives payloads to be processed
* and submitted to chain.
* Note that this process is best for submitting multiple transactions that
* dont rely on each other, i.e batch funds, batch token mints, etc.
*
* If any worker failure, the functions throws an error.
*
* @param args.sender The sender account to sign and submit the transaction
* @param args.data An array of transaction payloads
* @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)
*
* @return void. Throws if any error
*/
forSingleAccount(args: {
sender: Account$1;
data: InputGenerateTransactionPayloadData[];
options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">;
}): void;
}
declare class Transaction {
readonly config: AptosConfig;
readonly build: Build;
readonly simulate: Simulate;
readonly submit: Submit;
readonly batch: TransactionManagement;
constructor(config: AptosConfig);
/**
* Queries on-chain transactions. This function will not return pending
* transactions. For that, use `getTransactionsByHash`.
*
* @example
* const transactions = await aptos.getTransactions()
*
* @param args.options.offset The number transaction to start with
* @param args.options.limit Number of results to return
*
* @returns Array of on-chain transactions
*/
getTransactions(args?: {
options?: PaginationArgs;
}): Promise<TransactionResponse[]>;
/**
* Queries on-chain transaction by version. This function will not return pending transactions.
*
* @example
* const transaction = await aptos.getTransactions({ledgerVersion:1})
*
* @param args.ledgerVersion - Transaction version is an unsigned 64-bit number.
* @returns On-chain transaction. Only on-chain transactions have versions, so this
* function cannot be used to query pending transactions.
*/
getTransactionByVersion(args: {
ledgerVersion: AnyNumber;
}): Promise<TransactionResponse>;
/**
* Queries on-chain transaction by transaction hash. This function will return pending transactions.
*
* @example
* const transaction = await aptos.getTransactionByHash({transactionHash:"0x123"})
*
* @param args.transactionHash - Transaction hash should be hex-encoded bytes string with 0x prefix.
* @returns Transaction from mempool (pending) or on-chain (committed) transaction
*/
getTransactionByHash(args: {
transactionHash: HexInput;
}): Promise<TransactionResponse>;
/**
* Defines if specified transaction is currently in pending state
*
* To create a transaction hash:
*
* 1. Create a hash message from the bytes: "Aptos::Transaction" bytes + the BCS-serialized Transaction bytes.
* 2. Apply hash algorithm SHA3-256 to the hash message bytes.
* 3. Hex-encode the hash bytes with 0x prefix.
*
* @example
* const isPendingTransaction = await aptos.isPendingTransaction({transactionHash:"0x123"})
*
* @param args.transactionHash A hash of transaction
* @returns `true` if transaction is in pending state and `false` otherwise
*/
isPendingTransaction(args: {
transactionHash: HexInput;
}): Promise<boolean>;
/**
* Waits for a transaction to move past the pending state.
*
* There are 4 cases.
* 1. Transaction is successfully processed and committed to the chain.
* - The function will resolve with the transaction response from the API.
* 2. Transaction is rejected for some reason, and is therefore not committed to the blockchain.
* - The function will throw an AptosApiError with an HTTP status code indicating some problem with the request.
* 3. Transaction is committed but execution failed, meaning no changes were
* written to the blockchain state.
* - If `checkSuccess` is true, the function will throw a FailedTransactionError
* If `checkSuccess` is false, the function will resolve with the transaction response where the `success` field is false.
* 4. Transaction does not move past the pending state within `args.options.timeoutSecs` seconds.
* - The function will throw a WaitForTransactionError
*
* @example
* const transaction = await aptos.waitForTransaction({transactionHash:"0x123"})
*
* @param args.transactionHash The hash of a transaction previously submitted to the blockchain.
* @param args.options.timeoutSecs Timeout in seconds. Defaults to 20 seconds.
* @param args.options.checkSuccess A boolean which controls whether the function will error if the transaction failed.
* Defaults to true. See case 3 above.
* @returns The transaction on-chain. See above for more details.
*/
waitForTransaction(args: {
transactionHash: HexInput;
options?: WaitForTransactionOptions;
}): Promise<CommittedTransactionResponse>;
/**
* Gives an estimate of the gas unit price required to get a
* transaction on chain in a reasonable amount of time.
* For more information {@link https://api.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price}
*
* @returns Object holding the outputs of the estimate gas API
*
* @example
* const gasPrice = await aptos.waitForTransaction()
*/
getGasPriceEstimation(): Promise<GasEstimation>;
/**
* Returns a signing message for a transaction.
*
* This allows a user to sign a transaction using their own preferred signing method, and
* then submit it to the network.
*
* @example
* const transaction = await aptos.transaction.build.simple({...})
* const message = await aptos.getSigningMessage({transaction})
*
* @param args.transaction A raw transaction for signing elsewhere
*/
getSigningMessage(args: {
transaction: AnyRawTransaction;
}): Uint8Array;
/**
* Generates a transaction to publish a move package to chain.
*
* To get the `metadataBytes` and `byteCode`, can compile using Aptos CLI with command
* `aptos move compile --save-metadata ...`,
* For more info {@link https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module}
*
* @example
* const transaction = await aptos.publishPackageTransaction({
* account: alice,
* metadataBytes,
* moduleBytecode: [byteCode],
* })
*
* @param args.account The publisher account
* @param args.metadataBytes The package metadata bytes
* @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order
*
* @returns A SimpleTransaction that can be simulated or submitted to chain
*/
publishPackageTransaction(args: {
account: AccountAddressInput;
metadataBytes: HexInput;
moduleBytecode: Array<HexInput>;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction>;
/**
* Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for
* the account.
* Note: Only legacy Ed25519 scheme is supported for now.
* More info: {@link https://aptos.dev/guides/account-management/key-rotation/}
*
* @example
* const response = await aptos.rotateAuthKey({
* fromAccount: alice,
* toNewPrivateKey: new ED25519PublicKey("0x123"),
* })
*
* @param args.fromAccount The account to rotate the auth key for
* @param args.toNewPrivateKey The new private key to rotate to
*
* @returns PendingTransactionResponse
*/
rotateAuthKey(args: {
fromAccount: Account$1;
toNewPrivateKey: PrivateKey;
}): Promise<TransactionResponse>;
/**
* Sign a transaction that can later be submitted to chain
*
* @example
* const transaction = await aptos.transaction.build.simple({...})
* const transaction = await aptos.transaction.sign({
* signer: alice,
* transaction
* })
*
* @param args.signer The signer account
* @param args.transaction A raw transaction to sign on
*
* @returns AccountAuthenticator
*/
sign(args: {
signer: Account$1;
transaction: AnyRawTransaction;
}): AccountAuthenticator;
/**
* Sign a transaction as a fee payer that can later be submitted to chain
*
* @example
* const transaction = await aptos.transaction.build.simple({...})
* const transaction = await aptos.transaction.signAsFeePayer({
* signer: alice,
* transaction
* })
*
* @param args.signer The fee payer signer account
* @param args.transaction A raw transaction to sign on
*
* @returns AccountAuthenticator
*/
signAsFeePayer(args: {
signer: Account$1;
transaction: AnyRawTransaction;
}): AccountAuthenticator;
/**
* @deprecated Prefer to use `aptos.transaction.batch.forSingleAccount()`
*
* Batch transactions for a single account.
*
* This function uses a transaction worker that receives payloads to be processed
* and submitted to chain.
* Note that this process is best for submitting multiple transactions that
* dont rely on each other, i.e batch funds, batch token mints, etc.
*
* If any worker failure, the functions throws an error.
*
* @param args.sender The sender account to sign and submit the transaction
* @param args.data An array of transaction payloads
* @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)
*
* @return void. Throws if any error
*/
batchTransactionsForSingleAccount(args: {
sender: Account$1;
data: InputGenerateTransactionPayloadData[];
options?: Omit<InputGenerateTransactionOptions, "accountSequenceNumber">;
}): Promise<void>;
/**
* Sign and submit a single signer transaction to chain
*
* @param args.signer The signer account to sign the transaction
* @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
*
* @example
* const transaction = await aptos.transaction.build.simple({...})
* const transaction = await aptos.signAndSubmitTransaction({
* signer: alice,
* transaction
* })
*
* @return PendingTransactionResponse
*/
signAndSubmitTransaction(args: {
signer: Account$1;
transaction: AnyRawTransaction;
}): Promise<PendingTransactionResponse>;
}
/**
* A class to query all `Table` Aptos related queries
*/
declare class Table {
readonly config: AptosConfig;
constructor(config: AptosConfig);
/**
* Queries for a table item for a table identified by the handle and the key for the item.
* Key and value types need to be passed in to help with key serialization and value deserialization.
*
* Note, this query calls the fullnode server
*
* @example https://api.devnet.aptoslabs.com/v1/accounts/0x1/resource/0x1::coin::CoinInfo%3C0x1::aptos_coin::AptosCoin%3E
* const tableItem = await aptos.getTableItem({
* handle: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca",
* data: {
* key_type: "address", // Move type of table key
* value_type: "u128", // Move type of table value
* key: "0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935" // Value of table key
* },
* })
*
* @param args.handle A pointer to where that table is stored
* @param args.data Object that describes table item
* @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version
*
* @returns Table item value rendered in JSON
*/
getTableItem<T>(args: {
handle: string;
data: TableItemRequest;
options?: LedgerVersionArg;
}): Promise<T>;
/**
* Queries for a table items data.
*
* Optional `options.where` param can be passed to filter the response.
*
* Note, this query calls the indexer server
*
* @example
* const data = await aptos.getTableItemsData({
* options: { where: {
* table_handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" },
* transaction_version: { _eq: "0" }
* }
* },
* });
*
* @returns GetTableItemsDataResponse
*/
getTableItemsData(args: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & WhereArg<TableItemsBoolExp> & OrderByArg<GetTableItemsDataResponse[0]>;
}): Promise<GetTableItemsDataResponse>;
/**
* Queries for a table items metadata.
*
* Optional `options.where` param can be passed to filter the response.
*
* Note, this query calls the indexer server
*
* @example
* const data = await aptos.getTableItemsMetadata({
* options: { where: { handle: { _eq: "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca" } } },
* });
*
* @returns GetTableItemsMetadataResponse
*/
getTableItemsMetadata(args: {
minimumLedgerVersion?: AnyNumber;
options?: PaginationArgs & WhereArg<TableMetadatasBoolExp> & OrderByArg<GetTableItemsMetadataResponse[0]>;
}): Promise<GetTableItemsMetadataResponse>;
}
/**
* This class is the main entry point into Aptos's
* APIs and separates functionality into different namespaces.
*
* To use the SDK, create a new Aptos instance to get access
* to all the sdk functionality.
*
* @example
*
* const aptos = new Aptos();
*/
declare class Aptos {
readonly config: AptosConfig;
readonly account: Account;
readonly ans: ANS;
readonly coin: Coin;
readonly digitalAsset: DigitalAsset;
readonly event: Event;
readonly faucet: Faucet;
readonly fungibleAsset: FungibleAsset;
readonly general: General;
readonly staking: Staking;
readonly transaction: Transaction;
readonly table: Table;
constructor(settings?: AptosConfig);
}
interface Aptos extends Account, ANS, Coin, DigitalAsset, Event, Faucet, FungibleAsset, General, Staking, Table, Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {
}
/**
* The API response type
*
* @param status - the response status. i.e. 200
* @param statusText - the response message
* @param data the response data
* @param url the url the request was made to
* @param headers the response headers
* @param config (optional) - the request object
* @param request (optional) - the request object
*/
interface AptosResponse<Req, Res> {
status: number;
statusText: string;
data: Res;
url: string;
headers: any;
config?: any;
request?: Req;
}
/**
* The type returned from an API error
*
* @param name - the error name "AptosApiError"
* @param url the url the request was made to
* @param status - the response status. i.e. 400
* @param statusText - the response message
* @param data the response data
* @param request - the AptosRequest
*/
declare class AptosApiError extends Error {
readonly url: string;
readonly status: number;
readonly statusText: string;
readonly data: any;
readonly request: AptosRequest;
constructor(request: AptosRequest, response: AptosResponse<any, any>, message: string);
}
type DeserializableClass<T extends Serializable> = {
deserialize(deserializer: Deserializer): T;
};
/**
* Utility function that serializes and deserialize an object back into the same bundle as the sdk.
* This is a workaround to have the `instanceof` operator work when input objects come from a different
* bundle.
* @param cls The class of the object to normalize
* @param value the instance to normalize
*/
declare function normalizeBundle<T extends Serializable>(cls: DeserializableClass<T>, value: T): T;
/**
* Given a url and method, sends the request with axios and
* returns the response.
*/
declare function request<Req, Res>(options: ClientRequest<Req>, client: Client): Promise<ClientResponse<Res>>;
/**
* The main function to use when doing an API request.
*
* @param options AptosRequest
* @param aptosConfig The config information for the SDK client instance
* @returns the response or AptosApiError
*/
declare function aptosRequest<Req extends {}, Res extends {}>(options: AptosRequest, aptosConfig: AptosConfig, apiType: AptosApiType): Promise<AptosResponse<Req, Res>>;
type GetRequestOptions = {
/**
* The config for the API client
*/
aptosConfig: AptosConfig;
/**
* The type of API endpoint to call e.g. fullnode, indexer, etc
*/
type: AptosApiType;
/**
* The name of the API method
*/
originMethod: string;
/**
* The URL path to the API method
*/
path: string;
/**
* The content type of the request body
*/
contentType?: MimeType;
/**
* The accepted content type of the response of the API
*/
acceptType?: MimeType;
/**
* The query parameters for the request
*/
params?: Record<string, string | AnyNumber | boolean | undefined>;
/**
* Specific client overrides for this request to override aptosConfig
*/
overrides?: ClientConfig;
};
type GetAptosRequestOptions = Omit<GetRequestOptions, "type">;
/**
* Main function to do a Get request
*
* @param options GetRequestOptions
* @returns
*/
declare function get<Req extends {}, Res extends {}>(options: GetRequestOptions): Promise<AptosResponse<Req, Res>>;
declare function getAptosFullNode<Req extends {}, Res extends {}>(options: GetAptosRequestOptions): Promise<AptosResponse<Req, Res>>;
declare function paginateWithCursor<Req extends Record<string, any>, Res extends Array<{}>>(options: GetAptosRequestOptions): Promise<Res>;
type PostRequestOptions = {
/**
* The config for the API client
*/
aptosConfig: AptosConfig;
/**
* The type of API endpoint to call e.g. fullnode, indexer, etc
*/
type: AptosApiType;
/**
* The name of the API method
*/
originMethod: string;
/**
* The URL path to the API method
*/
path: string;
/**
* The content type of the request body
*/
contentType?: MimeType;
/**
* The accepted content type of the response of the API
*/
acceptType?: MimeType;
/**
* The query parameters for the request
*/
params?: Record<string, string | AnyNumber | boolean | undefined>;
/**
* The body of the request, should match the content type of the request
*/
body?: any;
/**
* Specific client overrides for this request to override aptosConfig
*/
overrides?: ClientConfig;
};
type PostAptosRequestOptions = Omit<PostRequestOptions, "type">;
/**
* Main function to do a Post request
*
* @param options PostRequestOptions
* @returns
*/
declare function post<Req extends {}, Res extends {}>(options: PostRequestOptions): Promise<AptosResponse<Req, Res>>;
declare function postAptosFullNode<Req extends {}, Res extends {}>(options: PostAptosRequestOptions): Promise<AptosResponse<Req, Res>>;
declare function postAptosIndexer<Req extends {}, Res extends {}>(options: PostAptosRequestOptions): Promise<AptosResponse<Req, Res>>;
declare function postAptosFaucet<Req extends {}, Res extends {}>(options: PostAptosRequestOptions): Promise<AptosResponse<Req, Res>>;
export { APTOS_BIP44_REGEX, APTOS_COIN, APTOS_HARDENED_REGEX, Account$1 as Account, AccountAddress, AccountAddressInput, AccountAuthenticator, AccountAuthenticatorEd25519, AccountAuthenticatorMultiEd25519, AccountAuthenticatorMultiKey, AccountAuthenticatorSingleKey, AccountData, AccountPublicKey, AccountSequenceNumber, AnyNumber, AnyPublicKey, AnyPublicKeyVariant, type AnyRawTransaction, type AnyRawTransactionInstance, AnySignature, type AnyTransactionPayloadInstance, Aptos, AptosApiError, AptosApiType, AptosConfig, AptosRequest, type AptosResponse, AptosSettings, AuthenticationKey, AuthenticationKeyScheme, Block, Bool, CKDPriv, ChainId, Client, ClientConfig, ClientRequest, ClientResponse, CommittedTransactionResponse, type CreateAccountFromPrivateKeyArgs, type CreateEd25519AccountFromPrivateKeyArgs, type CreateEd25519SingleKeyAccountFromPrivateKeyArgs, type CreateSingleKeyAccountFromPrivateKeyArgs, DEFAULT_MAX_GAS_AMOUNT, DEFAULT_TXN_EXP_SEC_FROM_NOW, DEFAULT_TXN_TIMEOUT_SEC, type DerivedKeys, Deserializable, type DeserializableClass, Deserializer, Ed25519Account, Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature, type Ed25519SignerConstructorArgs, type Ed25519SignerFromDerivationPathArgs, EntryFunction, type EntryFunctionABI, EntryFunctionArgument, type EntryFunctionArgumentTypes, EntryFunctionBytes, type ExecutionFinishEventData, type FailureEventData, FaucetConfig, FeePayerRawTransaction, FixedBytes, FullNodeConfig, type FunctionABI, GasEstimation, type GenerateAccountArgs, type GenerateEd25519AccountArgs, type GenerateEd25519SingleKeyAccountArgs, type GenerateSingleKeyAccountArgs, GetANSNameResponse, GetAccountCoinsDataResponse, GetAccountCollectionsWithOwnedTokenResponse, GetAccountOwnedObjectsResponse, GetAccountOwnedTokensFromCollectionResponse, GetAccountOwnedTokensQueryResponse, type GetAptosRequestOptions, GetChainTopUserTransactionsResponse, GetCollectionDataResponse, GetCurrentFungibleAssetBalancesResponse, GetCurrentTokenOwnershipResponse, GetDelegatedStakingActivitiesResponse, GetEventsResponse, GetFungibleAssetActivitiesResponse, GetFungibleAssetMetadataResponse, GetNumberOfDelegatorsResponse, GetOwnedTokensResponse, GetProcessorStatusResponse, type GetRequestOptions, GetTableItemsDataResponse, GetTableItemsMetadataResponse, GetTokenActivityResponse, GetTokenDataResponse, GraphqlQuery, HARDENED_OFFSET, Hex, HexInput, Identifier, IndexerConfig, type InputEntryFunctionData, type InputEntryFunctionDataWithABI, type InputEntryFunctionDataWithRemoteABI, type InputGenerateMultiAgentRawTransactionArgs, type InputGenerateMultiAgentRawTransactionData, type InputGenerateRawTransactionArgs, type InputGenerateSingleSignerRawTransactionArgs, type InputGenerateSingleSignerRawTransactionData, type InputGenerateTransactionData, type InputGenerateTransactionOptions, type InputGenerateTransactionPayloadData, type InputGenerateTransactionPayloadDataWithABI, type InputGenerateTransactionPayloadDataWithRemoteABI, type InputMultiSigData, type InputMultiSigDataWithABI, type InputMultiSigDataWithRemoteABI, type InputScriptData, type InputSimulateTransactionData, type InputSimulateTransactionOptions, type InputSubmitTransactionData, type InputViewFunctionData, type InputViewFunctionDataWithABI, type InputViewFunctionDataWithRemoteABI, KeyType, LedgerInfo, LedgerVersionArg, MimeType, ModuleId, MoveFunction, MoveFunctionGenericTypeParam, MoveFunctionId, MoveModuleBytecode, MoveModuleId, MoveOption, MoveResource, MoveString, MoveStructId, MoveValue, MoveVector, MultiAgentRawTransaction, MultiAgentTransaction, MultiEd25519PublicKey, MultiEd25519Signature, MultiKey, MultiKeyAccount, MultiKeySignature, MultiSig, MultiSigTransactionPayload, Network, OrderByArg, PaginationArgs, PendingTransactionResponse, type PostAptosRequestOptions, type PostRequestOptions, type PrivateKey, type PrivateKeyFromDerivationPathArgs, ProcessorType, PublicKey, RAW_TRANSACTION_SALT, RAW_TRANSACTION_WITH_DATA_SALT, RawTransaction, RawTransactionWithData, RotationProofChallenge, Script, ScriptFunctionArgument, type ScriptFunctionArgumentTypes, Secp256k1PrivateKey, Secp256k1PublicKey, Secp256k1Signature, Serializable, Serializer, Signature, SignedTransaction, SigningScheme, SigningSchemeInput, type SimpleEntryFunctionArgumentTypes, SimpleTransaction, SingleKeyAccount, type SingleKeySignerConstructorArgs, type SingleKeySignerFromDerivationPathArgs, type SingleKeySignerGenerateArgs, StructTag, type SuccessEventData, TableItemRequest, TokenStandardArg, TransactionArgument, TransactionAuthenticator, TransactionAuthenticatorEd25519, TransactionAuthenticatorFeePayer, TransactionAuthenticatorMultiAgent, TransactionAuthenticatorMultiEd25519, TransactionAuthenticatorSingleSender, TransactionPayload, TransactionPayloadEntryFunction, TransactionPayloadMultiSig, TransactionPayloadScript, TransactionResponse, TransactionWorker, type TransactionWorkerEvents, TransactionWorkerEventsEnum, TypeTag, TypeTagAddress, TypeTagBool, TypeTagGeneric, TypeTagParserError, TypeTagParserErrorType, TypeTagReference, TypeTagSigner, TypeTagStruct, TypeTagU128, TypeTagU16, TypeTagU256, TypeTagU32, TypeTagU64, TypeTagU8, TypeTagVector, U128, U16, U256, U32, U64, U8, Uint16, Uint32, Uint8, UserTransactionResponse, type VerifyEd25519SignatureArgs, type VerifyMultiKeySignatureArgs, type VerifySignatureArgs, type VerifySingleKeySignatureArgs, type ViewFunctionABI, WaitForTransactionOptions, WhereArg, aptosCoinStructTag, aptosRequest, buildTransaction, checkOrConvertArgument, convertArgument, deriveKey, deriveTransactionType, deserializeFromScriptArgument, fetchEntryFunctionAbi, fetchFunctionAbi, fetchViewFunctionAbi, findFirstNonSignerArg, generateRawTransaction, generateSignedTransaction, generateSignedTransactionForSimulation, generateSigningMessage, generateSigningMessageForSerializable, generateSigningMessageForTransaction, generateTransactionPayload, generateTransactionPayloadWithABI, generateUserTransactionHash, generateViewFunctionPayload, generateViewFunctionPayloadWithABI, get, getAptosFullNode, getAuthenticatorForSimulation, getFunctionParts, hashValues, isBcsAddress, isBcsBool, isBcsFixedBytes, isBcsString, isBcsU128, isBcsU16, isBcsU256, isBcsU32, isBcsU64, isBcsU8, isBool, isEncodedEntryFunctionArgument, isLargeNumber, isNull, isNumber, isScriptDataInput, isString, isValidBIP44Path, isValidHardenedPath, mnemonicToSeed, normalizeBundle, objectStructTag, optionStructTag, paginateWithCursor, parseTypeTag, post, postAptosFaucet, postAptosFullNode, postAptosIndexer, promiseFulfilledStatus, request, splitPath, standardizeTypeTags, stringStructTag, throwTypeMismatch };