Skip to main content
Glama

generate_oracle

Generate Chainlink oracle integration code for Arbitrum dApps to implement price feeds, VRF, automation, or functions with optional Stylus and frontend components.

Instructions

Generate Chainlink oracle integration code for Arbitrum dApps.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYesDescription of the oracle functionality needed
oracle_typeNoType of Chainlink oracle to integrate
networkNoNetwork to deploy onarbitrumSepolia
include_stylusNoInclude Stylus (Rust) implementation if available
include_frontendNoInclude frontend React hooks

Implementation Reference

  • The 'execute' method of GenerateOracleTool handles the logic for generating oracle integration code based on the provided prompt and oracle_type. It selects a template, builds the necessary file content (contracts, scripts, config), and returns a dictionary containing the generated files and instructions.
    def execute(self, **kwargs) -> dict[str, Any]:
        """Generate oracle integration code based on the request."""
        prompt = kwargs.get("prompt", "")
        oracle_type = kwargs.get("oracle_type")
        network = kwargs.get("network", "arbitrumSepolia")
        price_pairs = kwargs.get("price_pairs", ["ETH/USD"])
        include_stylus = kwargs.get("include_stylus", False)
        include_frontend = kwargs.get("include_frontend", True)
    
        # Validate inputs
        if not prompt:
            return {"error": "prompt is required"}
    
        # Select template
        if oracle_type:
            template = get_oracle_template(oracle_type)
            if not template:
                return {"error": f"Unknown oracle_type: {oracle_type}"}
        else:
            template = select_oracle_template(prompt)
    
        # Context retrieval (template-based generation doesn't require RAG)
        context = []
    
        # Build files
        files = {}
    
        # Add Solidity contract
        files["contracts/OracleConsumer.sol"] = self._customize_solidity(
            template, network, price_pairs
        )
    
        # Add Stylus implementation if available and requested
        if include_stylus and template.stylus_code:
            files["contracts/src/lib.rs"] = template.stylus_code
    
        # Add frontend hook if requested
        if include_frontend:
            files["src/hooks/useOracle.ts"] = template.frontend_hook
    
        # Add deployment script
        files["scripts/deploy.ts"] = self._generate_deploy_script(template, network)
    
        # Add Hardhat scaffold files
        files["hardhat.config.ts"] = self._generate_hardhat_config()
        files["package.json"] = self._generate_package_json(template, network)
        files[".env.example"] = "PRIVATE_KEY=your-private-key-without-0x-prefix\n"
    
        # Build response
        result = {
            "template_used": template.name,
            "oracle_type": template.oracle_type,
            "files": files,
            "dependencies": template.dependencies,
            "network_config": template.networks.get(network, {}),
            "features": template.features,
            "setup_instructions": self._get_setup_instructions(template, network),
        }
    
        if context:
            result["references"] = [
                {
                    "source": c.get("metadata", {}).get("source", "Unknown"),
                    "relevance": c.get("distance", 0),
                }
                for c in context[:3]
            ]
    
        return result
  • The 'input_schema' defines the expected input parameters for the 'generate_oracle' tool, including 'prompt', 'oracle_type', 'network', 'price_pairs', 'include_stylus', and 'include_frontend'.
    input_schema = {
        "type": "object",
        "properties": {
            "prompt": {
                "type": "string",
                "description": "Description of the oracle functionality needed",
            },
            "oracle_type": {
                "type": "string",
                "enum": ["price_feed", "vrf", "automation", "functions"],
                "description": "Type of Chainlink oracle to integrate",
            },
            "network": {
                "type": "string",
                "enum": ["arbitrum", "arbitrumSepolia"],
                "description": "Network to deploy on",
                "default": "arbitrumSepolia",
            },
            "price_pairs": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Price pairs to include (e.g., ['ETH/USD', 'BTC/USD'])",
            },
            "include_stylus": {
                "type": "boolean",
                "description": "Include Stylus (Rust) implementation if available",
                "default": False,
            },
            "include_frontend": {
                "type": "boolean",
                "description": "Include frontend React hooks",
                "default": True,
            },
        },
        "required": ["prompt"],
    }
  • The 'GenerateOracleTool' class defines the 'generate_oracle' tool name, description, and input schema. It inherits from 'BaseTool'.
    class GenerateOracleTool(BaseTool):
        """Generate Chainlink oracle integration code."""
    
        name = "generate_oracle"
        description = """Generate Chainlink oracle integration code for Arbitrum dApps.
    
    Supports:
    - Price Feed: Real-time price data (ETH/USD, BTC/USD, etc.)
    - VRF: Verifiable Random Function for provably fair randomness
    - Automation: Chainlink Keepers for automated contract execution
    - Functions: Custom JavaScript execution on Chainlink's DON
    
    Generates both Solidity contracts and frontend integration hooks."""
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 clarify what 'generate' entails—whether it produces complete deployable contracts, snippets, or documentation. It also omits details like authentication requirements, rate limits, or whether the output is deterministic based on inputs, which are critical 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 that front-loads the core purpose without unnecessary elaboration. Every word contributes directly to understanding the tool's function, making it highly concise and well-structured for quick comprehension.

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

Completeness3/5

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

Given the tool's complexity (5 parameters, no output schema, and no annotations), the description is minimally adequate but lacks depth. It doesn't explain the output format (e.g., code files, documentation) or behavioral aspects like error handling, which are important for a code-generation tool. However, the high schema coverage partially compensates for these gaps.

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 fully documents all parameters. The description adds no additional meaning beyond what's in the schema, such as explaining how 'prompt' influences the generated code or clarifying the relationships between parameters like 'oracle_type' and 'include_stylus'. Baseline 3 is appropriate when the schema handles parameter documentation effectively.

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

Purpose4/5

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

The description clearly states the tool's purpose: generating Chainlink oracle integration code for Arbitrum dApps. It specifies the verb ('generate'), resource ('Chainlink oracle integration code'), and target platform ('Arbitrum dApps'). However, it doesn't explicitly differentiate from sibling tools like 'generate_backend' or 'generate_frontend' that might also produce code for dApps.

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. It doesn't mention sibling tools like 'generate_backend' or 'generate_frontend' that might overlap in generating code components for dApps, nor does it specify prerequisites or contexts where this tool is particularly appropriate.

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