Skip to main content

Subgraph Network

Embeded Subgraph

This crawler is designed to capture blockchain events emitted by Smart Contracts on Layer 1 (L1) and embed them directly into the server. By providing a real-time blockchain data feed, this component enables developers to seamlessly access and utilize on-chain data for building their applications.

info

Currently, the crawler is only available in standalone version. Server embedded version is coming soon.

info

For registration and setup process, please contact us for support. We are still in the early stage of development.

Subgraph Network

With the subgraph embedded directly into the server, developers have the option to join the Subgraph Network, allowing them to establish redundancy for their own subgraph data. Additionally, this data is published, enabling other crawler nodes to validate it, thereby enhancing data transparency and integrity within their respective communities.

Nodes that join the Subgraph Network will be rewarded with LayerG tokens for computing resources contribution.

Subgraph Network Concept

  • Subgraph config: Include the subgraph configs:

    • schema.graphql: Define the subgraph schema
    type Item @entity {
    id: ID!
    tokenId: BigInt!
    tokenUri: String!
    standard: String!
    balances: [Balance!]! @derivedFrom(field: "item")
    }

    type Balance
    @entity
    @compositeIndexes(fields: [["item", "owner"], ["item", "value"]]) {
    id: ID! @unique
    item: Item! @index(unique: true)
    owner: User!
    value: BigInt! @index
    updatedAt: BigInt!
    contract: String!
    }

    type MetadataUpdateRecord @entity {
    id: ID!
    tokenId: BigInt!
    actor: User!
    timestamp: BigInt!
    }

    type User @entity {
    id: ID!
    balances: [Balance!]! @derivedFrom(field: "owner")
    }
    • subgraph.yaml: Define the subgraph data sources
    name: "ethereum-starter"
    version: "1.0.0"
    description: "This project serves as a starting point for an Ethereum indexer."
    schema:
    file: "./schema.graphql"
    network:
    name: "nebulas"
    chainId: "2484"
    endpoint:
    - "https://rpc-nebulas-testnet.uniultra.xyz"
    dataSources:
    - kind: EthereumDatasourceKind.Runtime
    startBlock: 16213720
    options:
    address: "0x1b122eff77d9a54d6c773c971f6acb6aaa9f90a8"
    abis:
    - name: "URC721"
    file: "./abis/URC721.json"
    - name: "URC4906"
    file: "./abis/URC4906.json"
    mapping:
    handlers:
    - kind: EthereumHandlerKind.Event
    handler: "HandleTransfer"
    filter:
    topics:
    - "Transfer(address indexed from, address indexed to, uint256 amount)"
    - kind: EthereumHandlerKind.Event
    handler: "MetadataUpdate"
    filter:
    topics:
    - "MetadataUpdate(uint256 tokenId)"
    - kind: EthereumDatasourceKind.Runtime
    startBlock: 16213720
    options:
    address: "0xeddd02437aa5db6def90ff32c329decd2bcb86db"
    abis:
    - name: "URC1155"
    file: "./abis/URC1155.json"
    mapping:
    handlers:
    - kind: EthereumHandlerKind.Event
    handler: "HandleTransferSingle"
    filter:
    topics:
    - "TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)"
    - kind: EthereumHandlerKind.Event
    handler: "HandleTransferBatch"
    filter:
    topics:
    - "TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)"
    repository: "https://github.com/subquery/ethereum-subql-starter"
    • abis: Define the contract ABIs

    For more details, please refer to the Subgraph Network page.

    These subgraph configs are packed and mark with a version before being uploaded.

  • Local database: The server local database

  • Proof of Indexer: Act as the DA Layer for the subgraph network, used for storing proof of data to ensure data integrity, detect discrepancies rapidly, and mitigate potential conflicts within the network

  • Query Service: The query service holds the information whether the subgraph data is valid, and it holds knows which node to query for the data given the subgraph config.