Skip to Content

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

TypeScriptsignAndSubmitTransaction

signAndSubmitTransaction

This function is used to sign and submit a transaction to the Aptos blockchain. If no signer is specified, the transaction will use the signer from the AptosJSProClient.

Usage

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

With Pre-built Transaction

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

Parameters

NameTypeDefault
signerAccount
feePayerAccount
feePayerAuthenticatorAccountAuthenticator
networkNetworkInfo

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

Return Type

The SignAndSubmitTransactionResult will be a TransactionResponse from the @aptos-labs/ts-sdk. The type will typically be PendingTransactionResponse or UserTransactionResponse.

PendingTransactionResponse

NameTypeDefault
typeTransactionResponseType.Pending
hashstring
senderstring
sequence_numberstring
max_gas_amountstring
gas_unit_pricestring
expiration_timestamp_secsstring
payloadTransactionPayloadResponse
signatureTransactionSignature

UserTransactionResponse

NameTypeDefault
typeTransactionResponseType.User
versionstring
hashstring
state_change_hashstring
event_root_hashstring
state_checkpoint_hashstring | null
gas_usedstring
successboolean

Whether the transaction was successful

vm_statusstring

The VM status of the transaction, can tell useful information in a failure

accumulator_root_hashstring
changesWriteSetChange[]

Final state of resources changed by the transaction

senderstring
sequence_numberstring
max_gas_amountstring
gas_unit_pricestring
expiration_timestamp_secsstring
payloadTransactionPayloadResponse
signatureTransactionSignature
eventsEvent[]

Events generated by the transaction

timestampstring
Last updated on