Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.4 KB

README.md

File metadata and controls

59 lines (47 loc) · 1.4 KB

Metadata GQL client

npm version Made With License: MIT

Autogenerated typed TZIP-16/TZIP-21 Metadata SDK with a built-in GQL client.

Installation

npm i @dipdup/metadata

Usage

First of all you need to create an instance of metadata client:

import { createClient } from '@dipdup/metadata'

const client = createClient({
    url: 'http://metadata.dipdup.net/v1/graphql',
    subscription: {
        url: "wss://metadata.dipdup.net/v1/graphql"
    }
});

Query

import { everything } from '@dipdup/metadata'

client.chain.query
    .token_metadata({
        where: { 
            contract: { _eq: 'KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton' },
            token_id: { _eq: 100000 }
        }
    })
    .get({ ...everything })
    .then(res => console.log)

Subscription (live query)

const { unsubscribe } = client.chain.subscription
    .token_metadata({
        where: { 
            contract: { _eq: 'KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton' },
            created_at: { _gt: '2021-07-06T00:00:00' }
        }
    })
    .get({ ...everything })
    .subscribe({
        next: res => console.log
    })