Skip to main content
Glama

generate_bridge_code

Generate TypeScript code for bridging assets between Arbitrum layers (L1/L2/L3) using the Arbitrum SDK, supporting ETH and ERC20 token transfers.

Instructions

Generate TypeScript code for Arbitrum asset bridging using the Arbitrum SDK. Supports ETH/ERC20 bridging L1<->L2 and L1->L3.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bridge_typeYesType of bridging operation to generate code for
amountNoAmount to bridge (in ETH or token units)0.1
token_addressNoL1 token address (required for erc20 operations)
destination_addressNoDestination address (for deposit_to operations)

Implementation Reference

  • The 'execute' method of GenerateBridgeCodeTool handles the tool logic, selecting and formatting the appropriate template based on 'bridge_type'.
    def execute(self, **kwargs) -> dict[str, Any]:
        """Generate bridging code based on the specified type."""
        bridge_type = kwargs.get("bridge_type")
        amount = kwargs.get("amount", "0.1")
        token_address = kwargs.get("token_address", "0x...")
        destination = kwargs.get("destination_address", "0x...")
        _include_status = kwargs.get("include_status_check", True)
    
        # Validate inputs
        if not bridge_type:
            return {"error": "bridge_type is required"}
    
        if bridge_type.startswith("erc20") and not token_address:
            return {"error": "token_address is required for ERC20 operations"}
    
        # Select template
        templates = {
            "eth_deposit": ETH_DEPOSIT_TEMPLATE,
            "eth_deposit_to": ETH_DEPOSIT_TO_TEMPLATE,
            "eth_withdraw": ETH_WITHDRAW_TEMPLATE,
            "erc20_deposit": ERC20_DEPOSIT_TEMPLATE,
            "erc20_withdraw": ERC20_WITHDRAW_TEMPLATE,
            "eth_l1_l3": ETH_L1_L3_TEMPLATE,
            "erc20_l1_l3": ERC20_L1_L3_TEMPLATE,
            "eth_l3_l2": ETH_L3_L2_TEMPLATE,
            "erc20_l3_l2": ERC20_L3_L2_TEMPLATE,
        }
    
        template = templates.get(bridge_type)
        if not template:
            return {"error": f"Unknown bridge_type: {bridge_type}"}
    
        # Format template using replace to avoid curly brace issues
        code = template.replace("{amount}", amount)
        code = code.replace("{token_address}", token_address)
        code = code.replace("{destination}", destination)
    
        # Build response
        result = {
            "code": code,
            "bridge_type": bridge_type,
            "dependencies": {
                "ethers": "^5.7.0",
                "@arbitrum/sdk": "^4.0.0",
            },
            "env_vars": [
                "L1_RPC_URL",
                "L2_RPC_URL",
                "PRIVATE_KEY",
            ],
            "notes": self._get_notes(bridge_type),
            "disclaimer": TEMPLATE_DISCLAIMER,
        }
    
        if bridge_type in ["eth_l1_l3", "erc20_l1_l3", "eth_l3_l2", "erc20_l3_l2"]:
            result["env_vars"].append("L3_RPC_URL")
    
        return result
  • The input_schema defines the parameters for the 'generate_bridge_code' tool, including bridge_type, amount, and token_address.
    input_schema = {
        "type": "object",
        "properties": {
            "bridge_type": {
                "type": "string",
                "enum": ["eth_deposit", "eth_deposit_to", "eth_withdraw",
                         "erc20_deposit", "erc20_withdraw",
                         "eth_l1_l3", "erc20_l1_l3",
                         "eth_l3_l2", "erc20_l3_l2"],
                "description": "Type of bridging operation to generate code for",
            },
            "amount": {
                "type": "string",
                "description": "Amount to bridge (in ETH for eth operations, or token units)",
                "default": "0.1",
            },
            "token_address": {
                "type": "string",
                "description": "L1 token address (required for erc20 operations)",
            },
            "destination_address": {
                "type": "string",
                "description": "Destination address (for deposit_to operations)",
            },
            "include_status_check": {
                "type": "boolean",
                "description": "Include code for checking bridge status",
                "default": True,
            },
        },
        "required": ["bridge_type"],
    }
  • The tool name is registered as 'generate_bridge_code' inside the GenerateBridgeCodeTool class definition.
    name = "generate_bridge_code"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool generates code but doesn't mention whether it requires specific dependencies, how the code is delivered (e.g., as a file or snippet), error handling, or any rate limits. This leaves significant gaps for a code-generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it front-loads the core purpose and succinctly lists supported operations without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of blockchain bridging and no annotations or output schema, the description is inadequate. It doesn't explain what the generated code looks like, any required setup (e.g., SDK installation), or error scenarios, leaving the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter semantics beyond implying support for ETH/ERC20 and L1/L2/L3 operations, which aligns with the bridge_type enum but doesn't provide extra value over the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Generate TypeScript code'), resource ('Arbitrum asset bridging'), and scope ('using the Arbitrum SDK. Supports ETH/ERC20 bridging L1<->L2 and L1->L3'), distinguishing it from sibling tools like generate_frontend or generate_tests that handle different code generation tasks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like ask_bridging or generate_messaging_code. It mentions what the tool supports but offers no context about prerequisites, typical use cases, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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