analyze-verified-contract
Analyze verified smart contracts on Monad testnet to assess functionality and security by providing a contract address.
Instructions
Analyze a verified contract from an address on the Monad testnet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Monad testnet address to analyze verified contract for |
Implementation Reference
- src/index.ts:37-101 (handler)The main handler function for the 'analyze-verified-contract' tool. It fetches verified source code from an API endpoint using the provided address, concatenates multiple source files if present, and returns a formatted text response for analysis, handling errors appropriately.async ({ address }) => { try { const apiUrl = process.env.API_URL const apiKey = process.env.API_KEY; if (!apiUrl) { throw new Error("API_URL not set."); } if (!apiKey) { throw new Error("API_KEY not set."); } const url = `${apiUrl}${address}`; const response = await fetch(url, { method: 'GET', headers: { "accept": "application/json", "x-api-key": apiKey } }); if (!response.ok) { throw new Error(`API request failed with status ${response.status}`); } const data = await response.json(); if (data.code !== 0) { throw new Error(`API request failed with error: ${data.message}`); } const sourceCodeList = data.result.sourceCode; if (sourceCodeList && sourceCodeList.length > 0) { const allSourceCode = sourceCodeList .map((item: { content: string }) => item.content) .join('\n\n'); return { content: [ { type: "text", text: `Analyze the source code of smart contract, including its core functionalities, main logic flow, and security aspects:\n\`\`\`\n${allSourceCode}\n\`\`\``, }, ], }; } else { throw new Error(`Failed to retrieve source code`); } } catch (error) { console.error("Error getting contract sourceCode:", error); return { content: [ { type: "text", text: `Failed to retrieve contract sourceCode for address: ${address}. Error: ${error instanceof Error ? error.message : String(error) }`, }, ], }; } } );
- src/index.ts:34-36 (schema)Input schema defined using Zod, requiring a 'address' string parameter describing the Monad testnet contract address.{ address: z.string().describe("Monad testnet address to analyze verified contract for"), },
- src/index.ts:31-32 (registration)Registration of the 'analyze-verified-contract' tool using server.tool(), including name, description, schema, and handler.server.tool( "analyze-verified-contract",
- src/index.ts:28-28 (registration)Declaration of server capabilities, listing 'analyze-verified-contract' as a supported tool.capabilities: ["analyze-verified-contract", "analyze-unverified-contract"]