メインコンテンツまでスキップ

Uploader-Basic

Overview

Uploader Basic SDK help us easy store off-chain NFT data (like metadata, images and other assets) by a few command. It build on top of NFT.storage, which long-term storage service designed to store assets on IPFS and FileCoin.

To using library require an NFT storage API key. If you don't have one, please go to here to register an API key.

Install

npm install @gusdk/uploader-basic

Usage

Create SDK instance with your API keys

const { GUUploaderBasic } = require("@gusdk/uploader-basic");
const uploader = new GUUploaderBasic({ nftStorageToken: "YOUR_API_KEY" });

Store your NFT metadata following command

const response = await uploader.storeMetadata({
name: "enter your work name",
description: "enter your work detail",
imagePath: "/path/to/your/work.jpg",
});

You will receive response like this:

Token {
ipnft: 'bafyreihy7g6qap2gphinbdwy47w367yqsfhphgtlfgrqsujrztlxilq3em',
url: 'ipfs://bafyreihy7g6qap2gphinbdwy47w367yqsfhphgtlfgrqsujrztlxilq3em/metadata.json'
}
  • Your IPFS cid: bafyreihy7g6qap2gphinbdwy47w367yqsfhphgtlfgrqsujrztlxilq3em
  • Your IPFS uri: ipfs://bafyreihy7g6qap2gphinbdwy47w367yqsfhphgtlfgrqsujrztlxilq3em/metadata.json. You can view it by Brave Browser or available IPFS gateways.

Functionality

storeMetadata

export interface BasicNFTMetadata {
name: string;
description: string;
imagePath: string;
}
storeMetadata(metadata: BasicNFTMetadata): Promise<Token>;

store NFT metadata on IPFS

storeFile

    storeFile(imagePath: string): Promise<CIDString>;

store NFT any file giving path on IPFS

storeFile

storeFiles(directoryPath: string): Promise<CIDString>;

store NFT any folder of files giving path on IPFS

get nftStorageService

  get nftStorageService(): NFTStorage;

You can get instance of NFT.storage and using build in api of NFT.storage. API available here