PNS as NFT
Deriving tokenId from PNS name
const ethers = require('ethers')
const BigNumber = ethers.BigNumber
const utils = ethers.utils
const name = 'richard'
const labelHash = utils.keccak256(utils.toUtf8Bytes(name))
const tokenId = BigNumber.from(labelHash).toString()Deriving PNS name from tokenId
const ethers = require('ethers')
const BigNumber = ethers.BigNumber
const gr = require('graphql-request')
const { request, gql } = gr
const tokenId = '26004363047961302715841817009868885426915362095607813844703532662233080456292'
// Should return 0x397df2a99f3fd3359a10190be2c38dd5cdea514e3c660c0ecad715815c22e464
const labelHash = BigNumber.from(tokenId).toHexString()
const url = 'https://graph.pulse.domains/subgraphs/name/graphprotocol/pns'
const GET_LABEL_NAME = gql`
query{
domains(first:1, where:{labelhash:"${labelHash}"}){
labelName
}
}`
request(url, GET_LABEL_NAME).then((data) => console.log(data))
// { domains: [ { labelName: 'pns' } ] }Turning subdomain into NFT
Metadata
Last updated