cairo-account
Generate custom smart contracts for Starknet or Ethereum-style accounts with configurable features like upgradeability, deployment, and signature types using OpenZeppelin Contracts libraries.
Instructions
Make a custom smart contract that represents an account that can be deployed and interacted with other contracts, and can be extended to implement custom logic. An account is a special type of contract that is used to validate and execute transactions.
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 |
|---|---|---|---|
| declare | No | Whether to enable the account to declare other contract classes. | |
| deploy | No | Whether to enables the account to be counterfactually deployed. | |
| info | No | Metadata about the contract and author | |
| name | Yes | The name of the contract | |
| outsideExecution | No | Whether to allow a protocol to submit transactions on behalf of the account, as long as it has the relevant signatures. | |
| pubkey | No | Whether to enables the account to change its own public key. | |
| type | Yes | Type of signature used for signature checking by the Account contract, Starknet account uses the STARK curve, Ethereum-flavored account uses the Secp256k1 curve. | |
| upgradeable | No | Whether the smart contract is upgradeable. |
Implementation Reference
- The core handler function for the 'cairo-account' tool. It constructs AccountOptions from inputs and generates Cairo code using account.print(opts) from '@openzeppelin/wizard-cairo'.async ({ name, type, declare, deploy, pubkey, outsideExecution, upgradeable, info }) => { const opts: AccountOptions = { name, type, declare, deploy, pubkey, outsideExecution, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => account.print(opts)), }, ], }; },
- Zod schema defining the input parameters for the 'cairo-account' tool, including name, type, declare, deploy, etc.export const accountSchema = { name: z.string().describe(commonDescriptions.name), type: z.enum(['stark', 'eth']).describe(cairoAccountDescriptions.type), declare: z.boolean().optional().describe(cairoAccountDescriptions.declare), deploy: z.boolean().optional().describe(cairoAccountDescriptions.deploy), pubkey: z.boolean().optional().describe(cairoAccountDescriptions.pubkey), outsideExecution: z.boolean().optional().describe(cairoAccountDescriptions.outsideExecution), upgradeable: commonSchema.upgradeable, info: commonSchema.info, } as const satisfies z.ZodRawShape;
- packages/mcp/src/cairo/tools/account.ts:8-34 (registration)Function that registers the 'cairo-account' tool with the MCP server, specifying name, prompt, schema, and handler.export function registerCairoAccount(server: McpServer): RegisteredTool { return server.tool( 'cairo-account', makeDetailedPrompt(cairoPrompts.Account), accountSchema, async ({ name, type, declare, deploy, pubkey, outsideExecution, upgradeable, info }) => { const opts: AccountOptions = { name, type, declare, deploy, pubkey, outsideExecution, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => account.print(opts)), }, ], }; }, ); }
- packages/mcp/src/cairo/tools.ts:30-33 (registration)Higher-level registration function that invokes registerCairoAccount among others for all Cairo tools.export function registerCairoTools(server: McpServer) { Object.values(getRegisterFunctions(server)).forEach(registerTool => { registerTool(server); });