event-sig
Extract event selectors for Ethereum smart contracts by inputting event names. Use this tool to simplify interactions with blockchain events and enhance contract analysis.
Instructions
get event selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventName | Yes | event name, e.g. 'Transfer(address indexed from, address indexed to, uint256 amount)' |
Implementation Reference
- src/cast-commands/utils.ts:33-38 (handler)The handler function for the "event-sig" tool. It computes the event selector by hashing the event name with keccak256 and taking the first 10 characters (4 bytes).async ({ eventName }) => { const eventSignature = ethers.keccak256(ethers.toUtf8Bytes(eventName)).slice(0, 10); return { content: [{ type: "text", text: `event signature: ${eventSignature}` }] }; }
- src/cast-commands/utils.ts:26-32 (schema)Schema definition including title, description, and input schema using Zod for the eventName parameter.{ title: "event-sig", description: "get event selector", inputSchema: { eventName: z.string().describe("event name, e.g. 'Transfer(address indexed from, address indexed to, uint256 amount)'"), } },
- src/cast-commands/utils.ts:23-39 (registration)Registration of the "event-sig" tool within the UtilsService.registerWithServer method using server.registerTool.// register tools to get event signature server.registerTool( "event-sig", { title: "event-sig", description: "get event selector", inputSchema: { eventName: z.string().describe("event name, e.g. 'Transfer(address indexed from, address indexed to, uint256 amount)'"), } }, async ({ eventName }) => { const eventSignature = ethers.keccak256(ethers.toUtf8Bytes(eventName)).slice(0, 10); return { content: [{ type: "text", text: `event signature: ${eventSignature}` }] }; } );