Modular imports
AlgoKit Utils is designed with a modular architecture that allows you to import only the functionality you need. This enables better tree-shaking and smaller bundle sizes for your applications.
Package architecture
Section titled “Package architecture”The library is organized into several subpath exports, each containing related functionality:
| Subpath | Purpose | Key Exports |
|---|---|---|
/transact | Transaction primitives | Transaction, TransactionSigner, OnApplicationComplete, LogicSigAccount, MultisigAccount, BoxReference |
/abi | ABI utilities | ABIMethod, ABIType, ABIStringType, ABIValue, Arc56 contract utilities |
/algod-client | Algod API types | AlgodClient, PendingTransactionResponse, and other Algod models |
/indexer-client | Indexer API types | IndexerClient, response types like TransactionResponse, AccountResponse |
/kmd-client | KMD API types | KmdClient, wallet types |
/common | Shared utilities | Address class, encoding/decoding codecs |
/testing | Test utilities | algorandFixture, algoKitLogCaptureFixture, TestLogger |
Using modular imports
Section titled “Using modular imports”Main export vs subpath imports
Section titled “Main export vs subpath imports”For most use cases, you can import from the main package:
import { AlgorandClient, algo, microAlgo } from '@algorandfoundation/algokit-utils'For specific types or when optimizing bundle size, use subpath imports:
// Transaction typesimport { Transaction, TransactionSigner, OnApplicationComplete } from '@algorandfoundation/algokit-utils/transact'
// ABI utilitiesimport { ABIMethod, ABIType, ABIStringType } from '@algorandfoundation/algokit-utils/abi'
// API client typesimport { PendingTransactionResponse } from '@algorandfoundation/algokit-utils/algod-client'import { TransactionResponse, AccountResponse } from '@algorandfoundation/algokit-utils/indexer-client'
// Testing utilitiesimport { algorandFixture } from '@algorandfoundation/algokit-utils/testing'Type imports
Section titled “Type imports”When you only need types (not runtime values), use type-only imports:
import type { Transaction, TransactionSigner } from '@algorandfoundation/algokit-utils/transact'import type { ABIMethod } from '@algorandfoundation/algokit-utils/abi'Subpath details
Section titled “Subpath details”/transact
Section titled “/transact”Contains core transaction primitives and signing utilities:
import { // Transaction class Transaction,
// Signing TransactionSigner, AddressWithTransactionSigner, LogicSigAccount, MultisigAccount,
// App call types OnApplicationComplete, BoxReference,
// Transaction encoding/decoding encodeTransaction, decodeTransaction,} from '@algorandfoundation/algokit-utils/transact'Contains ABI (Application Binary Interface) utilities for smart contract interaction:
import { // ABI Method ABIMethod,
// ABI Types ABIType, ABIStringType, ABIUintType, ABIAddressType, ABIArrayDynamicType, ABITupleType,
// ABI Values ABIValue,
// Arc56 utilities Arc56Contract, getBoxABIStorageKey, getGlobalABIStorageKey,} from '@algorandfoundation/algokit-utils/abi'/algod-client
Section titled “/algod-client”Contains autogenerated types from the Algod API specification:
import { AlgodClient, PendingTransactionResponse, // ... other Algod API types} from '@algorandfoundation/algokit-utils/algod-client'/indexer-client
Section titled “/indexer-client”Contains autogenerated types from the Indexer API specification:
import { IndexerClient, TransactionResponse, TransactionsResponse, AccountResponse, ApplicationResponse, AssetResponse, // ... other Indexer API types} from '@algorandfoundation/algokit-utils/indexer-client'/testing
Section titled “/testing”Contains testing utilities for automated tests:
import { algorandFixture, algoKitLogCaptureFixture, getTestAccount, runWhenIndexerCaughtUp,} from '@algorandfoundation/algokit-utils/testing'Tree-shaking benefits
Section titled “Tree-shaking benefits”Using modular imports helps bundlers (like webpack, esbuild, or rollup) eliminate unused code from your final bundle. For example, if you only need transaction types:
// This imports only what you needimport { Transaction } from '@algorandfoundation/algokit-utils/transact'
// Instead of importing everythingimport { Transaction } from '@algorandfoundation/algokit-utils'When to use modular imports
Section titled “When to use modular imports”Use the main export when:
- You’re using
AlgorandClientas your primary interface - Bundle size isn’t a critical concern
- You need multiple related features
Use subpath imports when:
- You need specific types for type annotations
- You’re building a library that should have minimal dependencies
- You want to optimize bundle size
- You’re working with lower-level APIs directly