Skip to main content
Glama
blocks.ts1.27 kB
import { getProvider } from './clients.js'; import { BlockIdentifier } from 'starknet'; /** * Get block details * @param blockIdentifier Block number, hash, or tag ('latest', 'pending') * @param network Network name (mainnet, sepolia) * @returns Block details */ export async function getBlock( blockIdentifier: BlockIdentifier = 'latest', network = 'mainnet' ) { const provider = getProvider(network); // No need for type conversion - StarknetJS handles this directly return provider.getBlock(blockIdentifier); } /** * Get the latest block number * @param network Network name (mainnet, sepolia) * @returns The latest block number */ export async function getBlockNumber(network = 'mainnet'): Promise<number> { const provider = getProvider(network); return provider.getBlockNumber(); } /** * Get transactions in a specific block * @param blockIdentifier Block number, hash, or tag ('latest', 'pending') * @param network Network name (mainnet, sepolia) * @returns Array of transaction hashes in the block */ export async function getBlockTransactions( blockIdentifier: BlockIdentifier = 'latest', network = 'mainnet' ): Promise<string[]> { const block = await getBlock(blockIdentifier, network); return block.transactions || []; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpdotdirect/starknet-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server