Skip to content

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

Methods

Constructors

constructor

new TransactionComposer(params): TransactionComposer

Create a TransactionComposer.

Parameters

NameTypeDescription
paramsTransactionComposerParamsThe configuration for this composer

Returns

TransactionComposer

The TransactionComposer instance

Defined in

src/types/composer.ts:608

Properties

algod

Private algod: AlgodClient

The algod client used by the composer.

Defined in

src/types/composer.ts:563


appManager

Private appManager: AppManager

Defined in

src/types/composer.ts:577


atc

Private atc: AtomicTransactionComposer

The ATC used to compose the group

Defined in

src/types/composer.ts:552


defaultValidityWindow

Private defaultValidityWindow: bigint

The default transaction validity window

Defined in

src/types/composer.ts:572


defaultValidityWindowIsExplicit

Private defaultValidityWindowIsExplicit: boolean = false

Whether the validity window was explicitly set on construction

Defined in

src/types/composer.ts:575


errorTransformers

Private errorTransformers: ErrorTransformer[]

Defined in

src/types/composer.ts:579


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
NameType
addressstring | Address
Returns

TransactionSigner

Defined in

src/types/composer.ts:569


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

src/types/composer.ts:566


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

src/types/composer.ts:557


txns

Private txns: Txn[] = []

Transactions that have not yet been composed

Defined in

src/types/composer.ts:560


NULL_SIGNER

Static Private NULL_SIGNER: TransactionSigner

Signer used to represent a lack of signer

Defined in

src/types/composer.ts:549

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

NameTypeDescription
paramsAppCallParamsThe application call transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1106


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

NameTypeDescription
paramsAppCallMethodCallThe ABI method application call transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1318


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

NameTypeDescription
paramsObjectThe 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.approvalProgramstring | Uint8ArrayThe 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.clearStateProgramstring | Uint8ArrayThe 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?AlgoAmountThe fee to pay IN ADDITION to the suggested fee. Useful for manually covering inner transaction fees.
params.extraProgramPages?numberNumber 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?bigintSet 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?bigintThe last round this transaction is valid. It is recommended to use validityWindow instead.
params.lease?string | Uint8ArrayPrevent 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?AlgoAmountThrow an error if the fee for the transaction is more than this amount; prevents overspending on fees during high congestion periods.
params.note?string | Uint8ArrayNote to attach to the transaction. Max of 1000 bytes.
params.onComplete?NoOpOC | OptInOC | CloseOutOC | UpdateApplicationOC | DeleteApplicationOCThe on-complete action of the call; defaults to no-op.
params.rekeyTo?string | AddressChange 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?ObjectThe state schema for the app. This is immutable once the app is created.
params.schema.globalByteSlicesnumberThe number of byte slices saved in global state.
params.schema.globalIntsnumberThe number of integers saved in global state.
params.schema.localByteSlicesnumberThe number of byte slices saved in local state.
params.schema.localIntsnumberThe number of integers saved in local state.
params.senderstring | AddressThe address of the account sending the transaction.
params.signer?TransactionSigner | TransactionSignerAccountThe 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?AlgoAmountThe 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 | bigintHow many rounds the transaction should be valid for, if not specified then the registered default validity window will be used.

Returns

TransactionComposer

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

src/types/composer.ts:985


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

NameTypeDescription
paramsAppCreateMethodCallThe ABI create method application call transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1166


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

NameTypeDescription
paramsAppDeleteParamsThe application delete transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1065


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

NameTypeDescription
paramsAppDeleteMethodCallThe ABI delete method application call transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1268


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

NameTypeDescription
paramsObjectThe application update transaction parameters
params.accountReferences?(string | Address)[]Any account addresses to add to the accounts array.
params.appIdbigintID 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.approvalProgramstring | Uint8ArrayThe 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.clearStateProgramstring | Uint8ArrayThe program to execute for ClearState OnComplete as raw teal (string) or compiled teal (base 64 encoded as a byte array (Uint8Array))
params.extraFee?AlgoAmountThe fee to pay IN ADDITION to the suggested fee. Useful for manually covering inner transaction fees.
params.firstValidRound?bigintSet 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?bigintThe last round this transaction is valid. It is recommended to use validityWindow instead.
params.lease?string | Uint8ArrayPrevent 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?AlgoAmountThrow an error if the fee for the transaction is more than this amount; prevents overspending on fees during high congestion periods.
params.note?string | Uint8ArrayNote to attach to the transaction. Max of 1000 bytes.
params.onComplete?UpdateApplicationOCThe on-complete action of the call; defaults to no-op.
params.rekeyTo?string | AddressChange 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.senderstring | AddressThe address of the account sending the transaction.
params.signer?TransactionSigner | TransactionSignerAccountThe 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?AlgoAmountThe 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 | bigintHow many rounds the transaction should be valid for, if not specified then the registered default validity window will be used.

Returns

TransactionComposer

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

src/types/composer.ts:1026


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

NameTypeDescription
paramsAppUpdateMethodCallThe ABI update method application call transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1218


addAssetConfig

addAssetConfig(params): TransactionComposer

Add an asset config transaction to the transaction group.

Parameters

NameTypeDescription
paramsAssetConfigParamsThe asset config transaction parameters

Returns

TransactionComposer

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`**
```typescript
composer.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`**
```typescript
composer.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

src/types/composer.ts:824


addAssetFreeze

addAssetFreeze(params): TransactionComposer

Add an asset freeze transaction to the transaction group.

Parameters

NameTypeDescription
paramsAssetFreezeParamsThe asset freeze transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:792


addAssetOptIn

addAssetOptIn(params): TransactionComposer

Add an asset opt-in transaction to the transaction group.

Parameters

NameTypeDescription
paramsAssetOptInParamsThe asset opt-in transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:893


addAssetOptOut

addAssetOptOut(params): TransactionComposer

Add an asset opt-out transaction to the transaction group.

Parameters

NameTypeDescription
paramsAssetOptOutParamsThe asset opt-out transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:931


addAssetTransfer

addAssetTransfer(params): TransactionComposer

Add an asset transfer transaction to the transaction group.

Parameters

NameTypeDescription
paramsAssetTransferParamsThe asset transfer transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:861


addAtc

addAtc(atc): TransactionComposer

Add the transactions within an AtomicTransactionComposer to the transaction group.

Parameters

NameTypeDescription
atcAtomicTransactionComposerThe AtomicTransactionComposer to build transactions from and add to the group

Returns

TransactionComposer

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

src/types/composer.ts:1416


addOfflineKeyRegistration

addOfflineKeyRegistration(params): TransactionComposer

Add an offline key registration transaction to the transaction group.

Parameters

NameTypeDescription
paramsOfflineKeyRegistrationParamsThe offline key registration transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1399


addOnlineKeyRegistration

addOnlineKeyRegistration(params): TransactionComposer

Add an online key registration transaction to the transaction group.

Parameters

NameTypeDescription
paramsOnlineKeyRegistrationParamsThe online key registration transaction parameters

Returns

TransactionComposer

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

src/types/composer.ts:1364


addPayment

addPayment(params): TransactionComposer

Add a payment transaction to the transaction group.

Parameters

NameTypeDescription
paramsPaymentParamsThe payment transaction parameters

Returns

TransactionComposer

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`**
```typescript
composer.addTransaction(txn)

Defined in

src/types/composer.ts:639


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

src/types/composer.ts:1946


buildAppCall

buildAppCall(params, suggestedParams): Promise<TransactionWithContext>

Parameters

NameType
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
suggestedParamsSuggestedParams

Returns

Promise<TransactionWithContext>

Defined in

src/types/composer.ts:1755


buildAssetConfig

buildAssetConfig(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsAssetConfigParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1712


buildAssetCreate

buildAssetCreate(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsAssetCreateParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1694


buildAssetDestroy

buildAssetDestroy(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsAssetDestroyParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1725


buildAssetFreeze

buildAssetFreeze(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsAssetFreezeParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1733


buildAssetTransfer

buildAssetTransfer(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsAssetTransferParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1743


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

NameType
atcAtomicTransactionComposer

Returns

TransactionWithSignerAndContext[]

Defined in

src/types/composer.ts:1422


buildKeyReg

buildKeyReg(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsOnlineKeyRegistrationParams | OfflineKeyRegistrationParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1806


buildMethodCall

buildMethodCall(params, suggestedParams, includeSigner): Promise<TransactionWithSignerAndContext[]>

Builds an ABI method call transaction and any other associated transactions represented in the ABI args.

Parameters

NameTypeDescription
paramsAppCreateMethodCall | AppUpdateMethodCall | AppCallMethodCall-
suggestedParamsSuggestedParams-
includeSignerbooleanWhether 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

src/types/composer.ts:1502


buildPayment

buildPayment(params, suggestedParams): TransactionWithContext

Parameters

NameType
paramsPaymentParams
suggestedParamsSuggestedParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1684


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

src/types/composer.ts:1888


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

NameType
txnTxn
suggestedParamsSuggestedParams

Returns

Promise<TransactionWithContext[]>

Defined in

src/types/composer.ts:1829


buildTxnWithSigner

buildTxnWithSigner(txn, suggestedParams): Promise<TransactionWithSignerAndContext[]>

Parameters

NameType
txnTxn
suggestedParamsSuggestedParams

Returns

Promise<TransactionWithSignerAndContext[]>

Defined in

src/types/composer.ts:1856


commonTxnBuildStep

commonTxnBuildStep<TParams>(buildTxn, params, txnParams): TransactionWithContext

Type parameters

NameType
TParamsextends CommonTransactionParams

Parameters

NameType
buildTxn(params: TParams) => Transaction
paramsCommonTransactionParams
txnParamsTParams

Returns

TransactionWithContext

Defined in

src/types/composer.ts:1444


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

src/types/composer.ts:1929


execute

execute(params?): Promise<SendAtomicTransactionComposerResults>

Parameters

NameTypeDescription
params?SendParamsThe 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

src/types/composer.ts:2044


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

src/types/composer.ts:1985


registerErrorTransformer

registerErrorTransformer(transformer): TransactionComposer

Register a function that will be used to transform an error caught when simulating or executing

Parameters

NameType
transformerErrorTransformer

Returns

TransactionComposer

The composer so you can chain method calls

Defined in

src/types/composer.ts:624


send

send(params?): Promise<SendAtomicTransactionComposerResults>

Compose the atomic transaction group and send it to the network.

Parameters

NameTypeDescription
params?SendParamsThe parameters to control execution with

Returns

Promise<SendAtomicTransactionComposerResults>

The execution result

Example

const result = await composer.send();

Defined in

src/types/composer.ts:1999


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

src/types/composer.ts:2056

simulate(options): Promise<SendAtomicTransactionComposerResults & { simulateResponse: SimulateResponse }>

Compose the atomic transaction group and simulate sending it to the network

Parameters

NameTypeDescription
optionsObject-
options.allowMoreLogging?boolean-
options.allowUnnamedResources?boolean-
options.execTraceConfig?SimulateTraceConfig-
options.extraOpcodeBudget?number | bigint-
options.round?number | bigint-
options.skipSignaturesbooleanWhether 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

src/types/composer.ts:2067

simulate(options): Promise<SendAtomicTransactionComposerResults & { simulateResponse: SimulateResponse }>

Compose the atomic transaction group and simulate sending it to the network

Parameters

NameType
optionsObject
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

src/types/composer.ts:2080


transformError

transformError(originalError): Promise<unknown>

Parameters

NameType
originalErrorunknown

Returns

Promise<unknown>

Defined in

src/types/composer.ts:581


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

NameTypeDescription
noteArc2TransactionNoteThe ARC-2 transaction note data

Returns

Uint8Array

The binary encoded transaction note

Defined in

src/types/composer.ts:2156