Skip to content

TransactionComposer

@algorandfoundation/algokit-utils / types/composer / TransactionComposer

types/composer.TransactionComposer

TransactionComposer helps you compose and execute transactions as a transaction group.

new TransactionComposer(params): TransactionComposer

Create a TransactionComposer.

NameTypeDescription
paramsTransactionComposerParamsThe configuration for this composer

TransactionComposer

The TransactionComposer instance

src/types/composer.ts:608

Private algod: AlgodClient

The algod client used by the composer.

src/types/composer.ts:563


Private appManager: AppManager

src/types/composer.ts:577


Private atc: AtomicTransactionComposer

The ATC used to compose the group

src/types/composer.ts:552


Private defaultValidityWindow: bigint

The default transaction validity window

src/types/composer.ts:572


Private defaultValidityWindowIsExplicit: boolean = false

Whether the validity window was explicitly set on construction

src/types/composer.ts:575


Private errorTransformers: ErrorTransformer[]

src/types/composer.ts:579


Private getSigner: (address: string | Address) => TransactionSigner

A function that takes in an address and return a signer function for that address.

▸ (address): TransactionSigner

NameType
addressstring | Address

TransactionSigner

src/types/composer.ts:569


Private getSuggestedParams: () => Promise<SuggestedParams>

An async function that will return suggested params for the transaction.

▸ (): Promise<SuggestedParams>

Promise<SuggestedParams>

src/types/composer.ts:566


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.

src/types/composer.ts:557


Private txns: Txn[] = []

Transactions that have not yet been composed

src/types/composer.ts:560


Static Private NULL_SIGNER: TransactionSigner

Signer used to represent a lack of signer

src/types/composer.ts:549

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.

NameTypeDescription
paramsAppCallParamsThe application call transaction parameters

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(),
})

src/types/composer.ts:1106


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.

NameTypeDescription
paramsAppCallMethodCallThe ABI method application call transaction parameters

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(),
})

src/types/composer.ts:1318


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.

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.

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,
})

src/types/composer.ts:985


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.

NameTypeDescription
paramsAppCreateMethodCallThe ABI create method application call transaction parameters

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(),
})

src/types/composer.ts:1166


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.

NameTypeDescription
paramsAppDeleteParamsThe application delete transaction parameters

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(),
})

src/types/composer.ts:1065


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.

NameTypeDescription
paramsAppDeleteMethodCallThe ABI delete method application call transaction parameters

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(),
})

src/types/composer.ts:1268


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.

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.

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(),
})

src/types/composer.ts:1026


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.

NameTypeDescription
paramsAppUpdateMethodCallThe ABI update method application call transaction parameters

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(),
})

src/types/composer.ts:1218


addAssetConfig(params): TransactionComposer

Add an asset config transaction to the transaction group.

NameTypeDescription
paramsAssetConfigParamsThe asset config transaction parameters

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(),
});

src/types/composer.ts:824


addAssetFreeze(params): TransactionComposer

Add an asset freeze transaction to the transaction group.

NameTypeDescription
paramsAssetFreezeParamsThe asset freeze transaction parameters

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(),
});

src/types/composer.ts:792


addAssetOptIn(params): TransactionComposer

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

NameTypeDescription
paramsAssetOptInParamsThe asset opt-in transaction parameters

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(),
});

src/types/composer.ts:893


addAssetOptOut(params): TransactionComposer

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

NameTypeDescription
paramsAssetOptOutParamsThe asset opt-out transaction parameters

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(),
});

src/types/composer.ts:931


addAssetTransfer(params): TransactionComposer

Add an asset transfer transaction to the transaction group.

NameTypeDescription
paramsAssetTransferParamsThe asset transfer transaction parameters

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(),
})

src/types/composer.ts:861


addAtc(atc): TransactionComposer

Add the transactions within an AtomicTransactionComposer to the transaction group.

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

TransactionComposer

The composer so you can chain method calls

Example

const atc = new AtomicTransactionComposer().addPayment({
sender: 'SENDERADDRESS',
receiver: 'RECEIVERADDRESS',
amount: 1000n,
});
composer.addAtc(atc);

src/types/composer.ts:1416


addOfflineKeyRegistration(params): TransactionComposer

Add an offline key registration transaction to the transaction group.

NameTypeDescription
paramsOfflineKeyRegistrationParamsThe offline key registration transaction parameters

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(),
});

src/types/composer.ts:1399


addOnlineKeyRegistration(params): TransactionComposer

Add an online key registration transaction to the transaction group.

NameTypeDescription
paramsOnlineKeyRegistrationParamsThe online key registration transaction parameters

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(),
});

src/types/composer.ts:1364


addPayment(params): TransactionComposer

Add a payment transaction to the transaction group.

NameTypeDescription
paramsPaymentParamsThe payment transaction parameters

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)

src/types/composer.ts:639


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.

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();

src/types/composer.ts:1946


buildAppCall(params, suggestedParams): Promise<TransactionWithContext>

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

Promise<TransactionWithContext>

src/types/composer.ts:1755


buildAssetConfig(params, suggestedParams): TransactionWithContext

NameType
paramsAssetConfigParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1712


buildAssetCreate(params, suggestedParams): TransactionWithContext

NameType
paramsAssetCreateParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1694


buildAssetDestroy(params, suggestedParams): TransactionWithContext

NameType
paramsAssetDestroyParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1725


buildAssetFreeze(params, suggestedParams): TransactionWithContext

NameType
paramsAssetFreezeParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1733


buildAssetTransfer(params, suggestedParams): TransactionWithContext

NameType
paramsAssetTransferParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1743


buildAtc(atc): TransactionWithSignerAndContext[]

Build an ATC and return transactions ready to be incorporated into a broader set of transactions this composer is composing

NameType
atcAtomicTransactionComposer

TransactionWithSignerAndContext[]

src/types/composer.ts:1422


buildKeyReg(params, suggestedParams): TransactionWithContext

NameType
paramsOnlineKeyRegistrationParams | OfflineKeyRegistrationParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1806


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

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

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.

Promise<TransactionWithSignerAndContext[]>

src/types/composer.ts:1502


buildPayment(params, suggestedParams): TransactionWithContext

NameType
paramsPaymentParams
suggestedParamsSuggestedParams

TransactionWithContext

src/types/composer.ts:1684


buildTransactions(): Promise<BuiltTransactions>

Compose all of the transactions without signers and return the transaction objects directly along with any ABI method calls.

Promise<BuiltTransactions>

The array of built transactions and any corresponding method calls

Example

const { transactions, methodCalls, signers } = await composer.buildTransactions();

src/types/composer.ts:1888


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.

NameType
txnTxn
suggestedParamsSuggestedParams

Promise<TransactionWithContext[]>

src/types/composer.ts:1829


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

NameType
txnTxn
suggestedParamsSuggestedParams

Promise<TransactionWithSignerAndContext[]>

src/types/composer.ts:1856


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

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

TransactionWithContext

src/types/composer.ts:1444


count(): Promise<number>

Get the number of transactions currently added to this composer.

Promise<number>

The number of transactions currently added to this composer

src/types/composer.ts:1929


execute(params?): Promise<SendAtomicTransactionComposerResults>

NameTypeDescription
params?SendParamsThe parameters to control execution with

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).

src/types/composer.ts:2044


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.

Promise<{ atc: AtomicTransactionComposer ; methodCalls: any ; transactions: TransactionWithSigner[] }>

The newly built atomic transaction composer and the transactions

Example

const { atc, transactions, methodCalls } = await composer.rebuild();

src/types/composer.ts:1985


registerErrorTransformer(transformer): TransactionComposer

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

NameType
transformerErrorTransformer

TransactionComposer

The composer so you can chain method calls

src/types/composer.ts:624


send(params?): Promise<SendAtomicTransactionComposerResults>

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

NameTypeDescription
params?SendParamsThe parameters to control execution with

Promise<SendAtomicTransactionComposerResults>

The execution result

Example

const result = await composer.send();

src/types/composer.ts:1999


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

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

Promise<SendAtomicTransactionComposerResults & { simulateResponse: SimulateResponse }>

The simulation result

Example

const result = await composer.simulate();

src/types/composer.ts:2056

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

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

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.

Promise<SendAtomicTransactionComposerResults & { simulateResponse: SimulateResponse }>

The simulation result

Example

const result = await composer.simulate({
skipSignatures: true,
});

src/types/composer.ts:2067

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

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

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

Promise<SendAtomicTransactionComposerResults & { simulateResponse: SimulateResponse }>

The simulation result

Example

const result = await composer.simulate({
extraOpcodeBudget: 1000,
});

src/types/composer.ts:2080


transformError(originalError): Promise<unknown>

NameType
originalErrorunknown

Promise<unknown>

src/types/composer.ts:581


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

NameTypeDescription
noteArc2TransactionNoteThe ARC-2 transaction note data

Uint8Array

The binary encoded transaction note

src/types/composer.ts:2156