Sending Transactions
Once a web application is connected to StarKey via the Aptos Wallet Adapter, it can prompt the user to sign and submit transactions on their behalf.
Sign and submit
signAndSubmitTransaction signs the transaction and submits it to the network in one call:
import { InputTransactionData, useWallet } from '@aptos-labs/wallet-adapter-react'
const { signAndSubmitTransaction } = useWallet()
const transaction: InputTransactionData = {
data: {
function: '0x1::aptos_account::transfer',
typeArguments: [],
functionArguments: [toAddress, amount],
},
}
const pendingTransaction = await signAndSubmitTransaction(transaction)
console.log('txHash ::', pendingTransaction.hash)Sign only
For advanced flows, such as multi-signature transactions, use signTransaction to sign without submitting — you decide when and how to submit it:
const { signTransaction } = useWallet()
const signedTransaction = await signTransaction(transaction)
// submit signedTransaction later as neededNotes
InputTransactionDatatakes the Move entry-function path, its type arguments, and its function arguments — the adapter handles BCS serialization for you, no manualAptosClientconstruction needed.- Both methods can reject if the user declines the confirmation prompt — wrap calls in
try/catch. See Error Codes.
Related pages
Last updated on