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
| Name | Required | Description | Default |
|---|---|---|---|
| bridge_type | Yes | Type of bridging operation to generate code for | |
| amount | No | Amount to bridge (in ETH or token units) | 0.1 |
| token_address | No | L1 token address (required for erc20 operations) | |
| destination_address | No | Destination 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"], } - src/mcp/tools/generate_bridge_code.py:380-380 (registration)The tool name is registered as 'generate_bridge_code' inside the GenerateBridgeCodeTool class definition.
name = "generate_bridge_code"