decode_hex
Convert hexadecimal strings into readable UTF-8 text, ASCII characters, or raw byte data for blockchain transaction analysis and data interpretation.
Instructions
Decode hex string to UTF-8, ASCII, and bytes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hex | Yes | Hex string to decode |
Implementation Reference
- src/handlers/utility-handlers.ts:123-137 (handler)Handler execution logic for the 'decode_hex' tool. Extracts the 'hex' argument and delegates to AdvancedBlockchainService.decodeHex, then formats the response.case 'decode_hex': { const hex = args?.hex as string; const result = advancedBlockchain.decodeHex(hex); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- Input schema definition for the 'decode_hex' tool, specifying a required 'hex' string parameter.inputSchema: { type: 'object', properties: { hex: { type: 'string', description: 'Hex string to decode', }, }, required: ['hex'], },
- src/handlers/utility-handlers.ts:57-70 (registration)Tool registration object defining name, description, and input schema for 'decode_hex' returned by registerUtilityHandlers.{ name: 'decode_hex', description: 'Decode hex string to UTF-8, ASCII, and bytes', inputSchema: { type: 'object', properties: { hex: { type: 'string', description: 'Hex string to decode', }, }, required: ['hex'], }, },
- Core implementation of hex decoding in AdvancedBlockchainService. Converts hex to bytes, then to UTF-8 and ASCII strings, returns structured response.decodeHex(hex: string): EndpointResponse { try { const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex; const bytes = Buffer.from(cleanHex, 'hex'); const utf8 = bytes.toString('utf8'); const ascii = bytes.toString('ascii'); return { success: true, data: { hex, utf8, ascii, bytes: Array.from(bytes), length: bytes.length, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to decode hex', }; } }