Skip to main content
Glama

get_transaction

get_transaction

Retrieve VeChain blockchain transaction details by ID, with options for pending transactions, raw hex data, and specific block references.

Instructions

Get a VeChain transaction by its ID. Optionally include pending txs (meta may be null), return raw hex, or pin to a specific head block.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesTransaction ID (0x-prefixed 32-byte hex)
pendingNoInclude pending transactions (meta may be null). Default: false
rawNoInclude raw hex transaction in response. Default: false
headNoHead block ID to use; defaults to best if omitted

Implementation Reference

  • The handler function for the 'get_transaction' tool. It constructs the Thorest API URL for /transactions/{id} with optional query parameters (pending, raw, head), performs a fetch request with timeout and abort control, handles errors, and returns the transaction data as JSON or an error message.
    callback: async ({ id, pending = false, raw = false, head }: { id: string, pending?: boolean, raw?: boolean, head?: string }) => {
        const base = isMainnet ? vechainConfig.mainnet.thorestApiBaseUrl : vechainConfig.testnet.thorestApiBaseUrl;
        const path = `/transactions/${encodeURIComponent(id)}`;
        const qs = new URLSearchParams();
    
        if (typeof pending === "boolean") qs.set("pending", String(pending));
        if (typeof raw === "boolean") qs.set("raw", String(raw));
        if (head) qs.set("head", head);
    
        const url = `${base}${path}${qs.toString() ? `?${qs.toString()}` : ""}`;
    
        const controller = new AbortController();
        const timeout = setTimeout(() => controller.abort(), isMainnet ? vechainConfig.mainnet.controllerAbortTimeout : vechainConfig.testnet.controllerAbortTimeout);
    
        try {
            const res = await fetch(url, { signal: controller.signal });
    
            if (!res.ok) {
                const bodyText = await res.text().catch(() => "");
                throw new Error(
                    `VeChain node responded ${res.status} ${res.statusText}${bodyText ? `: ${bodyText}` : ""
                    }`
                );
            }
    
            const data = await res.json();
    
            if (data == null) {
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify(
                                {
                                    message: "Transaction not found",
                                    id,
                                    pending,
                                    raw,
                                    head: head ?? "best",
                                },
                                null,
                                2
                            ),
                        },
                    ],
                };
            }
    
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(data, null, 2),
                    },
                ],
            };
        } catch (err) {
            const isAbort = (err as Error)?.name === "AbortError";
            return {
                content: [
                    {
                        type: "text",
                        text: JSON.stringify(
                            {
                                error: isAbort ? "Request timed out" : "Failed to fetch transaction",
                                reason: String((err as Error)?.message ?? err),
                                url,
                                id,
                                pending,
                                raw,
                                head: head ?? "best",
                            },
                            null,
                            2
                        ),
                    },
                ],
            };
        } finally {
            clearTimeout(timeout);
        }
    }
  • Zod input schema for validating the parameters of the get_transaction tool: transaction ID (required), pending, raw, and head (all optional).
    inputSchema: {
        id: z
            .string()
            .regex(vechainConfig.general.txidRegex, "Invalid transaction ID: expected 0x + 64 hex chars")
            .describe("Transaction ID (0x-prefixed 32-byte hex)"),
        pending: z
            .boolean()
            .optional()
            .describe("Include pending transactions (meta may be null). Default: false"),
        raw: z
            .boolean()
            .optional()
            .describe("Include raw hex transaction in response. Default: false"),
        head: z
            .string()
            .optional()
            .describe("Head block ID to use; defaults to best if omitted"),
    },
  • src/tools.ts:189-293 (registration)
    The registration of the 'get_transaction' tool within the vechainTools array, including name, title, description, inputSchema, and callback handler.
    {
        name: "get_transaction",
        title: "Retrieve a transaction by ID",
        description: "Get a VeChain transaction by its ID. Optionally include pending txs (meta may be null), return raw hex, or pin to a specific head block.",
        inputSchema: {
            id: z
                .string()
                .regex(vechainConfig.general.txidRegex, "Invalid transaction ID: expected 0x + 64 hex chars")
                .describe("Transaction ID (0x-prefixed 32-byte hex)"),
            pending: z
                .boolean()
                .optional()
                .describe("Include pending transactions (meta may be null). Default: false"),
            raw: z
                .boolean()
                .optional()
                .describe("Include raw hex transaction in response. Default: false"),
            head: z
                .string()
                .optional()
                .describe("Head block ID to use; defaults to best if omitted"),
        },
        callback: async ({ id, pending = false, raw = false, head }: { id: string, pending?: boolean, raw?: boolean, head?: string }) => {
            const base = isMainnet ? vechainConfig.mainnet.thorestApiBaseUrl : vechainConfig.testnet.thorestApiBaseUrl;
            const path = `/transactions/${encodeURIComponent(id)}`;
            const qs = new URLSearchParams();
    
            if (typeof pending === "boolean") qs.set("pending", String(pending));
            if (typeof raw === "boolean") qs.set("raw", String(raw));
            if (head) qs.set("head", head);
    
            const url = `${base}${path}${qs.toString() ? `?${qs.toString()}` : ""}`;
    
            const controller = new AbortController();
            const timeout = setTimeout(() => controller.abort(), isMainnet ? vechainConfig.mainnet.controllerAbortTimeout : vechainConfig.testnet.controllerAbortTimeout);
    
            try {
                const res = await fetch(url, { signal: controller.signal });
    
                if (!res.ok) {
                    const bodyText = await res.text().catch(() => "");
                    throw new Error(
                        `VeChain node responded ${res.status} ${res.statusText}${bodyText ? `: ${bodyText}` : ""
                        }`
                    );
                }
    
                const data = await res.json();
    
                if (data == null) {
                    return {
                        content: [
                            {
                                type: "text",
                                text: JSON.stringify(
                                    {
                                        message: "Transaction not found",
                                        id,
                                        pending,
                                        raw,
                                        head: head ?? "best",
                                    },
                                    null,
                                    2
                                ),
                            },
                        ],
                    };
                }
    
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify(data, null, 2),
                        },
                    ],
                };
            } catch (err) {
                const isAbort = (err as Error)?.name === "AbortError";
                return {
                    content: [
                        {
                            type: "text",
                            text: JSON.stringify(
                                {
                                    error: isAbort ? "Request timed out" : "Failed to fetch transaction",
                                    reason: String((err as Error)?.message ?? err),
                                    url,
                                    id,
                                    pending,
                                    raw,
                                    head: head ?? "best",
                                },
                                null,
                                2
                            ),
                        },
                    ],
                };
            } finally {
                clearTimeout(timeout);
            }
        }
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses some behavioral traits like handling pending transactions (meta may be null) and pinning to specific blocks, but doesn't cover important aspects like rate limits, authentication requirements, error conditions, or response format details. It provides basic operational context but lacks comprehensive behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly front-loaded with the core purpose first, followed by three concise optional features. Every sentence earns its place by providing distinct, valuable information without redundancy. The structure is logical and efficient with zero wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description should do more to compensate. While it covers the basic operation and parameter implications, it lacks information about return values, error handling, rate limits, or authentication requirements. For a 4-parameter tool with no structured output documentation, this leaves significant gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds meaningful context by explaining the implications of optional parameters: 'pending txs (meta may be null)', 'return raw hex', and 'pin to a specific head block'. This provides semantic understanding beyond the schema's technical descriptions, elevating the score above baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Get') and resource ('a VeChain transaction by its ID'), distinguishing it from siblings like get_block or get_account which retrieve different blockchain entities. It precisely identifies what this tool does without being vague or tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through optional parameters (e.g., 'include pending txs'), but doesn't explicitly state when to use this tool versus alternatives like get_block for block data or get_balance for account information. No explicit when-not or alternative guidance is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/leandrogavidia/vechain-mcp-server'

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