Skip to content

NetworkManager

Defined in: src/network-manager.ts:101

Manager for network-related operations. Provides utilities for querying blockchain state and waiting for specific conditions.

new NetworkManager(algod, algorand): NetworkManager

Defined in: src/network-manager.ts:111

Create a new NetworkManager instance.

AlgodClient

The algod client to use for network operations

AlgorandClient

The AlgorandClient instance (for LocalNet operations)

NetworkManager

get localNet(): LocalNetManager

Defined in: src/network-manager.ts:244

Get LocalNet-specific network utilities. These methods only work when connected to a LocalNet network and will throw an error if called on other networks.

// Block warp on LocalNet
await algorand.network.localNet.blockWarp(100n)
// Time warp on LocalNet
await algorand.network.localNet.timeWarp(BigInt(Date.now() / 1000) + 3600n)

LocalNetManager

The LocalNetManager instance

getLastRound(): Promise<bigint>

Defined in: src/network-manager.ts:125

Get the last committed round number.

Promise<bigint>

The last round number

const lastRound = await algorand.network.getLastRound()
console.log(`Current round: ${lastRound}`)

getLatestTimestamp(): Promise<bigint>

Defined in: src/network-manager.ts:144

Get the Unix timestamp of the latest block.

Note: This method makes two sequential API calls (status then block fetch). The round may advance between these calls, so the returned timestamp may not be from the actual latest timestamp.

Promise<bigint>

The UNIX timestamp of the last round

const timestamp = await algorand.network.getLatestTimestamp()
console.log(`Latest block time: ${new Date(Number(timestamp) * 1000)}`)

waitUntilRound(targetRound): Promise<void>

Defined in: src/network-manager.ts:164

Wait until a specific round is reached.

bigint

The round number to wait for

Promise<void>

Error if timeout is reached before the target round

// Wait for round 1000
await algorand.network.waitUntilRound(1000n)
// Wait with a 30 second timeout
await algorand.network.waitUntilRound(1000n, 30000)

waitUntilTimestamp(targetTimestamp, options?): Promise<void>

Defined in: src/network-manager.ts:188

Wait until a specific Unix timestamp is reached on the blockchain.

bigint

The target Unix timestamp in seconds

WaitUntilTimestampOptions

Optional parameters for waiting

Promise<void>

// Wait until a specific time
const futureTime = BigInt(Math.floor(Date.now() / 1000)) + 60n // 1 minute from now
await algorand.network.waitUntilTimestamp(futureTime)
// Wait with custom timing parameters
await algorand.network.waitUntilTimestamp(futureTime, { blockTimeSeconds: 3.0, pollingIntervalMs: 500 })