Live · BNB Mainnet

Flap AI Oracle

A standardized on-chain AI Oracle — just 3 steps to give any smart contract access to verifiable LLM reasoning, via a commit-and-reveal scheme.

Purpose-built for AI-powered Flap Vaults — bringing verifiable on-chain LLM reasoning to any contract on BNB Chain.

The Problem

Why Do We Need Flap AI Oracle?

Every "AI token" today is a black box. Projects claim "the AI automatically protects the floor" — but behind the scenes, it's just a guy clicking buttons.

This "trust me bro" model is the biggest lie in the AI crypto space.

Flap AI Oracle was built to fix this.

How It Works

How It Works

Three simple principles — build your prompt on-chain, let us handle the AI, and get back a verified decision.

01

Construct Your Prompt On-Chain

You write the full prompt directly in your smart contract — token address, objective, market context, and decision options. Everything is transparent and verifiable on-chain.

02

Call Our Contract — We Handle the Rest

Pass the prompt to FlapAIProvider with a fee. We handle LLM routing, proof generation, and deliver the verified result back to your contract via callback.

03

Tool Calling for Live External Data

Our AI can invoke tools during inference — like fetching live token market data — to make decisions grounded in real-time context, not stale assumptions.

See It in Action

A real example: an AI vault autonomously managing market making for a token.

📝 Prompt (constructed on-chain)

I am managing a vault for token 0x....7777, my main goal is to use my fund to do market making for this token. Check the market data (use ave_token_info) of this token and then decide what to do: (0) buy tokens to support the floor (1) sell my holdings to gain more funds for future market making (2) generate volumes only (i.e: buy and then sell immediately). You must choose exactly one option. Reply with a single integer: 0 to buy, 1 to sell, 2 to generate volumes.

🤖 AI Reasoning
Step 1 · Tool Callave_token_info

I'm starting by querying the ave_token_info function for the specified token. My immediate goal is to understand the current price trends and volume metrics. This initial data will heavily influence my decision-making process, specifically the selection between supporting the floor, selling holdings, or simply focusing on generating volumes.

Step 2 · Decision

I've considered the market data for XXX, observing the significant 24-hour price drop and the more recent stabilization. The volume/market cap ratio is also relevant. Given the double-digit drop, I leaned towards supporting the floor (Option 0) to stabilize the price. Though generating volume (Option 2) offers a way to keep the token active, supporting the floor is more appropriate for the circumstances.

0

✅ Result Delivered On-Chain

Buy tokens to support the floor

3 Simple Steps

Extend FlapAIConsumerBase, call reason(), handle the callback.

MarketMakingVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {FlapAIConsumerBase, IFlapAIProvider}
    from "src/plugins/AIProvider/IFlapAIProvider.sol";

contract MarketMakingVault is FlapAIConsumerBase {
    address public immutable TOKEN = 0x00000000000000000000000000000000000077777;

    uint256 private _lastRequestId;
    uint256 private _lastReasoningBlock;

    // Rate-limit: at most one AI call per ~1 200 blocks
    uint256 constant REASON_COOLDOWN = 1200;

    function lastRequestId() public view override returns (uint256) {
        return _lastRequestId;
    }

    function _shouldReason() internal view returns (bool) {
        if (_lastRequestId != 0) return false;       // request pending
        if (block.number < _lastReasoningBlock + REASON_COOLDOWN) return false;
        return true;
    }

    // Triggered on every incoming BNB; ask AI only when cooldown passed
    receive() external payable {
        if (!_shouldReason()) return;

        IFlapAIProvider p = IFlapAIProvider(_getFlapAIProvider());
        uint256 fee = p.getModel(0).price; // gemini-flash

        // Prompt built entirely on-chain — AI will call ave_token_info
        // to fetch live market data before deciding
        string memory prompt = string.concat(
            "I am managing a vault for token ",
            _toHexString(TOKEN),
            ", my main goal is to use my fund to do market making for this token. "
            "Check the market data (use ave_token_info) of this token and then "
            "decide what to do: "
            "(0) buy tokens to support the floor "
            "(1) sell my holdings to gain more funds for future market making "
            "(2) generate volumes only (i.e: buy and then sell immediately). "
            "You must choose exactly one option. "
            "Reply with a single integer: 0 to buy, 1 to sell, 2 to generate volumes."
        );

        _lastRequestId      = p.reason{value: fee}(0, prompt, 3);
        _lastReasoningBlock = block.number;
    }

    // AI decision arrives here after ave_token_info tool call + reasoning
    function _fulfillReasoning(uint256 id, uint8 choice)
        internal override
    {
        require(id == _lastRequestId);
        _lastRequestId = 0;
        if      (choice == 0) _buyTokens();          // support the floor
        else if (choice == 1) _sellHoldings();       // accumulate BNB
        else if (choice == 2) _generateVolume();     // buy then sell
    }

    function _onFlapAIRequestRefunded(uint256 id) internal override {
        require(id == _lastRequestId);
        _lastRequestId = 0; // cooldown still applies; will retry later
    }
}
🏦

Designed for Flap Vaults

Flap AI Oracle was originally created to unlock AI-driven decision-making inside Flap Tax Vaults — letting on-chain vaults autonomously decide when to buy back tokens, hold, or distribute revenue based on live LLM reasoning. Every decision is verifiable on-chain via an IPFS proof, giving token holders full transparency.

The oracle is chain-agnostic by design and can be integrated into any smart contract — not just vaults.

Ready to build
AI-powered contracts?

Check out the full documentation, integration guide, and Solidity reference for Flap AI Oracle.