Just built SecureApiGateway on @GenLayer which is a smart contract that brings real-world data on-chain through AI verification!
It fetches live weather , crypto prices, and news sentiment using multiple AI models which check every data point before it goes on the blockchain.
This contract (secureApiGateway)solves a problem of regular smart contracts not accessing the outside world as they can't check weather, prices, or news without centralized services like Chainlink. These services need you to trust a company which utterly defeats the point of blockchain.
SecureApiGateway fixes this using GenLayer's Optimistic Democracy, having multiple AI models check the data independently before storing it on-chain, removing the gap of having to trust a company for such services
HOW IT WORKS
Each function uses this special code:
result = gl.eq_principle.prompt_non_comparative(
lambda: input_prompt,
task=task,
criteria=criteria,
)
Here's what happens: 1️⃣ AI models get the request to fetch data 2️⃣ Each model fetches data independently 3️⃣ Models vote on the correct result 4️⃣ Final verified result goes on-chain
Write methods (fetch real-time data):
✅ fetch_weather_data(city) → Gets live weather (temperature, conditions, humidity, wind speed)
✅ fetch_crypto_price(symbol) → Gets crypto prices from CoinGecko, CoinMarketCap, Binance. AI models cross-check to make sure it's accurate.
✅ fetch_news_sentiment(topic) → Reads recent news and tells you if sentiment is positive, negative, or neutral.
Real example - BITCOIN PRICE
I tested fetch_crypto_price("BTC"):
Output:
{
"symbol": "BTC",
"price_usd": 104250.00,
"price_change_24h_percent": -1.25,
"market_cap_usd": 2065000000000.00,
"volume_24h_usd": 45800000000.00,
"last_updated": "2025-01-10T08:30:00Z"
}
What the AI validators said:
✅ Google Gemini: AGREE
❌ Claude Sonnet: DISAGREE (got different price)
❌ GPT-5.1: DISAGREE
❌ Grok-4: DISAGREE
Status: FINALIZED ✅
Even with disagreement, it worked because enough validators agreed. Different AI models might get slightly different prices at different times, but the system still reaches consensus!
WHAT WORKS & WHAT DOESN'T 🌐
🟢 WORKS:
Weather sites
Crypto price sites (CoinGecko, CoinMarketCap, Binance)
News sites (BBC, Reuters)
GitHub
Company websites
Any public website
🔴 BLOCKED:
Twitter/X (needs login)
Facebook (needs login)
Instagram (needs login)
Sites that require passwords
GenLayer can fully read public websites, but can't access sites that need accounts.
SecureApiGateway on genlayer,ensures AI models verify data independently ranging from
Flight Insurance → Auto-pay when the weather sentiment looks perfect for specified trips.
Price Feeds → DeFi apps can get verified prices without having to tap into various main site.
Trading Bots → Trade based on verified news sentiment.
Prediction Markets → Settle bets using real verified data.
All this happening without depending on a particular centralized service data.
The future is been built on AI-powered data verification and you can try it out on GenLayer Studio : https://t.co/lZFSnKEJco ,where you can build and test yours as well .
SecureApiGateway github: https://t.co/Ext0avm51v