AssetManager
@algorandfoundation/algokit-utils / types/asset-manager / AssetManager
types/asset-manager.AssetManager
Allows management of asset information.
Table of contents
Section titled “Table of contents”Constructors
Section titled “Constructors”Properties
Section titled “Properties”Methods
Section titled “Methods”Constructors
Section titled “Constructors”constructor
Section titled “constructor”• new AssetManager(algod, newGroup): AssetManager
Create a new asset manager.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
algod | AlgodClient | An algod client |
newGroup | () => TransactionComposer | A function that creates a new TransactionComposer transaction group |
Returns
Section titled “Returns”Example
const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))Defined in
Section titled “Defined in”src/types/asset-manager.ts:151
Properties
Section titled “Properties”_algod
Section titled “_algod”• Private _algod: AlgodClient
Defined in
Section titled “Defined in”src/types/asset-manager.ts:139
_newGroup
Section titled “_newGroup”• Private _newGroup: () => TransactionComposer
Type declaration
Section titled “Type declaration”▸ (): TransactionComposer
Returns
Section titled “Returns”Defined in
Section titled “Defined in”src/types/asset-manager.ts:140
Methods
Section titled “Methods”bulkOptIn
Section titled “bulkOptIn”▸ bulkOptIn(account, assetIds, options?): Promise<BulkAssetOptInOutResult[]>
Opt an account in to a list of Algorand Standard Assets.
Transactions will be sent in batches of 16 as transaction groups.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
account | string | Address | The account to opt-in |
assetIds | bigint[] | The list of asset IDs to opt-in to |
options? | Omit<CommonTransactionParams, "sender"> & SendParams | Any parameters to control the transaction or execution of the transaction |
Returns
Section titled “Returns”Promise<BulkAssetOptInOutResult[]>
An array of records matching asset ID to transaction ID of the opt in
Example
// Basic exampleassetManager.bulkOptIn('ACCOUNTADDRESS', [12345n, 67890n]);// With configurationassetManager.bulkOptIn('ACCOUNTADDRESS', [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true,});Defined in
Section titled “Defined in”src/types/asset-manager.ts:233
bulkOptOut
Section titled “bulkOptOut”▸ bulkOptOut(account, assetIds, options?): Promise<BulkAssetOptInOutResult[]>
Opt an account out of a list of Algorand Standard Assets.
Transactions will be sent in batches of 16 as transaction groups.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
account | string | Address | The account to opt-in |
assetIds | bigint[] | The list of asset IDs to opt-out of |
options? | Omit<CommonTransactionParams, "sender"> & SendParams & { ensureZeroBalance?: boolean } | Any parameters to control the transaction or execution of the transaction |
Returns
Section titled “Returns”Promise<BulkAssetOptInOutResult[]>
An array of records matching asset ID to transaction ID of the opt in
Example
// Basic exampleassetManager.bulkOptOut('ACCOUNTADDRESS', [12345n, 67890n]);// With configurationassetManager.bulkOptOut('ACCOUNTADDRESS', [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true,});Defined in
Section titled “Defined in”src/types/asset-manager.ts:283
getAccountInformation
Section titled “getAccountInformation”▸ getAccountInformation(sender, assetId): Promise<AccountAssetInformation>
Returns the given sender account’s asset holding for a given asset.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
sender | string | Address | The address of the sender/account to look up |
assetId | bigint | The ID of the asset to return a holding for |
Returns
Section titled “Returns”Promise<AccountAssetInformation>
The account asset holding information
Example
const address = 'XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA';const assetId = 123345n;const accountInfo = await assetManager.getAccountInformation(address, assetId);Defined in
Section titled “Defined in”src/types/asset-manager.ts:205
getById
Section titled “getById”▸ getById(assetId): Promise<AssetInformation>
Returns the current asset information for the asset with the given ID.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
assetId | bigint | The ID of the asset |
Returns
Section titled “Returns”Promise<AssetInformation>
The asset information
Example
const assetInfo = await assetManager.getById(12353n);