keccak256
Compute the keccak256 hash of input data, a cryptographic function essential for Ethereum blockchain operations like address generation and smart contract interactions.
Instructions
calculate keccak256 hash
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | data to hash |
Implementation Reference
- src/cast-commands/utils.ts:50-55 (handler)The async handler function for the 'keccak256' tool. It takes a 'data' input string, computes its Keccak-256 hash using ethers.keccak256(ethers.toUtf8Bytes(data)), and returns a text response with the hash.async ({ data }) => { const hash = ethers.keccak256(ethers.toUtf8Bytes(data)); return { content: [{ type: "text", text: `keccak256 hash: ${hash}` }] }; }
- src/cast-commands/utils.ts:43-49 (schema)The schema definition for the 'keccak256' tool, including title, description, and Zod inputSchema requiring a 'data' string.{ title: "keccak256", description: "calculate keccak256 hash", inputSchema: { data: z.string().describe("data to hash"), } },
- src/cast-commands/utils.ts:40-56 (registration)The registration of the 'keccak256' tool via server.registerTool call within UtilsService.registerWithServer method.// tool to calculate keccak256 hash server.registerTool( "keccak256", { title: "keccak256", description: "calculate keccak256 hash", inputSchema: { data: z.string().describe("data to hash"), } }, async ({ data }) => { const hash = ethers.keccak256(ethers.toUtf8Bytes(data)); return { content: [{ type: "text", text: `keccak256 hash: ${hash}` }] }; } );