Skip to main content
Glama
OpenZeppelin

OpenZeppelin Contracts MCP Server

Official
by OpenZeppelin

solidity-governor

Generate governance contract source code for DAOs. Configure voting parameters like delay, period, and quorum mode, and choose between ERC20 or ERC721 voting types. Output is provided as a Markdown code block.

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
blockTimeNoThe block time of the chain, default is 12
clockModeNoThe clock mode used by the voting token. 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, 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, 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
quorumPercentNoThe percent required, in cases of quorumMode equals percent
settingsNoAllow governance to update voting settings (delay, period, proposal threshold)
storageNoEnable storage of proposal details and enumerability of proposals
timelockNoThe type of timelock to use
upgradeableNoWhether the smart contract is upgradeable. Transparent uses more complex proxy with higher overhead, requires less changes in your contract. Can also be used with beacons. UUPS uses simpler proxy with less overhead, requires including extra code in your contract. Allows flexibility for authorizing upgrades.
votesNoThe type of voting to use

Implementation Reference

  • The handler function that takes the tool inputs, maps them to GovernorOptions, generates the Solidity contract code using the OpenZeppelin Wizard governor.print, and returns it as text content.
    async ({ name, delay, period, votes, clockMode, timelock, blockTime, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, storage, settings, upgradeable, info, }) => { const opts: GovernorOptions = { name, delay, period, votes, clockMode, timelock, blockTime, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, storage, settings, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintSolidityCodeBlock(() => governor.print(opts)), }, ], }; },
  • Zod object schema defining all input parameters and their types, descriptions for the solidity-governor tool.
    export const governorSchema = { name: z.string().describe(commonDescriptions.name), delay: z.string().describe(solidityGovernorDescriptions.delay), period: z.string().describe(solidityGovernorDescriptions.period), votes: z.literal('erc20votes').or(z.literal('erc721votes')).optional().describe(solidityGovernorDescriptions.votes), clockMode: z .literal('blocknumber') .or(z.literal('timestamp')) .optional() .describe(solidityGovernorDescriptions.clockMode), timelock: z .literal(false) .or(z.literal('openzeppelin')) .or(z.literal('compound')) .optional() .describe(solidityGovernorDescriptions.timelock), blockTime: z.number().optional().describe(solidityGovernorDescriptions.blockTime), decimals: z.number().optional().describe(solidityGovernorDescriptions.decimals), proposalThreshold: z.string().optional().describe(solidityGovernorDescriptions.proposalThreshold), quorumMode: z .literal('percent') .or(z.literal('absolute')) .optional() .describe(solidityGovernorDescriptions.quorumMode), quorumPercent: z.number().optional().describe(solidityGovernorDescriptions.quorumPercent), quorumAbsolute: z.string().optional().describe(solidityGovernorDescriptions.quorumAbsolute), storage: z.boolean().optional().describe(solidityGovernorDescriptions.storage), settings: z.boolean().optional().describe(solidityGovernorDescriptions.settings), upgradeable: commonSchema.upgradeable, info: commonSchema.info, } as const satisfies z.ZodRawShape;
  • The registration function for the solidity-governor tool, called by higher-level registration to add the tool to the MCP server with name, prompt, schema, and handler.
    export function registerSolidityGovernor(server: McpServer): RegisteredTool { return server.tool( 'solidity-governor', makeDetailedPrompt(solidityPrompts.Governor), governorSchema, async ({ name, delay, period, votes, clockMode, timelock, blockTime, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, storage, settings, upgradeable, info, }) => { const opts: GovernorOptions = { name, delay, period, votes, clockMode, timelock, blockTime, decimals, proposalThreshold, quorumMode, quorumPercent, quorumAbsolute, storage, settings, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintSolidityCodeBlock(() => governor.print(opts)), }, ], }; }, ); }

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