TransactionComposer
TransactionComposer
Section titled “TransactionComposer”Builds and sends atomic transaction groups with automatic resource population and fee handling.
Creating a Composer
Section titled “Creating a Composer”const composer = algorand.newGroup();Methods
Section titled “Methods”addPayment(params)
Section titled “addPayment(params)”Adds a payment transaction.
| Parameter | Type | Description |
|---|---|---|
params.sender | TransactionSignerAccount | Sender |
params.receiver | string | Receiver address |
params.amount | AlgoAmount | Payment amount |
params.note | string | Uint8Array | Optional note |
composer.addPayment({ sender: alice, receiver: bob.addr, amount: (1).algo(),});addAssetTransfer(params)
Section titled “addAssetTransfer(params)”Adds an asset transfer transaction.
| Parameter | Type | Description |
|---|---|---|
params.sender | TransactionSignerAccount | Sender |
params.receiver | string | Receiver address |
params.assetId | bigint | Asset ID |
params.amount | bigint | Transfer amount |
addAppCallMethodCall(params)
Section titled “addAppCallMethodCall(params)”Adds an ABI method call to an application.
send()
Section titled “send()”Sends all transactions in the group atomically.
const result = await algorand .newGroup() .addPayment({ sender: alice, receiver: bob.addr, amount: (1).algo() }) .addPayment({ sender: alice, receiver: charlie.addr, amount: (2).algo() }) .send();
console.log(result.txIds); // ['TX1...', 'TX2...']simulate()
Section titled “simulate()”Simulates the transaction group without submitting.
const simResult = await composer.simulate();buildGroup()
Section titled “buildGroup()”Builds the transaction group without sending.
const txns = await composer.buildGroup();