sig
Generate function selectors from Ethereum smart contract function signatures. Input a function signature to derive the corresponding selector for blockchain interactions.
Instructions
get function selector
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| functionName | Yes | function signature, e.g. 'transfer(address,uint256)' |
Implementation Reference
- src/cast-commands/utils.ts:16-21 (handler)The handler function that computes the Ethereum function selector (first 4 bytes of keccak256 hash of the function signature).async ({ functionName }) => { const functionSelector = ethers.keccak256(ethers.toUtf8Bytes(functionName)).slice(0, 10); return { content: [{ type: "text", text: `function selector: ${functionSelector}` }] }; }
- src/cast-commands/utils.ts:10-15 (schema)The tool metadata including title, description, and input schema using Zod for validation.title: "sig", description: "get function selector", inputSchema: { functionName: z.string().describe("function signature, e.g. 'transfer(address,uint256)'"), } },
- src/cast-commands/utils.ts:8-22 (registration)Registers the 'sig' tool on the MCP server using server.registerTool."sig", { title: "sig", description: "get function selector", inputSchema: { functionName: z.string().describe("function signature, e.g. 'transfer(address,uint256)'"), } }, async ({ functionName }) => { const functionSelector = ethers.keccak256(ethers.toUtf8Bytes(functionName)).slice(0, 10); return { content: [{ type: "text", text: `function selector: ${functionSelector}` }] }; } );