Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added class for NaaS rest client #1

Open
wants to merge 2 commits into
base: naas-rest-client
Choose a base branch
from

Conversation

shivanshsinghal107
Copy link

No description provided.

@shivanshsinghal107
Copy link
Author

Code to test the sdk:

  • for a node-js app:
import onec from "ceno-sdk";

const data = {
    "token_id": "13",
    "metadata": {
        "Title": "Reference NFT",
        "Creator": "Onecdot"
    },
    "public_address": "0xB1932F9dE39c0633b77F64752f83692aD978cDD9"
}

async function mint(data) {
    const naas = new onec.naas(api_key)
    
    // var res = await naas.mintRefNFT(data)
    // console.log(res)

    var res = await naas.checkMintStatus(1267)
    console.log(res)

    var res = await naas.fetchTokenID(1267)
    console.log(res)

    var res = await naas.fetchRefTokenID(1270)
    console.log(res)

    var res = await naas.getTokenMetadataHash(13)
    console.log(res)

    var res = await naas.getRefNFTs(13)
    console.log(res)

    var res = await naas.getIpfsFiles()
    console.log(res)
    
    // var res = await naas.uploadIpfsMetaData(data)
    // console.log(res)

    // var res = await naas.getIpfsMetaData()
    // console.log(res)
}

mint(data)
  • for a nextjs app (a file on the server/api side):
const onec = require('ceno-sdk')
const api_key = process.env.NAAS_APIKEY

function handler(req, res) {
	return new Promise(async (resolve, reject) => {
		if (req.method === 'GET') {
			try {
                var data = {
                    "meta_data": {
                        "Concert": "Test Service",
                        "Date": "dd-mm"
                    },
                    "info": "Optional:Some info"
                }

                const naas = new onec.naas(api_key)
                // const mintRes = await naas.mintRefNFT(data)
                // console.log(mintRes)

                var resp = await naas.checkMintStatus(1273)
                console.log(resp)

                var resp = await naas.fetchTokenID(1273)
                console.log(resp)

                var resp = await naas.fetchRefTokenID(1275)
                console.log(resp)

                var resp = await naas.getTokenMetadataHash(20)
                console.log(resp)

                var resp = await naas.getRefNFTs(20)
                console.log(resp)

                var resp = await naas.getIpfsFiles()
                console.log(resp)

                var resp = await naas.uploadIpfsMetaData(data)
                console.log(resp)

                var resp = await naas.getIpfsMetaData()
                console.log(resp)
                
				res.status(200).json({ resp });
				res.end();
			} catch (error) {
				console.log(error);
				res.status(400).send(error);
				res.end();
			}
		}
	});
}

export default handler;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant