1.1.1 • Published 1 year ago

rebus.nftid.js v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Rebus NFTID JS

Utils for encrypting/decrypting data for NFTs and uploading NFTs to an IPFS.

Installing

npm install rebus.nftid.js --save yarn add rebus.nftid.js

Usage

Creating a NFT ID

Using createNft

const { ipfs } = require('rebus.nftid.js');

const {
	createNft,
} = ipfs(process.env.IPFS_API_KEY);

// publicImageDataString = buffer from base64 data string of the public image
// privateImageDataString = buffer from base64 data string of the private image
const { privateKey, metadata } = await createNft('Default', 'Rebus', 'address', publicImageDataString, privateImageDataString);

// privateKey is used to decrypt the private image
// metadata = { ipnft: 'cid', url: 'ipfs://cid/metadata.json' }

Using other methods

const { ipfs } = require('rebus.nftid.js');

const {
	getFile,
} = ipfs(process.env.IPFS_API_KEY);

const imageData = Buffer.from('base64string', 'base64');
const imageFile = getFile([imageData], 'image.png', 'image/png');

const metadata = await uploadIpfs('Name', 'NFT ID', imageFile, {
	custom: 'custom',
	test: imageFile,
});
// metadata = { ipnft: 'cid', url: 'ipfs://cid/metadata.json' }

Useful encryption functions

const {
	generateKey, // Generates random encryption key
	encrypt, // Uses encryption key to encrypt a data string
	decrypt, // Uses encryption key to decrypt a data string
} = require('rebus.nftid.js');

Development

Dependencies

yarn install

Testing

yarn test