Skip to main content
Glama

generate_validator_setup

Generate code to manage Orbit chain validators, batch posters, and AnyTrust DAC keysets for Arbitrum deployments.

Instructions

Generate code for managing Orbit chain validators, batch posters, and AnyTrust DAC keysets.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the validator management action
actionNoAction to performlist
targetNoTarget entity to managevalidator
addressesNoAddresses to check, add, or remove
rollup_addressNoRollup contract address on parent chain
sequencer_inboxNoSequencerInbox contract address
parent_chainNoParent chain where contracts are deployedarbitrum-sepolia

Implementation Reference

  • The execute method of GenerateValidatorSetupTool generates TypeScript code for managing validators and batch posters based on the requested action (list, add, remove) and target (validator, batch_poster, keyset).
    def execute(self, **kwargs) -> dict[str, Any]:
        """Generate validator/batch poster management code."""
        prompt = kwargs.get("prompt", "")
        action = kwargs.get("action", "list")
        target = kwargs.get("target", "validator")
        addresses = kwargs.get("addresses", [])
        rollup_address = kwargs.get(
            "rollup_address", "0x0000000000000000000000000000000000000000"
        )
        sequencer_inbox = kwargs.get(
            "sequencer_inbox", "0x0000000000000000000000000000000000000000"
        )
        parent_chain = kwargs.get("parent_chain", "arbitrum-sepolia")
    
        if not prompt:
            return {"error": "prompt is required"}
    
        # Get parent chain info
        parent_rpc = PARENT_CHAIN_RPCS.get(
            parent_chain, PARENT_CHAIN_RPCS["arbitrum-sepolia"]
        )
        parent_chain_id = self._get_parent_chain_id(parent_chain)
        parent_chain_name = parent_chain.replace("-", " ").title()
    
        # Select appropriate template based on target and action
        template_name: str
        if target == "keyset":
            template = get_orbit_template("anytrust_config")
            template_name = template.name if template else "Orbit AnyTrust Config"
        elif action in ("add", "remove"):
            template = None  # Use inline mutate template
            template_name = (
                "Orbit Add Validators"
                if action == "add"
                else "Orbit Remove Validators"
            )
        else:
            template = get_orbit_template("validator_management")
            template_name = template.name if template else "Orbit Validator Management"
    
        if target == "keyset" and not template:
            return {"error": "Template not found for keyset target"}
        if action == "list" and target != "keyset" and not template:
            return {"error": "Template not found for validator list"}
    
        # Format addresses array
        addresses_str = self._format_address_array(addresses)
    
        # Get code from the appropriate source
        if action in ("add", "remove"):
            code = MUTATE_VALIDATOR_TEMPLATE_CODE
        else:
            code = template.code  # type: ignore[union-attr]
    
        # Substitute parameters
        action_verb = "Removing" if action == "remove" else "Adding"
        action_bool = "false" if action == "remove" else "true"
        code = code.replace("{parent_chain_id}", str(parent_chain_id))
        code = code.replace("{parent_chain_name}", parent_chain_name)
        code = code.replace("{rollup_address}", rollup_address)
        code = code.replace("{sequencer_inbox}", sequencer_inbox)
        code = code.replace("{addresses_array}", addresses_str)
        code = code.replace("{action_verb}", action_verb)
        code = code.replace("{action_bool}", action_bool)
    
        # Build files
        files = {}
        if target == "keyset":
            files["scripts/manage-keyset.ts"] = validate_template_output(
                code, "manage-keyset"
            )
        else:
            files["scripts/manage-validators.ts"] = validate_template_output(
                code, "manage-validators"
            )
    
        # Add .env.example
        files[".env.example"] = (
            f"DEPLOYER_PRIVATE_KEY=0x...\n"
            f"PARENT_CHAIN_RPC={parent_rpc}\n"
        )
    
        result = {
            "template_used": template_name,
            "action": action,
            "target": target,
            "files": files,
            "dependencies": ORBIT_DEPENDENCIES,
            "parent_chain": {
                "name": parent_chain,
                "chain_id": parent_chain_id,
                "rpc": parent_rpc,
            },
            "contract_addresses": {
                "rollup": rollup_address,
                "sequencer_inbox": sequencer_inbox,
            },
            "addresses_to_manage": addresses,
            "setup_instructions": [
                "1. Install dependencies: npm install viem dotenv",
                "2. Copy .env.example to .env and configure",
                f"3. Run: npx tsx {list(files.keys())[0]}",
            ],
            "notes": self._get_notes(action, target),
            "disclaimer": TEMPLATE_DISCLAIMER,
        }
    
        return result
  • Input schema for the generate_validator_setup tool.
    input_schema = {
        "type": "object",
        "properties": {
            "prompt": {
                "type": "string",
                "description": "Description of the validator management action",
            },
            "action": {
                "type": "string",
                "enum": ["list", "add", "remove"],
                "description": "Action to perform",
                "default": "list",
            },
            "target": {
                "type": "string",
                "enum": ["validator", "batch_poster", "keyset"],
                "description": "Target entity to manage",
                "default": "validator",
            },
            "addresses": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Addresses to check, add, or remove",
            },
            "rollup_address": {
                "type": "string",
                "description": "Rollup contract address on parent chain",
            },
            "sequencer_inbox": {
                "type": "string",
                "description": "SequencerInbox contract address on parent chain",
            },
            "parent_chain": {
                "type": "string",
                "enum": [
                    "arbitrum-one",
                    "arbitrum-sepolia",
                    "ethereum-mainnet",
                    "ethereum-sepolia",
                ],
                "description": "Parent chain where contracts are deployed",
                "default": "arbitrum-sepolia",
            },
        },
        "required": ["prompt"],
    }
  • Tool registration for generate_validator_setup in the MCP server.
    "generate_validator_setup": GenerateValidatorSetupTool(),

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/Quantum3-Labs/ARBuilder'

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