cairo-account
Generate custom smart contract code for Starknet or Ethereum-flavored accounts that validate transactions, execute interactions, and support features like upgradeability and external execution.
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 |
|---|---|---|---|
| name | Yes | The name of the contract | |
| 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. | |
| declare | No | Whether to enable the account to declare other contract classes. | |
| deploy | No | Whether to enables the account to be counterfactually deployed. | |
| pubkey | No | Whether to enables the account to change its own public key. | |
| outsideExecution | No | Whether to allow a protocol to submit transactions on behalf of the account, as long as it has the relevant signatures. | |
| upgradeable | No | Whether the smart contract is upgradeable. | |
| info | No | Metadata about the contract and author |
Implementation Reference
- The core handler function for the 'cairo-account' tool. It receives input parameters, constructs AccountOptions, calls the external account.print(opts) to generate Cairo code, formats it safely, and returns it as text content.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 and validation for the 'cairo-account' tool.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)Registration of the 'cairo-account' tool via server.tool(), specifying name, prompt generator, schema, and handler function.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:17-26 (registration)In getRegisterFunctions, the 'Account' entry that triggers registration of 'cairo-account' tool when registerCairoTools is called.function getRegisterFunctions(server: McpServer): CairoToolRegisterFunctions { return { ERC20: () => registerCairoERC20(server), ERC721: () => registerCairoERC721(server), ERC1155: () => registerCairoERC1155(server), Account: () => registerCairoAccount(server), Multisig: () => registerCairoMultisig(server), Governor: () => registerCairoGovernor(server), Vesting: () => registerCairoVesting(server), Custom: () => registerCairoCustom(server),
- packages/mcp/src/server.ts:26-26 (registration)Top-level call to registerCairoTools in createServer(), which registers all Cairo tools including 'cairo-account'.registerCairoTools(server);