Coder Social home page Coder Social logo

fds-workshop-repo's Introduction

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


fds-workshop-repo's People

Contributors

marcusrein avatar

Stargazers

Chidubem Okeke avatar Kevin J avatar Satoshi Okamoto avatar Arturo Mena Maekawa avatar

Watchers

 avatar

fds-workshop-repo's Issues

assigning value to token.owner: only executes once

In the mapping file beanz.ts, the value of token.owner is assigned like this:

token.owner = event.params.to.toHexString();

This is currently happening inside the if (!token) block, so this will assign the owner the first time a token appears in Transfer events.
But it won't update the owner in any subsequent Transfer events.

Should move line outside of the if (!token) block, just before saving the token entity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.