Skip to main content

Sending Transactions

Overview

Wallets, if supported, can commit transactions to the network using their connection to a node.

Sending a transaction with the default wallet

If you only want to send transactions to the network with the default wallet, you can simply call:

try {
const result = await window.algorand.postTxns({
stxns: [
'gqNzaWfEQ...',
],
});

console.log(result);
/*
{
id: 'awesome-wallet',
txnIDs: [
'OKU6A2Q...',
],
}
*/
} catch (error) {
// handle error
}
caution

If this operation is not supported, then a WalletOperationNotSupportedError will be thrown.

Sending a transaction with a specific wallet

If you want to target a specific wallet to send the transaction, you can simply pass the ID of the wallet to the options object:

try {
const result = await window.algorand.postTxns({
id: 'another-awesome-wallet',
stxns: [
'gqNzaWfEQ...',
],
});

console.log(result);
/*
{
id: 'another-awesome-wallet',
txnIDs: [
'OKU6A2Q...',
],
}
*/
} catch (error) {
// handle error
}
caution

If the specified wallet does not exist, then a WalletDoesNotExistError will be thrown.