JS Plugin

Tezos Harbinger Polywrapper JS Plugin

Client JS

Import Plugins

import { Web3ApiClient } from "@web3api/client-js"
import { tezosPlugin } from "@web3api/tezos-plugin-js"

Web3 API Client

Creates a new Web3ApiClient client from which queries and mutations will be called.

export const client = new Web3ApiClient({
   plugins: [
       {
         uri: "w3://ens/tezos.web3api.eth",
         plugin: tezosPlugin({
           networks: {
               mainnet: {
                   provider: "https://rpc.tzstats.com"
               }, 
               granadanet: {
                   provider: "https://rpc.granada.tzstats.com",
               }
           },
           defaultNetwork: "mainnet"
         })
       }
   ]
})

Query JS

Import Client

import { client } from './client'

Set Wrapper URI

Sets the URI which points to the Tezos Harbinger Polywrapper’s WASM files uploaded on IPFS.

const HARBINGER_URI = 'w3://ipfs/Qmd3Yja1oUjUyoxmT8P88jHpQJuy5oc6vyckoKx6F942B1'

Get Asset Data

Gets an asset's data by passing the network and asset code.

export const getAssetData = async (assetCode, network) => {
   return await client.query({
           uri: HARBINGER_URI,
           query: `
               query {
                   getAssetData(
                       network: $network,
                       assetCode: $assetCode,
                   )
               }`,
           variables: {
               assetCode,
               network
           }
   });
}

Last updated