TransactionComposer
@algorandfoundation/algokit-utils / types/composer / TransactionComposer
types/composer.TransactionComposer
TransactionComposer helps you compose and execute transactions as a transaction group.
Table of contents
Constructors
Properties
- algod
- appManager
- atc
- defaultValidityWindow
- defaultValidityWindowIsExplicit
- errorTransformers
- getSigner
- getSuggestedParams
- txnMaxFees
- txns
- NULL_SIGNER
Methods
- addAppCall
- addAppCallMethodCall
- addAppCreate
- addAppCreateMethodCall
- addAppDelete
- addAppDeleteMethodCall
- addAppUpdate
- addAppUpdateMethodCall
- addAssetConfig
- addAssetCreate
- addAssetDestroy
- addAssetFreeze
- addAssetOptIn
- addAssetOptOut
- addAssetTransfer
- addAtc
- addOfflineKeyRegistration
- addOnlineKeyRegistration
- addPayment
- addTransaction
- build
- buildAppCall
- buildAssetConfig
- buildAssetCreate
- buildAssetDestroy
- buildAssetFreeze
- buildAssetTransfer
- buildAtc
- buildKeyReg
- buildMethodCall
- buildPayment
- buildTransactions
- buildTxn
- buildTxnWithSigner
- commonTxnBuildStep
- count
- execute
- rebuild
- registerErrorTransformer
- send
- simulate
- transformError
- arc2Note
Constructors
constructor
• new TransactionComposer(params
): TransactionComposer
Create a TransactionComposer
.
Parameters
Name | Type | Description |
---|---|---|
params | TransactionComposerParams | The configuration for this composer |
Returns
The TransactionComposer
instance
Defined in
Properties
algod
• Private
algod: AlgodClient
The algod client used by the composer.
Defined in
appManager
• Private
appManager: AppManager
Defined in
atc
• Private
atc: AtomicTransactionComposer
The ATC used to compose the group
Defined in
defaultValidityWindow
• Private
defaultValidityWindow: bigint
The default transaction validity window
Defined in
defaultValidityWindowIsExplicit
• Private
defaultValidityWindowIsExplicit: boolean
= false
Whether the validity window was explicitly set on construction
Defined in
errorTransformers
• Private
errorTransformers: ErrorTransformer
[]
Defined in
getSigner
• Private
getSigner: (address
: string
| Address
) => TransactionSigner
A function that takes in an address and return a signer function for that address.
Type declaration
▸ (address
): TransactionSigner
Parameters
Name | Type |
---|---|
address | string | Address |
Returns
TransactionSigner
Defined in
getSuggestedParams
• Private
getSuggestedParams: () => Promise
<SuggestedParams
>
An async function that will return suggested params for the transaction.
Type declaration
▸ (): Promise
<SuggestedParams
>
Returns
Promise
<SuggestedParams
>
Defined in
txnMaxFees
• Private
txnMaxFees: Map
<number
, AlgoAmount
>
Map of transaction index in the atc to a max logical fee. This is set using the value of either maxFee or staticFee.
Defined in
txns
• Private
txns: Txn
[] = []
Transactions that have not yet been composed
Defined in
NULL_SIGNER
▪ Static
Private
NULL_SIGNER: TransactionSigner
Signer used to represent a lack of signer
Defined in
Methods
addAppCall
▸ addAppCall(params
): TransactionComposer
Add an application call transaction to the transaction group.
If you want to create or update an app use addAppCreate
or addAppUpdate
.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppCallParams | The application call transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAppCall({ sender: 'CREATORADDRESS' });
Example
composer.addAppCall({ sender: 'CREATORADDRESS', onComplete: algosdk.OnApplicationComplete.OptInOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppCallMethodCall
▸ addAppCallMethodCall(params
): TransactionComposer
Add a non-create/non-update ABI method application call transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppCallMethodCall | The ABI method application call transaction parameters |
Returns
The composer so you can chain method calls
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },});composer.addAppCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ['arg1_value'] });
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },})composer.addAppCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"], onComplete: algosdk.OnApplicationComplete.OptInOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppCreate
▸ addAppCreate(params
): TransactionComposer
Add an application create transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | Object | The application create transaction parameters |
params.accountReferences? | (string | Address )[] | Any account addresses to add to the accounts array. |
params.appReferences? | bigint [] | The ID of any apps to load to the foreign apps array. |
params.approvalProgram | string | Uint8Array | The program to execute for all OnCompletes other than ClearState as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). |
params.args? | Uint8Array [] | Any arguments to pass to the smart contract call. |
params.assetReferences? | bigint [] | The ID of any assets to load to the foreign assets array. |
params.boxReferences? | (BoxIdentifier | BoxReference )[] | Any boxes to load to the boxes array. Either the name identifier (which will be set against app ID of 0 i.e. the current app), or a box identifier with the name identifier and app ID. |
params.clearStateProgram | string | Uint8Array | The program to execute for ClearState OnComplete as raw teal that will be compiled (string) or compiled teal (encoded as a byte array (Uint8Array)). |
params.extraFee? | AlgoAmount | The fee to pay IN ADDITION to the suggested fee. Useful for manually covering inner transaction fees. |
params.extraProgramPages? | number | Number of extra pages required for the programs. Defaults to the number needed for the programs in this call if not specified. This is immutable once the app is created. |
params.firstValidRound? | bigint | Set the first round this transaction is valid. If left undefined, the value from algod will be used. We recommend you only set this when you intentionally want this to be some time in the future. |
params.lastValidRound? | bigint | The last round this transaction is valid. It is recommended to use validityWindow instead. |
params.lease? | string | Uint8Array | Prevent multiple transactions with the same lease being included within the validity window. A lease enforces a mutually exclusive transaction (useful to prevent double-posting and other scenarios). |
params.maxFee? | AlgoAmount | Throw an error if the fee for the transaction is more than this amount; prevents overspending on fees during high congestion periods. |
params.note? | string | Uint8Array | Note to attach to the transaction. Max of 1000 bytes. |
params.onComplete? | NoOpOC | OptInOC | CloseOutOC | UpdateApplicationOC | DeleteApplicationOC | The on-complete action of the call; defaults to no-op. |
params.rekeyTo? | string | Address | Change the signing key of the sender to the given address. Warning: Please be careful with this parameter and be sure to read the official rekey guidance. |
params.schema? | Object | The state schema for the app. This is immutable once the app is created. |
params.schema.globalByteSlices | number | The number of byte slices saved in global state. |
params.schema.globalInts | number | The number of integers saved in global state. |
params.schema.localByteSlices | number | The number of byte slices saved in local state. |
params.schema.localInts | number | The number of integers saved in local state. |
params.sender | string | Address | The address of the account sending the transaction. |
params.signer? | TransactionSigner | TransactionSignerAccount | The function used to sign transaction(s); if not specified then an attempt will be made to find a registered signer for the given sender or use a default signer (if configured). |
params.staticFee? | AlgoAmount | The static transaction fee. In most cases you want to use extraFee unless setting the fee to 0 to be covered by another transaction. |
params.validityWindow? | number | bigint | How many rounds the transaction should be valid for, if not specified then the registered default validity window will be used. |
Returns
The composer so you can chain method calls
Example
composer.addAppCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE',});
Example
composer.addAppCreate({ sender: 'CREATORADDRESS', approvalProgram: "TEALCODE", clearStateProgram: "TEALCODE", schema: { globalInts: 1, globalByteSlices: 2, localInts: 3, localByteSlices: 4 }, extraProgramPages: 1, onComplete: algosdk.OnApplicationComplete.OptInOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in signer: transactionSigner, maxRoundsToWaitForConfirmation: 5, suppressLog: true,})
Defined in
addAppCreateMethodCall
▸ addAppCreateMethodCall(params
): TransactionComposer
Add an ABI method create application call transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppCreateMethodCall | The ABI create method application call transaction parameters |
Returns
The composer so you can chain method calls
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },});composer.addAppCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ['arg1_value'],});
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },})composer.addAppCreateMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"], approvalProgram: "TEALCODE", clearStateProgram: "TEALCODE", schema: { globalInts: 1, globalByteSlices: 2, localInts: 3, localByteSlices: 4 }, extraProgramPages: 1, onComplete: algosdk.OnApplicationComplete.OptInOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppDelete
▸ addAppDelete(params
): TransactionComposer
Add an application delete transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppDeleteParams | The application delete transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAppDelete({ sender: 'CREATORADDRESS' });
Example
composer.addAppDelete({ sender: 'CREATORADDRESS', onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppDeleteMethodCall
▸ addAppDeleteMethodCall(params
): TransactionComposer
Add an ABI method delete application call transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppDeleteMethodCall | The ABI delete method application call transaction parameters |
Returns
The composer so you can chain method calls
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },});composer.addAppDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ['arg1_value'] });
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },})composer.addAppDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"], onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppUpdate
▸ addAppUpdate(params
): TransactionComposer
Add an application update transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | Object | The application update transaction parameters |
params.accountReferences? | (string | Address )[] | Any account addresses to add to the accounts array. |
params.appId | bigint | ID of the application; 0 if the application is being created. |
params.appReferences? | bigint [] | The ID of any apps to load to the foreign apps array. |
params.approvalProgram | string | Uint8Array | The program to execute for all OnCompletes other than ClearState as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) |
params.args? | Uint8Array [] | Any arguments to pass to the smart contract call. |
params.assetReferences? | bigint [] | The ID of any assets to load to the foreign assets array. |
params.boxReferences? | (BoxIdentifier | BoxReference )[] | Any boxes to load to the boxes array. Either the name identifier (which will be set against app ID of 0 i.e. the current app), or a box identifier with the name identifier and app ID. |
params.clearStateProgram | string | Uint8Array | The program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array)) |
params.extraFee? | AlgoAmount | The fee to pay IN ADDITION to the suggested fee. Useful for manually covering inner transaction fees. |
params.firstValidRound? | bigint | Set the first round this transaction is valid. If left undefined, the value from algod will be used. We recommend you only set this when you intentionally want this to be some time in the future. |
params.lastValidRound? | bigint | The last round this transaction is valid. It is recommended to use validityWindow instead. |
params.lease? | string | Uint8Array | Prevent multiple transactions with the same lease being included within the validity window. A lease enforces a mutually exclusive transaction (useful to prevent double-posting and other scenarios). |
params.maxFee? | AlgoAmount | Throw an error if the fee for the transaction is more than this amount; prevents overspending on fees during high congestion periods. |
params.note? | string | Uint8Array | Note to attach to the transaction. Max of 1000 bytes. |
params.onComplete? | UpdateApplicationOC | The on-complete action of the call; defaults to no-op. |
params.rekeyTo? | string | Address | Change the signing key of the sender to the given address. Warning: Please be careful with this parameter and be sure to read the official rekey guidance. |
params.sender | string | Address | The address of the account sending the transaction. |
params.signer? | TransactionSigner | TransactionSignerAccount | The function used to sign transaction(s); if not specified then an attempt will be made to find a registered signer for the given sender or use a default signer (if configured). |
params.staticFee? | AlgoAmount | The static transaction fee. In most cases you want to use extraFee unless setting the fee to 0 to be covered by another transaction. |
params.validityWindow? | number | bigint | How many rounds the transaction should be valid for, if not specified then the registered default validity window will be used. |
Returns
The composer so you can chain method calls
Example
composer.addAppUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE',});
Example
composer.addAppUpdate({ sender: 'CREATORADDRESS', approvalProgram: "TEALCODE", clearStateProgram: "TEALCODE", onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAppUpdateMethodCall
▸ addAppUpdateMethodCall(params
): TransactionComposer
Add an ABI method update application call transaction to the transaction group.
Note: we recommend using app clients to make it easier to make app calls.
Parameters
Name | Type | Description |
---|---|---|
params | AppUpdateMethodCall | The ABI update method application call transaction parameters |
Returns
The composer so you can chain method calls
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },});composer.addAppUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ['arg1_value'],});
Example
const method = new ABIMethod({ name: 'method', args: [{ name: 'arg1', type: 'string' }], returns: { type: 'string' },})composer.addAppUpdateMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"], approvalProgram: "TEALCODE", clearStateProgram: "TEALCODE", onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC, args: [new Uint8Array(1, 2, 3, 4)] accountReferences: ["ACCOUNT_1"] appReferences: [123n, 1234n] assetReferences: [12345n] boxReferences: ["box1", {appId: 1234n, name: "box2"}] lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAssetConfig
▸ addAssetConfig(params
): TransactionComposer
Add an asset config transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | AssetConfigParams | The asset config transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAssetConfig({ sender: 'MANAGERADDRESS', assetId: 123456n, manager: 'MANAGERADDRESS' });
Example
composer.addAssetConfig({ sender: 'MANAGERADDRESS', assetId: 123456n, manager: 'MANAGERADDRESS', reserve: 'RESERVEADDRESS', freeze: 'FREEZEADDRESS', clawback: 'CLAWBACKADDRESS', lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
#### Defined in
[src/types/composer.ts:758](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L758)
___
### addAssetCreate
▸ **addAssetCreate**(`params`): [`TransactionComposer`](types_composer.TransactionComposer.md)
Add an asset create transaction to the transaction group.
#### Parameters
| Name | Type | Description || :------ | :------ | :------ || `params` | [`AssetCreateParams`](/reference/algokit-utils-ts/api/modules/types_composer/#assetcreateparams) | The asset create transaction parameters |
#### Returns
[`TransactionComposer`](types_composer.TransactionComposer.md)
The composer so you can chain method calls
**`Example`**
```typescriptcomposer.addAssetCreate({ sender: "CREATORADDRESS", total: 100n})
Example
composer.addAssetCreate({ sender: 'CREATORADDRESS', total: 100n, decimals: 2, assetName: 'asset', unitName: 'unit', url: 'url', metadataHash: 'metadataHash', defaultFrozen: false, manager: 'MANAGERADDRESS', reserve: 'RESERVEADDRESS', freeze: 'FREEZEADDRESS', clawback: 'CLAWBACKADDRESS', lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
#### Defined in
[src/types/composer.ts:723](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L723)
___
### addAssetDestroy
▸ **addAssetDestroy**(`params`): [`TransactionComposer`](types_composer.TransactionComposer.md)
Add an asset destroy transaction to the transaction group.
#### Parameters
| Name | Type | Description || :------ | :------ | :------ || `params` | [`AssetDestroyParams`](/reference/algokit-utils-ts/api/modules/types_composer/#assetdestroyparams) | The asset destroy transaction parameters |
#### Returns
[`TransactionComposer`](types_composer.TransactionComposer.md)
The composer so you can chain method calls
**`Example`**
```typescriptcomposer.addAssetDestroy({ sender: "MANAGERADDRESS", assetId: 123456n })
Example
composer.addAssetDestroy({ sender: 'MANAGERADDRESS', assetId: 123456n, lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addAssetFreeze
▸ addAssetFreeze(params
): TransactionComposer
Add an asset freeze transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | AssetFreezeParams | The asset freeze transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAssetFreeze({ sender: 'MANAGERADDRESS', assetId: 123456n, account: 'ACCOUNTADDRESS', frozen: true,});
Example
composer.addAssetFreeze({ sender: 'MANAGERADDRESS', assetId: 123456n, account: 'ACCOUNTADDRESS', frozen: true, lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addAssetOptIn
▸ addAssetOptIn(params
): TransactionComposer
Add an asset opt-in transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | AssetOptInParams | The asset opt-in transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAssetOptIn({ sender: 'SENDERADDRESS', assetId: 123456n });
Example
composer.addAssetOptIn({ sender: 'SENDERADDRESS', assetId: 123456n, lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addAssetOptOut
▸ addAssetOptOut(params
): TransactionComposer
Add an asset opt-out transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | AssetOptOutParams | The asset opt-out transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAssetOptOut({ sender: 'SENDERADDRESS', assetId: 123456n, ensureZeroBalance: true });
Example
composer.addAssetOptOut({ sender: 'SENDERADDRESS', creator: 'CREATORADDRESS', assetId: 123456n, ensureZeroBalance: true,});
Example
composer.addAssetOptOut({ sender: 'SENDERADDRESS', assetId: 123456n, creator: 'CREATORADDRESS', ensureZeroBalance: true, lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addAssetTransfer
▸ addAssetTransfer(params
): TransactionComposer
Add an asset transfer transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | AssetTransferParams | The asset transfer transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addAssetTransfer({ sender: 'HOLDERADDRESS', assetId: 123456n, amount: 1n, receiver: 'RECEIVERADDRESS',});
Example
composer.addAssetTransfer({ sender: 'CLAWBACKADDRESS', assetId: 123456n, amount: 1n, receiver: 'RECEIVERADDRESS', clawbackTarget: 'HOLDERADDRESS', // This field needs to be used with caution closeAssetTo: 'ADDRESSTOCLOSETO' lease: 'lease', note: 'note', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
Defined in
addAtc
▸ addAtc(atc
): TransactionComposer
Add the transactions within an AtomicTransactionComposer
to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
atc | AtomicTransactionComposer | The AtomicTransactionComposer to build transactions from and add to the group |
Returns
The composer so you can chain method calls
Example
const atc = new AtomicTransactionComposer().addPayment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', amount: 1000n,});composer.addAtc(atc);
Defined in
addOfflineKeyRegistration
▸ addOfflineKeyRegistration(params
): TransactionComposer
Add an offline key registration transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | OfflineKeyRegistrationParams | The offline key registration transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addOfflineKeyRegistration({ sender: 'SENDERADDRESS',});
Example
composer.addOfflineKeyRegistration({ sender: 'SENDERADDRESS', lease: 'lease', note: 'note', // Use this with caution, it's generally better to use algorand.account.rekeyAccount rekeyTo: 'REKEYTOADDRESS', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addOnlineKeyRegistration
▸ addOnlineKeyRegistration(params
): TransactionComposer
Add an online key registration transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | OnlineKeyRegistrationParams | The online key registration transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addOnlineKeyRegistration({ sender: 'SENDERADDRESS', voteKey: Uint8Array.from(Buffer.from('voteKeyBase64', 'base64')), selectionKey: Uint8Array.from(Buffer.from('selectionKeyBase64', 'base64')), stateProofKey: Uint8Array.from(Buffer.from('stateProofKeyBase64', 'base64')), voteFirst: 1n, voteLast: 1000n, voteKeyDilution: 1n,});
Example
composer.addOnlineKeyRegistration({ sender: 'SENDERADDRESS', voteKey: Uint8Array.from(Buffer.from('voteKeyBase64', 'base64')), selectionKey: Uint8Array.from(Buffer.from('selectionKeyBase64', 'base64')), stateProofKey: Uint8Array.from(Buffer.from('stateProofKeyBase64', 'base64')), voteFirst: 1n, voteLast: 1000n, voteKeyDilution: 1n, lease: 'lease', note: 'note', // Use this with caution, it's generally better to use algorand.account.rekeyAccount rekeyTo: 'REKEYTOADDRESS', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),});
Defined in
addPayment
▸ addPayment(params
): TransactionComposer
Add a payment transaction to the transaction group.
Parameters
Name | Type | Description |
---|---|---|
params | PaymentParams | The payment transaction parameters |
Returns
The composer so you can chain method calls
Example
composer.addPayment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', amount: (4).algo(),});
Example
composer.addPayment({ amount: (4).algo(), receiver: 'RECEIVERADDRESS', sender: 'SENDERADDRESS', closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', lease: 'lease', note: 'note', // Use this with caution, it's generally better to use algorand.account.rekeyAccount rekeyTo: 'REKEYTOADDRESS', // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, extraFee: (1000).microAlgo(), staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness maxFee: (3000).microAlgo(),})
#### Defined in
[src/types/composer.ts:682](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L682)
___
### addTransaction
▸ **addTransaction**(`transaction`, `signer?`): [`TransactionComposer`](types_composer.TransactionComposer.md)
Add a pre-built transaction to the transaction group.
#### Parameters
| Name | Type | Description || :------ | :------ | :------ || `transaction` | `Transaction` | The pre-built transaction || `signer?` | `TransactionSigner` | Optional signer override for the transaction |
#### Returns
[`TransactionComposer`](types_composer.TransactionComposer.md)
The composer so you can chain method calls
**`Example`**
```typescriptcomposer.addTransaction(txn)
Defined in
build
▸ build(): Promise
<{ atc
: AtomicTransactionComposer
; methodCalls
: any
; transactions
: TransactionWithSigner
[] }>
Compose all of the transactions in a single atomic transaction group and an atomic transaction composer.
You can then use the transactions standalone, or use the composer to execute or simulate the transactions.
Once this method is called, no further transactions will be able to be added. You can safely call this method multiple times to get the same result.
Returns
Promise
<{ atc
: AtomicTransactionComposer
; methodCalls
: any
; transactions
: TransactionWithSigner
[] }>
The built atomic transaction composer, the transactions and any corresponding method calls
Example
const { atc, transactions, methodCalls } = await composer.build();
Defined in
buildAppCall
▸ buildAppCall(params
, suggestedParams
): Promise
<TransactionWithContext
>
Parameters
Name | Type |
---|---|
params | { accountReferences? : (string | Address )[] ; appReferences? : bigint [] ; approvalProgram : string | Uint8Array ; args? : Uint8Array [] ; assetReferences? : bigint [] ; boxReferences? : (BoxIdentifier | BoxReference )[] ; clearStateProgram : string | Uint8Array ; extraFee? : AlgoAmount ; extraProgramPages? : number ; firstValidRound? : bigint ; lastValidRound? : bigint ; lease? : string | Uint8Array ; maxFee? : AlgoAmount ; note? : string | Uint8Array ; onComplete? : NoOpOC | OptInOC | CloseOutOC | UpdateApplicationOC | DeleteApplicationOC ; rekeyTo? : string | Address ; schema? : { globalByteSlices : number ; globalInts : number ; localByteSlices : number ; localInts : number } ; sender : string | Address ; signer? : TransactionSigner | TransactionSignerAccount ; staticFee? : AlgoAmount ; validityWindow? : number | bigint } | { accountReferences? : (string | Address )[] ; appId : bigint ; appReferences? : bigint [] ; approvalProgram : string | Uint8Array ; args? : Uint8Array [] ; assetReferences? : bigint [] ; boxReferences? : (BoxIdentifier | BoxReference )[] ; clearStateProgram : string | Uint8Array ; extraFee? : AlgoAmount ; firstValidRound? : bigint ; lastValidRound? : bigint ; lease? : string | Uint8Array ; maxFee? : AlgoAmount ; note? : string | Uint8Array ; onComplete? : UpdateApplicationOC ; rekeyTo? : string | Address ; sender : string | Address ; signer? : TransactionSigner | TransactionSignerAccount ; staticFee? : AlgoAmount ; validityWindow? : number | bigint } | AppCallParams |
suggestedParams | SuggestedParams |
Returns
Promise
<TransactionWithContext
>
Defined in
buildAssetConfig
▸ buildAssetConfig(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | AssetConfigParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildAssetCreate
▸ buildAssetCreate(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | AssetCreateParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildAssetDestroy
▸ buildAssetDestroy(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | AssetDestroyParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildAssetFreeze
▸ buildAssetFreeze(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | AssetFreezeParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildAssetTransfer
▸ buildAssetTransfer(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | AssetTransferParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildAtc
▸ buildAtc(atc
): TransactionWithSignerAndContext
[]
Build an ATC and return transactions ready to be incorporated into a broader set of transactions this composer is composing
Parameters
Name | Type |
---|---|
atc | AtomicTransactionComposer |
Returns
TransactionWithSignerAndContext
[]
Defined in
buildKeyReg
▸ buildKeyReg(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | OnlineKeyRegistrationParams | OfflineKeyRegistrationParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildMethodCall
▸ buildMethodCall(params
, suggestedParams
, includeSigner
): Promise
<TransactionWithSignerAndContext
[]>
Builds an ABI method call transaction and any other associated transactions represented in the ABI args.
Parameters
Name | Type | Description |
---|---|---|
params | AppCreateMethodCall | AppUpdateMethodCall | AppCallMethodCall | - |
suggestedParams | SuggestedParams | - |
includeSigner | boolean | Whether to include the actual signer for the transactions. If you are just building transactions without signers yet then set this to false . |
Returns
Promise
<TransactionWithSignerAndContext
[]>
Defined in
buildPayment
▸ buildPayment(params
, suggestedParams
): TransactionWithContext
Parameters
Name | Type |
---|---|
params | PaymentParams |
suggestedParams | SuggestedParams |
Returns
TransactionWithContext
Defined in
buildTransactions
▸ buildTransactions(): Promise
<BuiltTransactions
>
Compose all of the transactions without signers and return the transaction objects directly along with any ABI method calls.
Returns
Promise
<BuiltTransactions
>
The array of built transactions and any corresponding method calls
Example
const { transactions, methodCalls, signers } = await composer.buildTransactions();
Defined in
buildTxn
▸ buildTxn(txn
, suggestedParams
): Promise
<TransactionWithContext
[]>
Builds all transaction types apart from txnWithSigner
, atc
and methodCall
since those ones can have custom signers that need to be retrieved.
Parameters
Name | Type |
---|---|
txn | Txn |
suggestedParams | SuggestedParams |
Returns
Promise
<TransactionWithContext
[]>
Defined in
buildTxnWithSigner
▸ buildTxnWithSigner(txn
, suggestedParams
): Promise
<TransactionWithSignerAndContext
[]>
Parameters
Name | Type |
---|---|
txn | Txn |
suggestedParams | SuggestedParams |
Returns
Promise
<TransactionWithSignerAndContext
[]>
Defined in
commonTxnBuildStep
▸ commonTxnBuildStep<TParams
>(buildTxn
, params
, txnParams
): TransactionWithContext
Type parameters
Name | Type |
---|---|
TParams | extends CommonTransactionParams |
Parameters
Name | Type |
---|---|
buildTxn | (params : TParams ) => Transaction |
params | CommonTransactionParams |
txnParams | TParams |
Returns
TransactionWithContext
Defined in
count
▸ count(): Promise
<number
>
Get the number of transactions currently added to this composer.
Returns
Promise
<number
>
The number of transactions currently added to this composer
Defined in
execute
▸ execute(params?
): Promise
<SendAtomicTransactionComposerResults
>
Parameters
Name | Type | Description |
---|---|---|
params? | SendParams | The parameters to control execution with |
Returns
Promise
<SendAtomicTransactionComposerResults
>
The execution result
Deprecated
Use send
instead.
Compose the atomic transaction group and send it to the network
An alias for composer.send(params)
.
Defined in
rebuild
▸ rebuild(): Promise
<{ atc
: AtomicTransactionComposer
; methodCalls
: any
; transactions
: TransactionWithSigner
[] }>
Rebuild the group, discarding any previously built transactions. This will potentially cause new signers and suggested params to be used if the callbacks return a new value compared to the first build.
Returns
Promise
<{ atc
: AtomicTransactionComposer
; methodCalls
: any
; transactions
: TransactionWithSigner
[] }>
The newly built atomic transaction composer and the transactions
Example
const { atc, transactions, methodCalls } = await composer.rebuild();
Defined in
registerErrorTransformer
▸ registerErrorTransformer(transformer
): TransactionComposer
Register a function that will be used to transform an error caught when simulating or executing
Parameters
Name | Type |
---|---|
transformer | ErrorTransformer |
Returns
The composer so you can chain method calls
Defined in
send
▸ send(params?
): Promise
<SendAtomicTransactionComposerResults
>
Compose the atomic transaction group and send it to the network.
Parameters
Name | Type | Description |
---|---|---|
params? | SendParams | The parameters to control execution with |
Returns
Promise
<SendAtomicTransactionComposerResults
>
The execution result
Example
const result = await composer.send();
Defined in
simulate
▸ simulate(): Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
Compose the atomic transaction group and simulate sending it to the network
Returns
Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
The simulation result
Example
const result = await composer.simulate();
Defined in
▸ simulate(options
): Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
Compose the atomic transaction group and simulate sending it to the network
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.allowMoreLogging? | boolean | - |
options.allowUnnamedResources? | boolean | - |
options.execTraceConfig? | SimulateTraceConfig | - |
options.extraOpcodeBudget? | number | bigint | - |
options.round? | number | bigint | - |
options.skipSignatures | boolean | Whether or not to skip signatures for all built transactions and use an empty signer instead. This will set fixSigners and allowEmptySignatures when sending the request to the algod API. |
Returns
Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
The simulation result
Example
const result = await composer.simulate({ skipSignatures: true,});
Defined in
▸ simulate(options
): Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
Compose the atomic transaction group and simulate sending it to the network
Parameters
Name | Type |
---|---|
options | Object |
options.allowEmptySignatures? | boolean |
options.allowMoreLogging? | boolean |
options.allowUnnamedResources? | boolean |
options.execTraceConfig? | SimulateTraceConfig |
options.extraOpcodeBudget? | number | bigint |
options.fixSigners? | boolean |
options.round? | number | bigint |
Returns
Promise
<SendAtomicTransactionComposerResults
& { simulateResponse
: SimulateResponse
}>
The simulation result
Example
const result = await composer.simulate({ extraOpcodeBudget: 1000,});
Defined in
transformError
▸ transformError(originalError
): Promise
<unknown
>
Parameters
Name | Type |
---|---|
originalError | unknown |
Returns
Promise
<unknown
>
Defined in
arc2Note
▸ arc2Note(note
): Uint8Array
Create an encoded transaction note that follows the ARC-2 spec.
https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
Parameters
Name | Type | Description |
---|---|---|
note | Arc2TransactionNote | The ARC-2 transaction note data |
Returns
Uint8Array
The binary encoded transaction note