Created
July 26, 2021 08:11
-
-
Save drewstaylor/ad48cd22f447370b54e05c6cfb54eb19 to your computer and use it in GitHub Desktop.
Get Tezos FA2 Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TezosToolkit = require('@taquito/taquito') | |
const compose = require('@taquito/taquito'); | |
const tzip12 = require('@taquito/tzip12'); | |
const Tzip12Module = require('@taquito/tzip12'); | |
const tzip16 = require('@taquito/tzip16'); | |
const Tzip16Module = require('@taquito/tzip16'); | |
const Tezos = new TezosToolkit.TezosToolkit("https://mainnet-tezos.giganode.io"); | |
Tezos.addExtension(new Tzip12Module.Tzip12Module()); | |
Tezos.addExtension(new Tzip16Module.Tzip16Module()); | |
const FA2 = "KT1TBaU9Jz3DnZAifL9pcW4g3EvH9WpNFyo1"; | |
const getFa2 = async () => { | |
return Tezos.contract.at(FA2, compose.compose(tzip16.tzip16, tzip12.tzip12)); | |
}; | |
(async () => { | |
console.log("Getting contract"); | |
const c = await getFa2(); | |
const metadata = await c.tzip16().getMetadata(); | |
console.log("Contract Metadata", metadata); | |
const isTzip12Contract = await c.tzip12().isTzip12Compliant(); | |
console.log("isTzip12Contract?", isTzip12Contract); | |
// const tokenMeta = await c.tzip12().getTokenMetadata(0); | |
// console.log(tokenMeta); | |
const storage = await c.storage(); | |
const tokenMeta0 = await storage.assets.token_metadata.get('0'); | |
const entries = tokenMeta0.extras.entries(); | |
for (let entry of entries) { | |
console.log(entry); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "fa2-test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "fa2.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node fa2.js" | |
}, | |
"keywords": [ | |
"Tezos" | |
], | |
"author": "[email protected]", | |
"license": "MIT", | |
"dependencies": { | |
"@taquito/taquito": "^9.2.0", | |
"@taquito/tzip12": "^9.2.0", | |
"@taquito/tzip16": "^9.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment