Skip to main content
Glama

network_get_block_number

Retrieve the current block number from the Ethereum or EVM-compatible blockchain for accurate synchronization and transaction tracking in wallet operations.

Instructions

Get the current block number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function getBlockNumberHandler that executes the tool logic: retrieves the Ethereum provider and calls getBlockNumber() to return the current block number.
    export const getBlockNumberHandler = async (input: any): Promise<ToolResultSchema> => {
      try {
        const provider = getProvider();
        if (!provider) {
          return createErrorResponse("Provider is required to get block number, please set the provider URL");
        }
        const blockNumber = await provider.getBlockNumber();
    
        return createSuccessResponse(
        `Block number retrieved successfully
          Block number: ${blockNumber.toString()}
        `);
      } catch (error) {
        return createErrorResponse(`Failed to get block number: ${(error as Error).message}`);
      }
    };
  • Tool schema definition including name, description, and input schema (no parameters required).
    {
      name: "network_get_block_number",
      description: "Get the current block number",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    },
  • src/tools.ts:602-604 (registration)
    Registration of the network_get_block_number tool handler in the handlers dictionary, mapping the tool name to getBlockNumberHandler.
    "network_get_network": getNetworkHandler,
    "network_get_block_number": getBlockNumberHandler,
    "network_get_fee_data": getFeeDataHandler,
  • src/tools.ts:1-36 (registration)
    Import statement that brings in the getBlockNumberHandler from the handlers/wallet.ts file.
    import {
      createWalletHandler,
      fromPrivateKeyHandler,
      fromMnemonicHandler,
      fromEncryptedJsonHandler,
      encryptWalletHandler,
      getAddressHandler,
      getPublicKeyHandler,
      getPrivateKeyHandler,
      getBalanceHandler,
      getChainIdHandler,
      getGasPriceHandler,
      getTransactionCountHandler,
      callHandler,
      sendTransactionHandler,
      signTransactionHandler,
      populateTransactionHandler,
      signMessageHandler,
      signTypedDataHandler,
      verifyMessageHandler,
      verifyTypedDataHandler,
      getBlockHandler,
      getTransactionHandler,
      getTransactionReceiptHandler,
      getCodeHandler,
      getStorageAtHandler,
      estimateGasHandler,
      getLogsHandler,
      getEnsResolverHandler,
      lookupAddressHandler,
      resolveNameHandler,
      getNetworkHandler,
      getBlockNumberHandler,
      getFeeDataHandler,
      createMnemonicPhraseHandler,
      setProviderHandler

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/dcSpark/mcp-cryptowallet-evm'

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