Skip to content

marcusrein/FDS-Workshop-Repo

Repository files navigation

File Data Sources Workshop 2023

Top Slide

  • This repo has a fully functional subgraph that implements File Data Sources and Full Text Search.
  • For this workshop, I used this address and this metadata from the Beanz NFT collection.
  • Clone and deploy this repo's subgraph to start tinkering with File Data Sources.

Prerequisites

  • Install graph-cli: yarn global add @graphprotocol/graph-cli

Option 1: Deploy This Repo's Premade File Data Sources Subgraph

  • Create a subgraph through Subgraph Studio but do not deploy it just yet. Instead of deploying a boilerplate subgraph, you'll be deploying this repo's subgraph to your newly created Subgraph Studio dashboard.

  • Clone this repo, then yarn install.

  • Copy/paste the Authentication Key from Subgraph Studio into your terminal and authenticate your computer.

  • cd <yourSubgraphFolder> from this repo and copy/paste the graph deploy --studio <nameOfYourSubgraph> from Subgraph Studio into your terminal to deploy this repo's subgraph.

  • Wait 20-30 min for the subgraph to index IPFS. Once indexed, you will not have to wait this long again.

  • Begin querying our File Data Sources subgraph!

  • This repo's subgraph has Full Text Search feature integrated as its quite useful when querying NFT Metadata.

Option 2: Deploy a File Data Sources Endabled Subgraph That Indexes A Different NFT

Use a NFT marketplace like Opensea to find an NFT and gather its contract address and open its link to its IPFS metadata.

You can find this data on each NFT on Opensea by navigating to a specific NFT, clicking on its details -> contract address and token ID.

Details

Use Miniscan to find important information relevant to your subgraph (smart contract name, ABI, startblock).

2. Go to Subgraph Studio, and build a new subgraph

  • Follow the instructions in Subgraph Studio to spin up a new subgraph on your local computer using graph-cli.

  • Enter information gathered from MiniScan about your smart contract into graph-cli as prompted.

  • Choose "yes" when asked if wanting to index events as entites.

  • graph deploy... to deploy your subgraph

Review and update key files in your scaffolded subgraph:

  • subgraph.yaml (Subgraph Manifest)
  • src/mappings.ts (Subgraph Logic)
  • schema.graphql (Presented Subgraph Data)
  • Refer to documentation and the subgraph in this repo for specific changes and techniques.

Option 3: Build With Data Edge Contracts

// SPDX-License-Identifier: GPL-2.0-or-later

pragma solidity ^0.8.12;

/// @title Data Edge contract is only used to store on-chain data, it does not
///        perform execution. On-chain client services can read the data
///        and decode the payload for different purposes.
///        NOTE: This version emits an event with the calldata.
contract EventfulDataEdge {
    event Log(bytes data);

    /// @dev Fallback function, accepts any payload
    fallback() external payable {
        emit Log(msg.data);
    }
}

Official File Data Sources Documentation

Other good subgraphs:

Other resources


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published