JS Library abstracting freeverse's API to create end update living assets represented by NFTs. This SDK is mainly targeted at videogame companies that are interested in participating in PRINGO platform to retrieve the different NFTs owned by their players together with their properties to render/represent those features in a game context.
To test and experiment with the SDK at current development stage, there's a sample .env file called .env.sample in this directory containing some configuration variables needed to check some of the functionalities. Of course feel free to include these configuration variables inside your own .env file corresponding to your application.
- PRIVATE_KEY: Freeverse signing private key (just needed to perform write operations).
- UNIVERSE_ID: A valid freeverse's universe id (just for default operations).
- FREEVERSE_API_URL: Freeverse API URL.
- IPFS_API_URL=https://ipfs.infura.io:5001/api/v0
- MAX_ASSETS_TO_BULK_UPDATE: Maximum assets to update in a bulk kind operation.
- CORS: CORS enabled or not (boolean)
- FREEVERSE_TIMEOUT: Accepted timeout for freverse's API calls (recommended 120000)
- SUFFIX_REAL_WORLD_PROPS=real:: Asset Real World props Suffix
- SUFFIX_IN_GAME_PROPS=game:: Asset In Game props suffix
- SUFFIX_GOV_PROPS=gov:: Asset Governance props suffix
Under the directory tests, there's an integration test regarding all this module exported methods.
After installing the package:
npm i pringo-sdk
This code snippet can serve (appart from the tests in tests/index.tests.js) as an example on how to use this SDK methods:
const PRINGO_SDK = require('pringo-sdk')
const UNIVERSE_ID = parseInt(process.env.UNIVERSE_ID)
const run = async function () {
const assets = await PRINGO_SDK.getAssets(UNIVERSE_ID)
console.log(assets.nodes)
const attr = { trait_type: 'gov::proposalId', value: 5 }
const nfts = await PRINGO_SDK.getAssetsByAttribute(attr, UNIVERSE_ID)
console.log(nfts.nodes)
const ownerNfts = await PRINGO_SDK.getAssetsByOwnerId(nfts.nodes[0].ownerId, UNIVERSE_ID)
console.log(ownerNfts)
const isEmailLinked = await PRINGO_SDK.isEmailLinked(nfts.nodes[0].ownerId, UNIVERSE_ID)
console.log(isEmailLinked)
const reference = await PRINGO_SDK.getVerseReference()
console.log(reference)
const cryptos = await PRINGO_SDK.getAllSupportedCryptocurrencies()
console.log(cryptos)
const crypto = await PRINGO_SDK.getSupportedCryptocurrencyById(cryptos.nodes[0].currencyId)
console.log(crypto)
const refundableBuynows = await PRINGO_SDK.getMyRefundableBuyNows(nfts.nodes[0].id, UNIVERSE_ID)
console.log(refundableBuynows)
const withdrawableBuynows = await PRINGO_SDK.getMyWithdrawableBuynows(nfts.nodes[0].id, UNIVERSE_ID)
console.log(withdrawableBuynows)
const universes = await PRINGO_SDK.getAllUniverses()
console.log(universes)
const ownership = await PRINGO_SDK.isUniverseOwner(universes.nodes[0].ownerId, universes.nodes[0].id)
console.log(ownership)
const universe = await PRINGO_SDK.getUniverseById(universes.nodes[0].id)
console.log(universe)
}
run()