AR.IO LogoAR.IO Documentation
AR.IO SDKANT Contracts

Versions

getModuleId()

Gets the module ID of the current ANT process by querying its spawn transaction tags. Results are cached after the first successful fetch.

const moduleId = await ant.getModuleId();
console.log(`ANT was spawned with module: ${moduleId}`);

// With custom GraphQL URL and retries
const moduleId = await ant.getModuleId({
  graphqlUrl: 'https://arweave.net/graphql',
  retries: 5
});

Output:

"FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE"

getVersion()

Gets the version string of the current ANT by matching its module ID with versions from the ANT registry.

const version = await ant.getVersion();
console.log(`ANT is running version: ${version}`);

// With custom ANT registry
const version = await ant.getVersion({
  antRegistryId: 'custom-ant-registry-id'
});

Output:

"23"

isLatestVersion()

Checks if the current ANT version is the latest according to the ANT registry.

const isLatest = await ant.isLatestVersion();
if (!isLatest) {
  console.log('ANT can be upgraded to the latest version');
}

Output:

true

getANTVersions

Static method that returns the full array of available ANT versions and the latest version from the ANT registry.

import { ANT } from '@ar.io/sdk';

// Get all available ANT versions
const antVersions = ANT.versions;
const versions = await antVersions.getANTVersions();

Result:

{
  [
    {
      "moduleId": "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE",
      "version": "23",
      "releaseNotes": "Initial release of the ANT module.",
      "releaseDate": 1700000000000
    }
    // ...other versions
  ],
}

getLatestANTVersion()

Static method that returns the latest ANT version from the ANT registry.

import { ANT } from '@ar.io/sdk';

// Get the latest ANT version
import { ANT } from '@ar.io/sdk';

// Get all available ANT versions
const antVersions = ANT.versions;
const versions = await antVersions.getANTVersions();
const latestVersion = await antVersions.getLatestANTVersion();

Result:

{
  "moduleId": "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE",
  "version": "23",
  "releaseNotes": "Initial release of the ANT module.",
  "releaseDate": 1700000000000
}

How is this guide?