Docs
Arama⌘ K
  • Ana sayfa
  • Graph Hakkında
  • Desteklenen Ağlar
  • Protocol Contracts
  • Subgraph'ler
    • Substream'ler
      • Token API
        • AI Suite
          • Endeksleme
            • Kaynaklar
              Subgraph'ler > How-to Guides

              7 dakika

              NEAR Üzerinde Subgraphlar Oluşturma

              This guide is an introduction to building Subgraphs indexing smart contracts on the NEAR blockchain⁠.

              NEAR Nedir?

              NEAR⁠, merkezi olmayan uygulamalar geliştirmek için kullanılan bir akıllı sözleşme platformudur. Daha fazla bilgi için resmi dokümantasyona⁠ bakabilirsiniz.

              What are NEAR Subgraphs?

              The Graph gives developers tools to process blockchain events and make the resulting data easily available via a GraphQL API, known individually as a Subgraph. Graph Node⁠ is now able to process NEAR events, which means that NEAR developers can now build Subgraphs to index their smart contracts.

              Subgraphs are event-based, which means that they listen for and then process onchain events. There are currently two types of handlers supported for NEAR Subgraphs:

              • Blok işleyicileri: Bunlar her yeni blokta çalışır
              • Makbuz işleyicileri: Belirli bir hesapta her mesaj yürütüldüğünde çalışır

              NEAR dokümantasyonundan⁠:

              Makbuz, sistemdeki eyleme geçirilebilir tek nesnedir. NEAR platformunda “bir işlemin işlenmesinden” bahsettiğimizde, bu nihayetinde bir noktada “makbuzların uygulanması” anlamına gelir.

              NEAR Subgraph’ı Oluşturma

              @graphprotocol/graph-cli is a command-line tool for building and deploying Subgraphs.

              @graphprotocol/graph-ts is a library of Subgraph-specific types.

              NEAR Subgraph development requires graph-cli above version 0.23.0, and graph-ts above version 0.23.0.

              Building a NEAR Subgraph is very similar to building a Subgraph that indexes Ethereum.

              There are three aspects of Subgraph definition:

              subgraph.yaml: the Subgraph manifest, defining the data sources of interest, and how they should be processed. NEAR is a new kind of data source.

              schema.graphql: a schema file that defines what data is stored for your Subgraph, and how to query it via GraphQL. The requirements for NEAR Subgraphs are covered by the existing documentation.

              AssemblyScript Eşlemeleri: Olay verisini, şemanızda tanımlanan varlıklara dönüştüren AssemblyScript kodudur. NEAR desteği, NEAR’a özgü veri türleri ve yeni JSON ayrıştırma işlevi sunar.

              During Subgraph development there are two key commands:

              1$ graph codegen # generates types from the schema file identified in the manifest2$ graph build # generates Web Assembly from the AssemblyScript files, and prepares all the Subgraph files in a /build folder

              Subgraph Manifest Tanımı

              The Subgraph manifest (subgraph.yaml) identifies the data sources for the Subgraph, the triggers of interest, and the functions that should be run in response to those triggers. See below for an example Subgraph manifest for a NEAR Subgraph:

              1specVersion: 1.3.02schema:3  file: ./src/schema.graphql # link to the schema file4dataSources:5  - kind: near6    network: near-mainnet7    source:8      account: app.good-morning.near # This data source will monitor this account9      startBlock: 10662188 # Required for NEAR10    mapping:11      apiVersion: 0.0.912      language: wasm/assemblyscript13      blockHandlers:14        - handler: handleNewBlock # the function name in the mapping file15      receiptHandlers:16        - handler: handleReceipt # the function name in the mapping file17      file: ./src/mapping.ts # link to the file with the Assemblyscript mappings
              • NEAR Subgraphs introduce a new kind of data source (near)
              • network, subgraph’i sunan Graph Düğümü üzerindeki bir ağa karşılık gelmelidir. Subgraph Studio’da, NEAR’ın ana ağı near-mainnet, ve NEAR’ın test ağı near-testnet’tir
              • NEAR veri kaynakları, NEAR hesabı⁠ ile ilişkili, insan tarafından okunabilir bir kimlik olan isteğe bağlı source.account alanını sunar. Bu, bir hesap veya alt hesap olabilir.
              • NEAR veri kaynakları, isteğe bağlı ek source.accounts alanını tanıtır. Bu alan isteğe bağlı sonekler ve önekler içerir. En azından bir önek veya sonek belirtilmelidir. Bu ekler ilgili listedeki değerlerle başlayan veya biten herhangi bir hesabı eşleştirirler. Aşağıdaki örnek şunlarla eşleşecektir: [app|good].*[morning.near|morning.testnet]. Sadece önekler veya sonekler listesi gerekiyorsa diğer alan atlanabilir.
              1accounts:2  prefixes:3    - app4    - good5  suffixes:6    - morning.near7    - morning.testnet

              NEAR veri kaynakları iki tür işleyiciyi destekler:

              • blockHandlers: her yeni NEAR blokunda çalıştırılır. source.account gerekli değildir.
              • receiptHandlers: veri kaynağının source.account’unun alıcı olduğu her makbuzda çalışır. Makbuz (receipt) teknik bir kavramdır, daha detaylı bilgi için NEAR dokümanlarını inceleyebilirsiniz. Bu noktada, yalnızca tam eşleşmelerin işlendiğine dikkat edin. (Alt hesaplar⁠ bağımsız veri kaynakları olarak eklenmelidir).

              Şema Tanımı

              Schema definition describes the structure of the resulting Subgraph database and the relationships between entities. This is agnostic of the original data source. There are more details on Subgraph schema definition here.

              AssemblyScript Eşlemeleri

              Olayları işlemek için kullanılan işleyiciler AssemblyScript⁠ ile yazılmıştır.

              NEAR endeksleme, AssemblyScript API için NEAR’a özgü veri türlerini tanıtır.

              1class ExecutionOutcome {2      gasBurnt: u64,3      blockHash: Bytes,4      id: Bytes,5      logs: Array<string>,6      receiptIds: Array<Bytes>,7      tokensBurnt: BigInt,8      executorId: string,9  }1011class ActionReceipt {12      predecessorId: string,13      receiverId: string,14      id: CryptoHash,15      signerId: string,16      gasPrice: BigInt,17      outputDataReceivers: Array<DataReceiver>,18      inputDataIds: Array<CryptoHash>,19      actions: Array<ActionValue>,20  }2122class BlockHeader {23      height: u64,24      prevHeight: u64,// Always zero when version < V325      epochId: Bytes,26      nextEpochId: Bytes,27      chunksIncluded: u64,28      hash: Bytes,29      prevHash: Bytes,30      timestampNanosec: u64,31      randomValue: Bytes,32      gasPrice: BigInt,33      totalSupply: BigInt,34      latestProtocolVersion: u32,35  }3637class ChunkHeader {38      gasUsed: u64,39      gasLimit: u64,40      shardId: u64,41      chunkHash: Bytes,42      prevBlockHash: Bytes,43      balanceBurnt: BigInt,44  }4546class Block {47      author: string,48      header: BlockHeader,49      chunks: Array<ChunkHeader>,50  }5152class ReceiptWithOutcome {53      outcome: ExecutionOutcome,54      receipt: ActionReceipt,55      block: Block,56  }

              Bu türler blok & makbuz işleyicilerine aktarılır:

              • Blok işleyiciler bir Block alacaktır
              • Makbuz işleyiciler bir ReceiptWithOutcome alacaktır

              Otherwise, the rest of the AssemblyScript API is available to NEAR Subgraph developers during mapping execution.

              Bu, yeni bir JSON ayrıştırma fonksiyonunu içerir - NEAR üzerindeki günlükler sıklıkla dizeleştirilmiş JSON olarak yayılır. Geliştiricilerin bu günlükleri kolayca işlemelerine olanak tanımak için JSON API kapsamında yeni bir json.fromString(...) fonksiyonu mevcuttur.

              NEAR Subgraph’ını Dağıtma

              Once you have a built Subgraph, it is time to deploy it to Graph Node for indexing. NEAR Subgraphs can be deployed to any Graph Node >=v0.26.x (this version has not yet been tagged & released).

              The Graph Ağı’ndaki Subgraph Studio ve yükseltme Endeksleyicisi şu anda beta olarak NEAR ana ağı ve test ağını endekslemeyi, aşağıdaki ağ isimleriyle desteklemektedir:

              • near-mainnet
              • near-testnet

              More information on creating and deploying Subgraphs on Subgraph Studio can be found here.

              As a quick primer - the first step is to “create” your Subgraph - this only needs to be done once. On Subgraph Studio, this can be done from your Dashboard: “Create a Subgraph”.

              Once your Subgraph has been created, you can deploy your Subgraph by using the graph deploy CLI command:

              1$ graph create --node <graph-node-url> <subgraph-name> # creates a Subgraph on a local Graph Node (on Subgraph Studio, this is done via the UI)2$ graph deploy --node <graph-node-url> --ipfs https://ipfs.thegraph.com <subgraph-name> # uploads the build files to a specified IPFS endpoint, and then deploys the Subgraph to a specified Graph Node based on the manifest IPFS hash

              The node configuration will depend on where the Subgraph is being deployed.

              Subgraph Stüdyosu

              1graph auth2graph deploy <subgraph-ismi>

              Yerel Graph Düğümü (varsayılan yapılandırmaya göre)

              1graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 <subgraph-ismi>

              Once your Subgraph has been deployed, it will be indexed by Graph Node. You can check its progress by querying the Subgraph itself:

              1{2  _meta {3    block {4      number5    }6  }7}

              NEAR’ı Yerel Graph Düğümü ile İndeksleme

              NEAR’ı indeksleyen bir Graph Düğümü çalıştırmanın aşağıdaki operasyonel gereksinimleri vardır:

              • Firehose enstrümantasyonu ile NEAR İndeksleyici Çerçevesi
              • NEAR Firehose Bileşen(ler)i
              • Firehose uç noktası yapılandırılmış Graph Düğümü

              Yukarıdaki bileşenlerin çalıştırılması hakkında yakında daha fazla bilgi vereceğiz.

              NEAR Subgraph’ını Sorgulama

              The GraphQL endpoint for NEAR Subgraphs is determined by the schema definition, with the existing API interface. Please visit the GraphQL API documentation for more information.

              Örnek Subgraph’ler

              Here are some example Subgraphs for reference:

              NEAR Blokları⁠

              NEAR Makbuzları⁠

              FAQ

              Beta nasıl çalışır?

              NEAR support is in beta, which means that there may be changes to the API as we continue to work on improving the integration. Please email [email protected]⁠ so that we can support you in building NEAR Subgraphs, and keep you up to date on the latest developments!

              Can a Subgraph index both NEAR and EVM chains?

              No, a Subgraph can only support data sources from one chain/network.

              Can Subgraphs react to more specific triggers?

              Şu anda yalnızca Blok ve Makbuz tetikleyicileri desteklenmektedir. Belirli bir hesaba yapılan fonksiyon çağrıları için tetikleyicileri araştırma aşamasındayız. NEAR yerel olay desteğine sahip oldu takdirde, olay tetikleyicilerini desteklemekle de ilgileneceğiz.

              Makbuz işleyicileri hesaplar ve bunların alt hesapları için tetiklenecek mi?

              Bir account belirtildiyse, yalnızca tam hesap adı eşleştirilecektir. accounts alanı belirterek alt hesapları eşleştirmek mümkündür. suffixes (önekleri) ve prefixes’i (sonekleri) ve accounts alanını da belirterek, alt hesapları eşleştirmek mümkündür. Örneğin, aşağıdaki mintbase1.near alt hesaplarının tümünü eşleştirecektir:

              1accounts:2  suffixes:3    - mintbase1.near

              Can NEAR Subgraphs make view calls to NEAR accounts during mappings?

              Bu desteklenmemektedir. Bu fonksiyonelliğin indeksleme için gerekli olup olmadığını değerlendiriyoruz.

              Can I use data source templates in my NEAR Subgraph?

              Bu şu anda desteklenmemektedir. Bu fonksiyonelliğin indeksleme için gerekli olup olmadığını değerlendiriyoruz.

              Ethereum Subgraphs support “pending” and “current” versions, how can I deploy a “pending” version of a NEAR Subgraph?

              Pending functionality is not yet supported for NEAR Subgraphs. In the interim, you can deploy a new version to a different “named” Subgraph, and then when that is synced with the chain head, you can redeploy to your primary “named” Subgraph, which will use the same underlying deployment ID, so the main Subgraph will be instantly synced.

              My question hasn’t been answered, where can I get more help building NEAR Subgraphs?

              If it is a general question about Subgraph development, there is a lot more information in the rest of the Developer documentation. Otherwise please join The Graph Protocol Discord⁠ and ask in the #near channel or email [email protected]⁠.

              Referanslar

              • NEAR geliştirici dokümantasyonu⁠
              ⁠GitHub'da Düzenle⁠

              Fork Kullanarak Hızlı ve Kolay Subgraph Hata AyıklamaArweave Üzerinde Subgraphlar Oluşturma
              Bu sayfada
              • NEAR Nedir?
              • What are NEAR Subgraphs?
              • NEAR Subgraph’ı Oluşturma
              • Subgraph Manifest Tanımı
              • Şema Tanımı
              • AssemblyScript Eşlemeleri
              • NEAR Subgraph’ını Dağıtma
              • Subgraph Stüdyosu
              • Yerel Graph Düğümü (varsayılan yapılandırmaya göre)
              • NEAR’ı Yerel Graph Düğümü ile İndeksleme
              • NEAR Subgraph’ını Sorgulama
              • Örnek Subgraph’ler
              • FAQ
              • Beta nasıl çalışır?
              • Can a Subgraph index both NEAR and EVM chains?
              • Can Subgraphs react to more specific triggers?
              • Makbuz işleyicileri hesaplar ve bunların alt hesapları için tetiklenecek mi?
              • Can NEAR Subgraphs make view calls to NEAR accounts during mappings?
              • Can I use data source templates in my NEAR Subgraph?
              • Ethereum Subgraphs support “pending” and “current” versions, how can I deploy a “pending” version of a NEAR Subgraph?
              • My question hasn’t been answered, where can I get more help building NEAR Subgraphs?
              • Referanslar
              The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service