Skip to main content
Glama
OpenZeppelin

OpenZeppelin Contracts MCP Server

Official
by OpenZeppelin

cairo-governor

Generate governance contract source code for DAOs or decentralized systems using ERC20 or ERC721 voting tokens. Customize parameters like voting delays, periods, quorum modes, and timelocks. Output formatted in Markdown for immediate use.

Instructions

Make a contract to implement governance, such as for a DAO.

Returns the source code of the generated contract, formatted in a Markdown code block. Does not write to disk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameNoRequired when votes is enabled, for hashing and signing typed structured data. Name for domain separator implementing SNIP12Metadata trait. Prevents two applications from producing the same hash.
appVersionNoRequired when votes is enabled, for hashing and signing typed structured data. Version for domain separator implementing SNIP12Metadata trait. Prevents two versions of the same application from producing the same hash.
clockModeNoThe clock mode used by the voting token. For now, only timestamp mode where the token uses voting durations expressed as timestamps is supported. For Governor, this must be chosen to match what the ERC20 or ERC721 voting token uses.
decimalsNoThe number of decimals to use for the contract, default is 18 for ERC20Votes and 0 for ERC721Votes (because it does not apply to ERC721Votes).
delayYesThe delay since proposal is created until voting starts, in readable date time format matching /^(\d+(?:\.\d+)?) +(second|minute|hour|day|week|month|year)s?$/, default is "1 day".
infoNoMetadata about the contract and author
nameYesThe name of the contract
periodYesThe length of period during which people can cast their vote, in readable date time format matching /^(\d+(?:\.\d+)?) +(second|minute|hour|day|week|month|year)s?$/, default is "1 week".
proposalThresholdNoMinimum number of votes an account must have to create a proposal, default is 0.
quorumAbsoluteNoThe absolute quorum required, in cases of quorumMode equals absolute.
quorumModeNoThe type of quorum mode to use, either by percentage or absolute value.
quorumPercentNoThe percent required, in cases of quorumMode equals percent.
settingsNoWhether to allow governance to update voting settings (delay, period, proposal threshold).
timelockNoWhether to add a delay to actions taken by the Governor. Gives users time to exit the system if they disagree with governance decisions. If "openzeppelin", Module compatible with OpenZeppelin's TimelockController.
upgradeableNoWhether the smart contract is upgradeable.
votesNoThe type of voting to use. Either erc20votes, meaning voting power with a votes-enabled ERC20 token. Either erc721votes, meaning voting power with a votes-enabled ERC721 token. Voters can entrust their voting power to a delegate.

Implementation Reference

  • Handler function that constructs GovernorOptions from input parameters and generates Cairo Governor contract code using governor.print(opts) from @openzeppelin/wizard-cairo.
    async ({ name, delay, period, votes, clockMode, timelock, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, settings, upgradeable, appName, appVersion, info, }) => { const opts: GovernorOptions = { name, delay, period, votes, clockMode, timelock, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, settings, upgradeable, appName, appVersion, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => governor.print(opts)), }, ], }; },
  • Zod schema defining the input parameters and validation for the cairo-governor tool, matching GovernorOptions type.
    export const governorSchema = { name: z.string().describe(commonDescriptions.name), delay: z.string().describe(cairoGovernorDescriptions.delay), period: z.string().describe(cairoGovernorDescriptions.period), votes: z.enum(['erc20votes', 'erc721votes']).optional().describe(cairoGovernorDescriptions.votes), clockMode: z.enum(['timestamp']).optional().describe(cairoGovernorDescriptions.clockMode), timelock: z .union([z.literal(false), z.literal('openzeppelin')]) .optional() .describe(cairoGovernorDescriptions.timelock), decimals: z.number().optional().describe(cairoGovernorDescriptions.decimals), proposalThreshold: z.string().optional().describe(cairoGovernorDescriptions.proposalThreshold), quorumMode: z.enum(['percent', 'absolute']).optional().describe(cairoGovernorDescriptions.quorumMode), quorumPercent: z.number().optional().describe(cairoGovernorDescriptions.quorumPercent), quorumAbsolute: z.string().optional().describe(cairoGovernorDescriptions.quorumAbsolute), settings: z.boolean().optional().describe(cairoGovernorDescriptions.settings), upgradeable: commonSchema.upgradeable, appName: z.string().optional().describe(cairoCommonDescriptions.appName), appVersion: z.string().optional().describe(cairoCommonDescriptions.appVersion), info: commonSchema.info, } as const satisfies z.ZodRawShape;
  • Registers the 'cairo-governor' tool on the MCP server with name, prompt, schema, and handler function.
    export function registerCairoGovernor(server: McpServer): RegisteredTool { return server.tool( 'cairo-governor', makeDetailedPrompt(cairoPrompts.Governor), governorSchema, async ({ name, delay, period, votes, clockMode, timelock, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, settings, upgradeable, appName, appVersion, info, }) => { const opts: GovernorOptions = { name, delay, period, votes, clockMode, timelock, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, settings, upgradeable, appName, appVersion, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => governor.print(opts)), }, ], }; }, ); }
  • Top-level registration function for all Cairo tools, including cairo-governor via registerCairoGovernor.
    export function registerCairoTools(server: McpServer) { Object.values(getRegisterFunctions(server)).forEach(registerTool => { registerTool(server); }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OpenZeppelin/contracts-wizard'

If you have feedback or need assistance with the MCP directory API, please join our Discord server