NetworkManager
Defined in: src/network-manager.ts:101
Manager for network-related operations. Provides utilities for querying blockchain state and waiting for specific conditions.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NetworkManager(
algod,algorand):NetworkManager
Defined in: src/network-manager.ts:111
Create a new NetworkManager instance.
Parameters
Section titled “Parameters”The algod client to use for network operations
algorand
Section titled “algorand”The AlgorandClient instance (for LocalNet operations)
Returns
Section titled “Returns”NetworkManager
Accessors
Section titled “Accessors”localNet
Section titled “localNet”Get Signature
Section titled “Get Signature”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.
Example
Section titled “Example”// Block warp on LocalNetawait algorand.network.localNet.blockWarp(100n)
// Time warp on LocalNetawait algorand.network.localNet.timeWarp(BigInt(Date.now() / 1000) + 3600n)Returns
Section titled “Returns”The LocalNetManager instance
Methods
Section titled “Methods”getLastRound()
Section titled “getLastRound()”getLastRound():
Promise<bigint>
Defined in: src/network-manager.ts:125
Get the last committed round number.
Returns
Section titled “Returns”Promise<bigint>
The last round number
Example
Section titled “Example”const lastRound = await algorand.network.getLastRound()console.log(`Current round: ${lastRound}`)getLatestTimestamp()
Section titled “getLatestTimestamp()”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.
Returns
Section titled “Returns”Promise<bigint>
The UNIX timestamp of the last round
Example
Section titled “Example”const timestamp = await algorand.network.getLatestTimestamp()console.log(`Latest block time: ${new Date(Number(timestamp) * 1000)}`)waitUntilRound()
Section titled “waitUntilRound()”waitUntilRound(
targetRound):Promise<void>
Defined in: src/network-manager.ts:164
Wait until a specific round is reached.
Parameters
Section titled “Parameters”targetRound
Section titled “targetRound”bigint
The round number to wait for
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”Error if timeout is reached before the target round
Example
Section titled “Example”// Wait for round 1000await algorand.network.waitUntilRound(1000n)
// Wait with a 30 second timeoutawait algorand.network.waitUntilRound(1000n, 30000)waitUntilTimestamp()
Section titled “waitUntilTimestamp()”waitUntilTimestamp(
targetTimestamp,options?):Promise<void>
Defined in: src/network-manager.ts:188
Wait until a specific Unix timestamp is reached on the blockchain.
Parameters
Section titled “Parameters”targetTimestamp
Section titled “targetTimestamp”bigint
The target Unix timestamp in seconds
options?
Section titled “options?”Optional parameters for waiting
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”// Wait until a specific timeconst futureTime = BigInt(Math.floor(Date.now() / 1000)) + 60n // 1 minute from nowawait algorand.network.waitUntilTimestamp(futureTime)
// Wait with custom timing parametersawait algorand.network.waitUntilTimestamp(futureTime, { blockTimeSeconds: 3.0, pollingIntervalMs: 500 })