solidity-account
Generate ERC-4337 compliant account contract source code with customizable features like signature validation, token handling, and module compatibility. Outputs formatted Markdown code for immediate use.
Instructions
Make an account contract that follows the ERC-4337 standard. Experimental, some features are not audited and are subject to change.
Returns the source code of the generated contract, formatted in a Markdown code block. Does not write to disk.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ERC1155Holder | No | Whether to implement the `onERC1155Received` function to allow the account to receive ERC1155 tokens. | |
| ERC721Holder | No | Whether to implement the `onERC721Received` function to allow the account to receive ERC721 tokens. | |
| ERC7579Modules | No | Whether to implement the ERC-7579 compatibility to enable functionality on the account with modules. | |
| batchedExecution | No | Whether to implement a minimal batching interface for the account to allow multiple operations to be executed in a single transaction following the ERC-7821 standard. | |
| info | No | Metadata about the contract and author | |
| name | Yes | The name of the account contract | |
| signatureValidation | No | Whether to implement the ERC-1271 standard for validating signatures. This is useful for the account to verify signatures. | |
| signer | No | Defines the signature verification algorithm used by the account to verify user operations. Options: - ECDSA: Standard Ethereum signature validation using secp256k1, validates signatures against a specified owner address - ERC7702: Special ECDSA validation using account's own address as signer, enables EOAs to delegate execution rights - P256: NIST P-256 curve (secp256r1) validation for integration with Passkeys and HSMs - RSA: RSA PKCS#1 v1.5 signature validation (RFC8017) for PKI systems and HSMs - Multisig: ERC-7913 multisignature requiring minimum number of signatures from authorized signers - MultisigWeighted: ERC-7913 weighted multisignature where signers have different voting weights |
Implementation Reference
- The asynchronous handler function for the 'solidity-account' tool. It constructs AccountOptions from validated inputs and generates the Solidity account contract code using the @openzeppelin/wizard 'account.print' method, then wraps it in a safe-printed text content response.async ({ name, signatureValidation, ERC721Holder, ERC1155Holder, signer, batchedExecution, ERC7579Modules, info, upgradeable, }) => { const opts: AccountOptions = { name, signatureValidation, ERC721Holder, ERC1155Holder, signer, batchedExecution, ERC7579Modules, info, upgradeable, }; return { content: [ { type: 'text', text: safePrintSolidityCodeBlock(() => account.print(opts)), }, ], }; },
- Zod schema (accountSchema) that validates and describes the input parameters for the 'solidity-account' tool, imported and used during tool registration.export const accountSchema = { name: z.string().describe('The name of the account contract'), signatureValidation: z .literal(false) .or(z.literal('ERC1271')) .or(z.literal('ERC7739')) .optional() .describe(solidityAccountDescriptions.signatureValidation), ERC721Holder: z.boolean().optional().describe(solidityAccountDescriptions.ERC721Holder), ERC1155Holder: z.boolean().optional().describe(solidityAccountDescriptions.ERC1155Holder), signer: z .literal(false) .or(z.literal('ECDSA')) .or(z.literal('EIP7702')) .or(z.literal('Multisig')) .or(z.literal('MultisigWeighted')) .or(z.literal('P256')) .or(z.literal('RSA')) .or(z.literal('WebAuthn')) .optional() .describe(solidityAccountDescriptions.signer), batchedExecution: z.boolean().optional().describe(solidityAccountDescriptions.batchedExecution), ERC7579Modules: z .literal(false) .or(z.literal('AccountERC7579')) .or(z.literal('AccountERC7579Hooked')) .optional() .describe(solidityAccountDescriptions.ERC7579Modules), info: commonSchema.info, upgradeable: commonSchema.upgradeable, } as const satisfies z.ZodRawShape;
- packages/mcp/src/solidity/tools/account.ts:8-45 (registration)Tool registration function (registerSolidityAccount) that registers the 'solidity-account' tool on the MCP server, providing the tool name, detailed prompt from wizard-common, the accountSchema for input validation, and the handler function.export function registerSolidityAccount(server: McpServer): RegisteredTool { return server.tool( 'solidity-account', makeDetailedPrompt(solidityPrompts.Account), accountSchema, async ({ name, signatureValidation, ERC721Holder, ERC1155Holder, signer, batchedExecution, ERC7579Modules, info, upgradeable, }) => { const opts: AccountOptions = { name, signatureValidation, ERC721Holder, ERC1155Holder, signer, batchedExecution, ERC7579Modules, info, upgradeable, }; return { content: [ { type: 'text', text: safePrintSolidityCodeBlock(() => account.print(opts)), }, ], }; }, ); }