Flap AI Oracle

1. Overview & Roadmap

Overview

Three simple steps β€” build your prompt on-chain, let us handle the AI, and get back a verified decision.

FlapAIProvider is a standardized on-chain AI oracle plugin built for the Flap ecosystem. It gives Vault contracts (and any smart contract) access to verifiable LLM reasoning via a commit-and-reveal scheme inspired by Chainlink VRF.

FlapAIProvider separates concerns of AI-powered smart contracts cleanly:

  • On-chain (commit): The consumer calls reason() with a prompt and pays a BNB fee. The contract records the request and emits an event.

  • Off-chain: The oracle backend listens for the event, feeds the prompt to the selected LLM, and obtains a numeric choice.

  • On-chain (reveal): The oracle calls fulfillReasoning() with the result and an IPFS CID linking to the full reasoning proof. The consumer's callback is invoked automatically.

Every request is permanently auditable: the IPFS CID stored on-chain pins the raw LLM inputs, outputs, temperature, model version, and salt that produced the decision.

Architecture

Flap AI Oracle

Roadmap

Release
Features

v1 (current)

Commit-and-reveal reasoning, multi-model registry, IPFS proof anchoring, refund fallback, FlapAIConsumerBase integration base, tool calling support (currently ave_token_tool available)

v2 (next)

Additional tools, multi-step reasoning workflows, and enhanced oracle features

Note: The LLM can only return a single numeric choice in the range [0, numOfChoices).


2. Deployed Addresses & Supported Models

Deployed Addresses

circle-exclamation

Supported Models

The following models are available on both BSC Testnet and BNB Mainnet:

Model ID
Name
Price per Request

0

google/gemini-3-flash

0.01 BNB

1

anthropic/claude-sonnet-4.6

0.05 BNB

2

deepseek/deepseek-r1

0.03 BNB

Query any model on-chain at any time:


3. Tool Calling Support

FlapAIProvider supports tool calling, allowing the LLM to fetch real-time external data before making a decision. The oracle backend automatically executes tool calls embedded in your prompt and injects the results into the LLM context.

Available Tools

Currently, the following tool is supported:

ave_token_tool

Fetches comprehensive market data for a Flap token, including:

  • Current price and market cap

  • Price change percentages

  • Trading volume (24h, 7d)

  • Holder count

  • Liquidity status

Usage example in prompt:

The oracle will automatically detect the tool request, fetch the token data, and provide it to the LLM before it makes a choice.

circle-info

Need additional tools? If you need specific data sources or APIs to implement your vault strategy, feel free to reach out to us. We're actively expanding the tool library based on community needs.


4. How to Integrate

Step 1 β€” Extend FlapAIConsumerBase

Your contract must inherit FlapAIConsumerBase and implement three members:

Step 2 β€” Submit a Reasoning Request

The vault triggers reason() inside receive(). An internal _shouldReason() method encapsulates the go/no-go logic (balance threshold, cooldown, etc.) so the receive() body stays clean:

Cost note: reason() does not refund excess msg.value. Overpayment becomes protocol revenue. Always pass exactly model.price (or query it on-chain first).

Step 3 β€” Verify a Fulfilled Request

After the oracle calls back, the full reasoning proof is available on-chain forever:

Step 4 β€” Override _getFlapAIProvider() for Testing

In tests or on unsupported chains, override the address resolver:

Full Example β€” Minimal Consumer


5. References

IFlapAIProvider.sol

Last updated