Skip to Content

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

TypeScriptbuildTransaction

buildTransaction

This function is used to build a transaction. The transaction will be built with getServerTime if no timestamps are provided.

Usage

import { AptosJSProClient } from "@aptos-labs/js-pro"; import { Network } from "@aptos-labs/ts-sdk"; const client = new AptosJSProClient({ /* ... */ }); const transaction = await client.buildTransaction({ data: { function: "0x1::aptos_account::transfer", functionArguments: [recipient.accountAddress, 100], }, });

Parameters

The buildTransaction function two types of parameters: BuildSimpleTransactionParameters or BuildMultiAgentTransactionParameters.

BuildSimpleTransactionParameters

NameTypeDefault
dataInputGenerateTransactionPayloadData
optionsInputGenerateTransactionOptions
withFeePayerboolean
senderAccountAddressInput
networkNetworkInfo

The network to use for the request. If not set, the network of the AptosJSProClient instance will be used.

BuildMultiAgentTransactionParameters

NameTypeDefault
dataInputGenerateTransactionPayloadData
secondarySignerAddressesAccountAddressInput[]
optionsInputGenerateTransactionOptions
withFeePayerboolean
senderAccountAddressInput
networkNetworkInfo

The network to use for the request. If not set, the network of the AptosJSProClient instance will be used.

Return Type

The buildTransaction will return a SimpleTransaction or MultiAgentTransaction from the @aptos-labs/ts-sdk depending on the parameters passed in.

SimpleTransaction

This is the return type for the buildTransaction function when the secondarySignerAddresses parameter is not provided.

NameTypeDefault
rawTransactionRawTransaction
feePayerAddressAccountAddress | undefined
secondarySignerAddressesundefined
serialize(serializer: Serializer) => void

Serializes the transaction data using the provided serializer. This function ensures that the raw transaction and fee payer address are properly serialized for further processing.

bcsToBytes() => Uint8Array<ArrayBufferLike>

Serializes a Serializable value to its BCS representation. This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.

bcsToHex() => Hex

Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

toStringWithoutPrefix() => string

Returns the hex string representation of the Serializable value without the 0x prefix.

toString() => string

Returns the hex string representation of the Serializable value with the 0x prefix.

MultiAgentTransaction

This is the return type for the buildTransaction function when the secondarySignerAddresses parameter is provided.

NameTypeDefault
rawTransactionRawTransaction
feePayerAddressAccountAddress | undefined
secondarySignerAddressesAccountAddress[]
serialize(serializer: Serializer) => void

Serializes the transaction data, including the raw transaction, secondary signer addresses, and fee payer address. This function is essential for preparing the transaction for transmission or storage in a serialized format.

bcsToBytes() => Uint8Array<ArrayBufferLike>

Serializes a Serializable value to its BCS representation. This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.

bcsToHex() => Hex

Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

toStringWithoutPrefix() => string

Returns the hex string representation of the Serializable value without the 0x prefix.

toString() => string

Returns the hex string representation of the Serializable value with the 0x prefix.

Last updated on