@d13co/dt-algokit-utils
v9.2.3-dt.5.2.0.0
Published
Fork of @algorandfoundation/algokit-utils with dtalgod support: reads at past rounds, object versions and history, asset holders, extended simulate and read-only TEAL queries.
Maintainers
Readme
dt-algokit-utils
@d13co/dt-algokit-utilsis a fork of@algorandfoundation/algokit-utilsthat adds support for dtalgod, an algod with time travel and extended simulate. The upstream README follows below.
It is a drop-in replacement: existing APIs, types and generated typed clients work unchanged, and on stock algosdk or a stock algod everything behaves as upstream while the new features throw, except for a few changes to existing methods, such as state.box.getMap reading a map in one listing and retries honouring Retry-After: see the changed methods.
Main changes
- Reads at a past round:
{ round }on account, asset, app, global/local state and box reads returns the state as of the end of that round. - App clients pinned to a round:
appClient.atRound(round)reads state and simulates readonly ABI calls at that round, for generated typed clients too. - Versions:
algorand.dtlists the rounds at which a box, an app's boxes, an app, an asset or an account changed, with the values if asked, by page or as an async iterator; as of a list ofrounds, with the changed state keys, or only the changes of one statekeyor box nameprefix. - Asset holders:
algorand.dt.getAssetHolders/iterateAssetHolderslist an asset's holders at a round. - Box listings:
algorand.app.getBoxeslists boxes under a prefix with their values in one paged listing;state.box.getMapuses it. - Extended simulate:
algorand.simulate.groupssimulates several groups in one request, or each on its own withparallel, andalgorand.simulate.roundssimulates groups at many rounds, a request per round. - Node limits: simulate follows the limits dtalgod reports, and readonly app calls get the node's full extra opcode budget.
- Queries:
algorand.query.runruns read-only TEAL calls of a program or app at many rounds (POST /v2/query), optionally under a later consensus protocol, split within the node's limits;algorand.query.groups/roundsquery composed app calls, with simulate as the fallback. - Retries: the clients algokit-utils makes retry by dt-algosdk's retry policy (rate limits, busy nodes,
Retry-After, no blind resubmits of transactions), changed per client or globally withretry, with an event for each wait. - Abort signals:
signalon app reads, version pages, simulate and queries cancels the request and its retries.
See the full list of differences for every changed method, examples and caveats.
Installing the fork
The new features also need dt-algosdk, the matching fork of algosdk, and a node on the current dt-algorand release (dt5, v5.0.5-dt5); older dtalgod releases are not supported. Install both under their upstream names and override them across your whole dependency tree, so your code, generated typed clients and other libraries (e.g. algokit-subscriber) all load the same copy. Imports stay @algorandfoundation/algokit-utils and algosdk.
npm (package.json; each override must equal the dependency spec):
{
"dependencies": {
"@algorandfoundation/algokit-utils": "npm:@d13co/[email protected]",
"algosdk": "npm:[email protected]"
},
"overrides": {
"@algorandfoundation/algokit-utils": "npm:@d13co/[email protected]",
"algosdk": "npm:[email protected]"
}
}pnpm (pnpm-workspace.yaml, or pnpm.overrides in package.json), with the same dependencies as above:
overrides:
'@algorandfoundation/algokit-utils': npm:@d13co/[email protected]
algosdk: npm:[email protected]yarn: the same entries under resolutions in package.json (yarn ignores overrides). Yarn 4 refuses versions published less than a day ago (npmMinimalAgeGate); to install a new release right away, add npmPreapprovedPackages: ["@d13co/dt-algokit-utils", "dt-algosdk"] to .yarnrc.yml. bun: the same entries under overrides.
Fork versions are prereleases (-dt.…), which ^ ranges don't match, so pin the exact versions as above. With the overrides in place, other packages' algosdk and algokit-utils peer ranges are satisfied. Don't reach for --legacy-peer-deps or --force if npm reports a peer conflict: it means an override is missing, and those flags install a second, stock copy.
Then check that only the forks are installed: npm ls algosdk @algorandfoundation/algokit-utils or pnpm why algosdk.
AlgoKit TypeScript Utilities
A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand. This project is part of AlgoKit.
The goal of this library is to provide intuitive, productive utility functions that make it easier, quicker and safer to build applications on Algorand. Largely these functions wrap the underlying Algorand SDK, but provide a higher level interface with sensible defaults and capabilities for common tasks.
Note: If you prefer Python there's an equivalent Python utility library.
Install
Before installing, you'll need to decide on the version you want to target. Version 7 and 8 have the same feature set, however v7 leverages algosdk@>=2.9.0<3.0, whereas v8 leverages algosdk@>=3.0.0. Your project and it's dependencies will help you decide which version to target.
Once you've decided on the target version, this library can be installed from NPM using your favourite npm client, e.g.:
To target algosdk@2 and use version 7 of AlgoKit Utils, run the below:
npm install algosdk@^2.9.0 @algorandfoundation/algokit-utils@^7.0.0To target algosdk@3 and use the latest version of AlgoKit Utils, run the below:
npm install algosdk@^3.0.0 @algorandfoundation/algokit-utilsNow you can import the library:
import { AlgorandClient, Config } from '@algorandfoundation/algokit-utils'See usage for more details.
Migration
Whilst we aim to minimise breaking changes, there are situations where they are required. JSDoc deprecations should guide you through most migration paths inside your IDE, however the migration guides will provide more detailed information should you need it.
If you're targeting v7, please refer to the v7 migration guide. If you're targeting v8, please refer to the v8 migration guide.
Guiding principles
This library follows the Guiding Principles of AlgoKit.
Contributing
This is an open source project managed by the Algorand Foundation. See the AlgoKit contributing page to learn about making improvements.
To successfully run the tests in this repository you need to be running LocalNet via AlgoKit and also have package dependencies and .env.template copied to .env (both of which algokit bootstrap all can do for you):
algokit bootstrap all
algokit localnet startTo run tests you can use VS Code, or:
npm run test