Skip to main content
Glama

generate_messaging_code

Generate TypeScript code for Arbitrum cross-chain messaging operations including L1 to L2 retryable tickets and L2 to L1 messages with status checking.

Instructions

Generate TypeScript code for Arbitrum cross-chain messaging. Supports L1->L2 retryable tickets and L2->L1 messages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
message_typeYesType of messaging operation to generate code for
include_exampleNoInclude example usage with sample contract call

Implementation Reference

  • The execute() method of GenerateMessagingCodeTool class handles the request for messaging code based on the provided message_type parameter.
    def execute(self, **kwargs) -> dict[str, Any]:
        """Generate messaging code based on the specified type."""
        message_type = kwargs.get("message_type")
        _include_example = kwargs.get("include_example", True)
    
        if not message_type:
            return {"error": "message_type is required"}
    
        templates = {
            "l1_to_l2": L1_TO_L2_MESSAGE_TEMPLATE,
            "l2_to_l1": L2_TO_L1_MESSAGE_TEMPLATE,
            "l2_to_l1_claim": L2_TO_L1_CLAIM_TEMPLATE,
            "l2_to_l3": L2_TO_L3_MESSAGE_TEMPLATE,
            "l3_to_l2": L3_TO_L2_MESSAGE_TEMPLATE,
            "l3_to_l2_claim": L3_TO_L2_CLAIM_TEMPLATE,
            "check_status": MESSAGE_STATUS_TEMPLATE,
        }
    
        template = templates.get(message_type)
        if not template:
            return {"error": f"Unknown message_type: {message_type}"}
    
        # Determine required env vars based on message type
        env_vars = ["PRIVATE_KEY"]
        if message_type in ("l1_to_l2", "l2_to_l1_claim", "check_status"):
            env_vars = ["L1_RPC_URL", "L2_RPC_URL", "PRIVATE_KEY"]
        elif message_type == "l2_to_l1":
            env_vars = ["L2_RPC_URL", "PRIVATE_KEY"]
        elif message_type == "l2_to_l3":
            env_vars = ["L2_RPC_URL", "L3_RPC_URL", "PRIVATE_KEY"]
        elif message_type == "l3_to_l2":
            env_vars = ["L3_RPC_URL", "PRIVATE_KEY"]
        elif message_type == "l3_to_l2_claim":
            env_vars = ["L2_RPC_URL", "L3_RPC_URL", "PRIVATE_KEY"]
    
        result = {
            "code": template,
            "message_type": message_type,
            "dependencies": {
                "ethers": "^5.7.0",
                "@arbitrum/sdk": "^4.0.0",
            },
            "env_vars": env_vars,
            "notes": self._get_notes(message_type),
            "related_types": self._get_related_types(message_type),
            "disclaimer": TEMPLATE_DISCLAIMER,
        }
    
        return result
  • The input_schema defines the expected input for the tool, including message_type and include_example.
    input_schema = {
        "type": "object",
        "properties": {
            "message_type": {
                "type": "string",
                "enum": [
                    "l1_to_l2", "l2_to_l1", "l2_to_l1_claim",
                    "l2_to_l3", "l3_to_l2", "l3_to_l2_claim",
                    "check_status",
                ],
                "description": "Type of messaging operation to generate code for",
            },
            "include_example": {
                "type": "boolean",
                "description": "Include example usage with sample contract call",
                "default": True,
            },
        },
        "required": ["message_type"],
    }
  • The GenerateMessagingCodeTool class definition, setting the name property to 'generate_messaging_code'.
    class GenerateMessagingCodeTool(BaseTool):
        """Generate Arbitrum cross-chain messaging code."""
    
        name = "generate_messaging_code"

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