JavaScript/TypeScript client library for the Arweave decentralized permanent data storage network
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Network information queries, peer discovery, and block data retrieval for interacting with the Arweave blockchain and network topology.
Retrieve comprehensive information about the current state of the Arweave network.
/**
* Get current network information
* @returns Promise resolving to network info
*/
getInfo(): Promise<NetworkInfoInterface>;Usage Example:
import Arweave from "arweave";
const arweave = Arweave.init();
const networkInfo = await arweave.network.getInfo();
console.log(`Network: ${networkInfo.network}`);
console.log(`Version: ${networkInfo.version}`);
console.log(`Current height: ${networkInfo.height}`);
console.log(`Peers: ${networkInfo.peers}`);
console.log(`Queue length: ${networkInfo.queue_length}`);Retrieve a list of peer nodes in the Arweave network.
/**
* Get list of network peers
* @returns Promise resolving to array of peer addresses
*/
getPeers(): Promise<PeerList>;Usage Example:
const peers = await arweave.network.getPeers();
console.log(`Found ${peers.length} peers:`);
peers.forEach(peer => console.log(peer));Retrieve a block by its independent hash.
/**
* Get block by independent hash
* @param indepHash - Independent hash of the block
* @returns Promise resolving to block data
*/
get(indepHash: string): Promise<BlockData>;Usage Example:
const blockHash = "block-independent-hash";
const block = await arweave.blocks.get(blockHash);
console.log(`Block height: ${block.height}`);
console.log(`Block timestamp: ${block.timestamp}`);
console.log(`Transactions: ${block.txs.length}`);Retrieve a block by its height in the blockchain.
/**
* Get block by height
* @param height - Block height
* @returns Promise resolving to block data
*/
getByHeight(height: number): Promise<BlockData>;Usage Example:
const blockHeight = 1000000;
const block = await arweave.blocks.getByHeight(blockHeight);
console.log(`Block hash: ${block.indep_hash}`);
console.log(`Previous block: ${block.previous_block}`);Retrieve the current (latest) block in the blockchain.
/**
* Get the current block
* @returns Promise resolving to current block data
*/
getCurrent(): Promise<BlockData>;Usage Example:
const currentBlock = await arweave.blocks.getCurrent();
console.log(`Current height: ${currentBlock.height}`);
console.log(`Current hash: ${currentBlock.indep_hash}`);
console.log(`Weave size: ${currentBlock.weave_size}`);interface NetworkInfoInterface {
/** Network identifier */
network: string;
/** Network protocol version */
version: number;
/** Network release number */
release: number;
/** Current block height */
height: number;
/** Current block hash */
current: string;
/** Total number of blocks */
blocks: number;
/** Number of connected peers */
peers: number;
/** Transaction queue length */
queue_length: number;
/** Node state latency in milliseconds */
node_state_latency: number;
}/** Array of peer addresses */
type PeerList = string[];interface BlockData {
/** Block nonce */
nonce: string;
/** Previous block hash */
previous_block: string;
/** Block timestamp (Unix timestamp) */
timestamp: number;
/** Last difficulty retarget timestamp */
last_retarget: number;
/** Mining difficulty */
diff: string;
/** Block height */
height: number;
/** Block hash */
hash: string;
/** Independent hash (unique identifier) */
indep_hash: string;
/** Array of transaction IDs in this block */
txs: string[];
/** Wallet list root hash */
wallet_list: string;
/** Mining reward address */
reward_addr: string;
/** Block tags */
tags: Tag[];
/** Mining reward pool */
reward_pool: string;
/** Total weave size in bytes */
weave_size: string;
/** Block size in bytes */
block_size: string;
/** Cumulative mining difficulty */
cumulative_diff: string;
/** Hash list merkle root */
hash_list_merkle: string;
}Usage Example:
// Monitor network status
async function monitorNetwork() {
const info = await arweave.network.getInfo();
const currentBlock = await arweave.blocks.getCurrent();
console.log(`Network Status:`);
console.log(`- Height: ${info.height}`);
console.log(`- Peers: ${info.peers}`);
console.log(`- Queue: ${info.queue_length} transactions`);
console.log(`- Weave Size: ${currentBlock.weave_size} bytes`);
console.log(`- Block Size: ${currentBlock.block_size} bytes`);
}
// Get transaction count for recent blocks
async function getRecentActivity() {
const current = await arweave.blocks.getCurrent();
const recentBlocks = [];
for (let i = 0; i < 10; i++) {
const block = await arweave.blocks.getByHeight(current.height - i);
recentBlocks.push({
height: block.height,
txCount: block.txs.length,
timestamp: new Date(block.timestamp * 1000)
});
}
console.log("Recent block activity:", recentBlocks);
}