npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@airstack/subgraph-generator

v1.0.0-alpha.9

Published

Integrate Airstack schemas in any subgraph.

Downloads

68

Readme

Airstack Subgraphs

Introduction

Airstack is a web3 developer platform that provides powerful APIs for integrating on-chain and off-chain data into any application. With Airstack developers are able to easily connect their applications to the web3 ecosystem.

Airstack enables GraphQL queries that combine on-chain and off-chain data from multiple sources in a single response. Our goal is to enable developers to query and integrate relevant web3 data, and serve it up to users without requiring heavy infrastructure or even a back-end.

Airstack identity APIs map addresses and transactions across various sources, including: ENS, Farcaster, Lens, POAP, Dapps, and Marketplaces.

Airstack Substreams & Subgraphs

Airstack is a pioneer in utilizing Substreams to index on-chain transactions faster than RPC-based solutions. Substreams are used for real-time indexing of on-chain events and for high volume blockchains such as Polygon. Airstack Substreams are hosted in-house on our infra.

Airstack deploys Subgraphs with custom schemas for indexing historical events and sales data from specific dapps, marketplaces and protocols. Airstack subgraphs are hosted in-house on our infra.

Airstack schemas for Substreams and Subgraphs define how events and transactions are indexed, aggregated, and consumed across projects in standard formats, enabling seamless querying of like data across projects and chains. Example verticals: NFT Marketplace, Social, DAOs, DeFi.

Airstack augments on-chain data with off-chain metadata from IPFS, dapps and marketplaces (for example NFT images and descriptions). Wherever possible we default to on-chain data.

Data is stored in the Airstack backend and optimized with parallel processing for fast GraphQL querying.

Getting Started

1. Prerequisite:

You already have a subgraph for Dapp/Protocol. And you intend to integrate Airstack schemas into the project.

2. Install Airstack package:

npm install @airstack/subgraph-generator

3. Identify the vertical for the Dapp/Protocol:

We support

  • NFT Marketplace: nft-marketplace
  • Domain Name: domain-name
  • DEX: dex
  • Bridges: TBD
  • DAO: TBD
  • Defi: TBD
  • Games: TBD

Use the following command to add Airstack Schemas and Modules in your project

npx  @airstack/subgraph-generator <vertical>  --yaml <subgraph.yaml file path> --graphql <schema.graphql file path> --dataSourceNames <"name1, name2, ..."> --templates <"name1, name2">

Examples:

a. NFT Marketplace

npx @airstack/subgraph-generator nft-marketplace

Terminal will prompt these questions

Enter the name of the subgraph:
Enter the version of the subgraph:
Enter the slug of the subgraph:

Integration of the Airstack schemas is done. Now, move to the vertical-specific section for further integration.

3. Code integration

Example: NFT Marketplace

  1. Import airstack modules
import * as airstack from "../modules/airstack/nft-marketplace"
  1. Creation of NFT object
let nft = new airstack.nft.NFT(
    collectionAddress, // Address
    standard, // string "ERC721" or "ERC1155"
    tokenId, // BigInt
    amount // BigInt 1 for "ERC721" , n for "ERC1155"
)
  1. Creation of royalties array
let royalties = new Array<airstack.nft.CreatorRoyalty>()
let royalty = new airstack.nft.CreatorRoyalty(
    fee, // BigInt
    beneficiary // Address
)
royalties.push(royalty)
  1. Creation of NFT Sales array
let allSales = new Array<airstack.nft.Sale>()
let sale = new airstack.nft.Sale(
    buyer, // Address
    seller, // Address
    nft, // airstack.nft.NFT
    paymentAmount, // BigInt
    paymentToken, // Address
    protocolFees, // BigInt
    protocolFeesBeneficiary, // Address
    royalties // airstack.nft.CreatorRoyalty[]
)
allSales.push(sale)
  1. Use the trackNFTSaleTransactions function to process the data and store in Airstack schema
airstack.nft.trackNFTSaleTransactions(
    chainId, //  string eg: for mainnet: 1
    txHash, // string eg: event.transaction.hash.toHexString()
    txIndex, //string eg: event.transaction.index
    allSales, // airstack.nft.Sale[]
    isBundle, // boolean 
    protocolType, // string eg: "NFT_MARKET_PLACE"
    protocolActionType, //string eg: "SELL"
    timestamp, // BigInt eg: event.block.timestamp
    blockHeight, // BigInt eg: event.block.number
    blockHash // string eg: event.block.hash.toHexString()
)

Development status of each vertical

⌛ = Prioritized 💬 = In discussion 🔨 = In progress implementation ✅ = Completed

| Vertical | Status | | --------------- | :----: | | NFT Marketplace | ✅ | | Domain Name | ✅ | | DEX | 🔨 | | Bridges | 💬 | | DAO | ⌛ | | Defi | ⌛ | | Games | ⌛ |

To build the module

If you want to build the module yourself, please follow there steps.

  1. Clone the repo
  2. Run commandnpx @airstack/subgraph-generator <vertical> --name <subgraph_name> --slug <subgraph_slug> --version <subgraph_version>
  3. Run the command npm run build