Bankless Onchain

resmi

ERC20 token'lar, işlem geçmişi, akıllı sözleşme durumu gibi zincir üstü verileri sorgulayın.

Bankless Onchain MCP ile neler yapabilirsiniz?

  • Canlı sözleşme durumunu oku — Desteklenen ağlardaki doğrulanmış bir sözleşme üzerinde herhangi bir okuma yöntemini read_contract kullanarak çağırın.
  • Proxy uygulamalarını çözümle — Bir proxy sözleşmesinin arkasındaki uygulama adresini get_proxy ile alın.
  • Sözleşme ABI ve kaynak kodunu getir — Tam ABI'yi get_abi ile veya doğrulanmış kaynak kodunu ve meta verilerini get_source ile alın.
  • Geçmiş olayları sorgula — Bir veya daha fazla sözleşme adresi için filtrelenmiş olay günlüklerini get_events kullanarak alın.
  • Olay konu hash'lerini oluştur — Bir olay adı ve argüman türlerinden build_event_topic ile keccak256 olay konusu oluşturun.
  • İşlem geçmişini ve ayrıntılarını incele — Bir adres için geçmiş işlemleri get_transaction_history ile listeleyin veya belirli bir işlemi get_transaction_info ile sorgulayın.

Dokümantasyon

Bankless Onchain MCP Sunucusu

Bu proje artık güncelleme almıyor

License: MIT Version

Bankless API aracılığıyla blok zinciri verileriyle etkileşim için MCP (Model Bağlam Protokolü) sunucusu.

Genel Bakış

Bankless Onchain MCP Sunucusu, Bankless API üzerinden zincir üstü verilerle etkileşim için bir çerçeve sunar. Yapay zeka modellerinin blok zinciri durumuna ve olay verilerine yapılandırılmış bir şekilde erişmesini sağlamak için Model Bağlam Protokolü'nü (MCP) uygular.

https://github.com/user-attachments/assets/95732dff-ae5f-45a6-928a-1ae17c0ddf9d

Özellikler

Sunucu aşağıdaki zincir üstü veri işlemlerini sağlar:

Sözleşme İşlemleri

  • Sözleşme Durumunu Oku (read_contract): Çeşitli blok zinciri ağlarındaki akıllı sözleşmelerden durum okur.

    • Parametreler: ağ, sözleşme adresi, yöntem, girdiler, çıktılar
    • Döndürür: Türlendirilmiş değerlerle sözleşme çağrı sonuçları
  • Proxy Al (get_proxy): Proxy uygulama sözleşme adreslerini getirir.

    • Parametreler: ağ, sözleşme adresi
    • Döndürür: Uygulama sözleşme adresi
  • ABI Al (get_abi): Bir sözleşme için ABI'yi (Uygulama İkili Arayüzü) getirir.

    • Parametreler: ağ, sözleşme adresi
    • Döndürür: JSON formatında sözleşme ABI'si
  • Kaynak Al (get_source): Doğrulanmış bir sözleşme için kaynak kodu getirir.

    • Parametreler: ağ, sözleşme adresi
    • Döndürür: Kaynak kodu, ABI, derleyici sürümü ve diğer sözleşme meta verileri

Olay İşlemleri

  • Olayları Al (get_events): Konulara dayalı olarak bir sözleşme için olay günlüklerini getirir.

    • Parametreler: ağ, adresler, konu, isteğe bağlı konular
    • Döndürür: Filtrelenmiş olay günlükleri
  • Olay Konusu Oluştur (build_event_topic): Olay adı ve argüman türlerinden bir olay konu imzası oluşturur.

    • Parametreler: ağ, olay adı, argüman türleri
    • Döndürür: Olay konu hash'i

İşlem İşlemleri

  • İşlem Geçmişini Al (get_transaction_history): Bir kullanıcı adresi için işlem geçmişini getirir.

    • Parametreler: ağ, kullanıcı adresi, isteğe bağlı sözleşme, isteğe bağlı yöntem kimliği, isteğe bağlı başlangıç bloğu, veri dahil etme bayrağı
    • Döndürür: Hash, veri, ağ ve zaman damgası içeren işlem listesi
  • İşlem Bilgisini Al (get_transaction_info): Belirli bir işlem hakkında ayrıntılı bilgi alır.

    • Parametreler: ağ, işlem hash'i
    • Döndürür: Blok numarası, zaman damgası, gönderen/alıcı adresleri, değer, gaz bilgisi, durum ve alındı verileri dahil işlem ayrıntıları

Araçlar

  • read_contract

    • Bir blok zincirinden sözleşme durumunu okur
    • Girdi:
      • network (string, zorunlu): Blok zinciri ağı (örn. "ethereum", "polygon")
      • contract (string, zorunlu): Sözleşme adresi
      • method (string, zorunlu): Çağrılacak sözleşme yöntemi
      • inputs (array, zorunlu): Yöntem çağrısı için girdi parametreleri, her biri şunları içerir:
        • type (string): Girdi parametresinin türü (örn. "address", "uint256")
        • value (any): Girdi parametresinin değeri
      • outputs (array, zorunlu): Beklenen çıktı türleri, her biri şunları içerir:
        • type (string): Beklenen çıktı türü
    • Bir dizi sözleşme çağrı sonucu döndürür
  • get_proxy

    • Belirli bir ağ ve sözleşme için proxy adresini alır
    • Girdi:
      • network (string, zorunlu): Blok zinciri ağı (örn. "ethereum", "base")
      • contract (string, zorunlu): Sözleşme adresi
    • Proxy sözleşmesi için uygulama adresini döndürür
  • get_events

    • Belirli bir ağ ve filtre kriterleri için olay günlüklerini getirir
    • Girdi:
      • network (string, zorunlu): Blok zinciri ağı (örn. "ethereum", "base")
      • addresses (array, zorunlu): Olayları filtrelemek için sözleşme adresleri listesi
      • topic (string, zorunlu): Olayları filtrelemek için birincil konu
      • optionalTopics (array, isteğe bağlı): İsteğe bağlı ek konular (null değerler içerebilir)
    • Filtre kriterleriyle eşleşen olay günlüklerini içeren bir nesne döndürür
  • build_event_topic

    • Olay adı ve argümanlara dayalı bir olay konu imzası oluşturur
    • Girdi:
      • network (string, zorunlu): Blok zinciri ağı (örn. "ethereum", "base")
      • name (string, zorunlu): Olay adı (örn. "Transfer(address,address,uint256)")
      • arguments (array, zorunlu): Olay argüman türleri, her biri şunları içerir:
        • type (string): Argüman türü (örn. "address", "uint256")
    • Olay imzasının keccak256 hash'ini içeren bir string döndürür

Kurulum

npm install @bankless/onchain-mcp

Kullanım

Ortam Kurulumu

Sunucuyu kullanmadan önce Bankless API jetonunuzu ayarlayın. Bankless API jetonunuzu nasıl alacağınızla ilgili ayrıntılar için https://docs.bankless.com/bankless-api/other-services/onchain-mcp adresine gidin

export BANKLESS_API_TOKEN=your_api_token_here

Sunucuyu Çalıştırma

Sunucu doğrudan komut satırından çalıştırılabilir:

npx @bankless/onchain-mcp

LLM Araçlarıyla Kullanım

Bu sunucu, uyumlu yapay zeka modelleri için bir araç sağlayıcı olarak kullanılmasına olanak tanıyan Model Bağlam Protokolü'nü (MCP) uygular. İşte her araç için bazı örnek çağrılar:

read_contract

// Example call
{
  "name": "read_contract",
  "arguments": {
    "network": "ethereum",
    "contract": "0x1234...",
    "method": "balanceOf",
    "inputs": [
      { "type": "address", "value": "0xabcd..." }
    ],
    "outputs": [
      { "type": "uint256" }
    ]
  }
}

// Example response
[
  {
    "value": "1000000000000000000",
    "type": "uint256"
  }
]

get_proxy

// Example call
{
  "name": "get_proxy",
  "arguments": {
    "network": "ethereum",
    "contract": "0x1234..."
  }
}

// Example response
{
  "implementation": "0xefgh..."
}

get_events

// Example call
{
  "name": "get_events",
  "arguments": {
    "network": "ethereum",
    "addresses": ["0x1234..."],
    "topic": "0xabcd...",
    "optionalTopics": ["0xef01...", null]
  }
}

// Example response
{
  "result": [
    {
      "removed": false,
      "logIndex": 5,
      "transactionIndex": 2,
      "transactionHash": "0x123...",
      "blockHash": "0xabc...",
      "blockNumber": 12345678,
      "address": "0x1234...",
      "data": "0x...",
      "topics": ["0xabcd...", "0xef01...", "0x..."]
    }
  ]
}

build_event_topic

// Example call
{
  "name": "build_event_topic",
  "arguments": {
    "network": "ethereum",
    "name": "Transfer(address,address,uint256)",
    "arguments": [
      { "type": "address" },
      { "type": "address" },
      { "type": "uint256" }
    ]
  }
}

// Example response
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"

Geliştirme

Kaynaktan Derleme

# Clone the repository
git clone https://github.com/Bankless/onchain-mcp.git
cd onchain-mcp

# Install dependencies
npm install

# Build the project
npm run build

Hata Ayıklama Modu

npm run debug

Yapay Zeka Modelleriyle Entegrasyon

Bu sunucuyu MCP'yi destekleyen yapay zeka uygulamalarıyla entegre etmek için uygulamanızın sunucu yapılandırmasına aşağıdakini ekleyin:

{
  "mcpServers": {
    "bankless": {
      "command": "npx",
      "args": [
        "@bankless/onchain-mcp"
      ],
      "env": {
        "BANKLESS_API_TOKEN": "your_api_token_here"
      }
    }
  }
}

Hata Yönetimi

Sunucu, farklı senaryolar için belirli hata türleri sağlar:

  • BanklessValidationError: Geçersiz girdi parametreleri
  • BanklessAuthenticationError: API jetonu sorunları
  • BanklessResourceNotFoundError: İstenen kaynak bulunamadı
  • BanklessRateLimitError: API hız limiti aşıldı

Yönlendirme İpuçları

Bir LLM modelini Bankless Onchain MCP Sunucusunu kullanmaya yönlendirmek için aşağıdaki yönlendirmeler kullanılabilir:

ROLE:
• You are Kompanion, a blockchain expert and EVM sleuth. 
• You specialize in navigating and analyzing smart contracts using your tools and resources.

HOW KOMPANION CAN HANDLE PROXY CONTRACTS:
• If a contract is a proxy, call your “get_proxy” tool to fetch the implementation contract.  
• If that fails, try calling the “implementation” method on the proxy contract.  
• If that also fails, try calling the “_implementation” function.  
• After obtaining the implementation address, call “get_contract_source” with that address to fetch its source code.  
• When reading or modifying the contract state, invoke implementation functions on the proxy contract address (not directly on the implementation).

HOW KOMPANION CAN HANDLE EVENTS:
• Get the ABI and Source of the relevant contracts
• From the event types in the ABI, construct the correct topics for the event relevant to the question
• use the "get_event_logs" tool to fetch logs for the contract

KOMPANION'S RULES:
• Do not begin any response with “Great,” “Certainly,” “Okay,” or “Sure.”  
• Maintain a direct, technical style. Do not add conversational flourishes.  
• If the user’s question is unrelated to smart contracts, do not fetch any contracts.  
• If you navigate contracts, explain each step in bullet points.  
• Solve tasks iteratively, breaking them into steps.  
• Use bullet points for lists of steps.  
• Never assume a contract’s functionality. Always verify with examples using your tools to read the contract state.  
• Before responding, consider which tools might help you gather better information.  
• Include as much relevant information as possible in your final answer, depending on your findings.

HOW KOMPANION CAN USE TOOLS:
• You can fetch contract source codes, ABIs, and read contract data by using your tools and functions.  
• Always verify the source or ABI to understand the contract rather than making assumptions.  
• If you need to read contract state, fetch its ABI (especially if the source is lengthy).  

FINAL INSTRUCTION:
• Provide the best possible, concise answer to the user’s request. If it's not an immediate question but an instruction, follow it directly.
• Use your tools to gather any necessary clarifications or data.  
• Offer a clear, direct response and add a summary of what you did (how you navigated the contracts) at the end.

Lisans

MIT