SDK Integration

Importing the VWBL SDK to your Project

Integrating the SDK...?

SDK integration is the process of importing a library file (SDK), known as a software development kit, into your project in order to use the library file's functions. By integrating the VWBL SDK into a TypeScript project, you can easily create a NFT project. (e.g. a bespoke NFT market).

A VWBL SDK Demo App

The Integration Demo application demonstrates how to integrate the VWBL SDK in your app.

Download our Demo Application ​​

Step 1. Add the SDK to Your Project

Install the via npm or yarn to get started.

yarn
npm
yarn add vwbl-sdk
nom install vwbl-sdk

Step 2. Create a VWBL Instance

In order to use functions in the VWBL SDK, you will need to create an instance of VWBL first.

const vwblInstance = new VWBL({
  web3,
  contractAddress: "0x...",
  manageKeyType: ManageKeyType.VWBL_NETWORK_SERVER,
  uploadContentType: UploadContentType.S3,
  uploadMetadataType: UploadMetadataType.S3,
  vwblNetworkUrl: "https://vwbl.network",
  awsConfig: {
    region: "ap-northeast-1",
    idPoolId: "ap-northeast-1:...",
    cloudFrontUrl: "https://d2d...7o5.cloudfront.net",
    bucketName: {
      metadata: "your_s3_bucket",
      content: "your_s3_bucket",
    },
  },
});

Constructor Options

name required type description
web3 true Web3 web3 instance
contractAddress true string VWBL NFT's contract address
vwblNetworkUrl true string VWBL Network's URL.
managedKeyType false ManagedKeyType Specify how to manage decyption key. You can choose one of the following. ・VWBL_NETWORK_SERVER ・VWBL_NETWORK_CONSORTIUM(not implemented yet) ・MY_SERVER(not implemented yet).
uploadContentType false UploadContentType Specify where you upload your content to. You can choose one of the following. ・AWS ・IPFS ・CUSTOM
uploadMetadataType false UploadMetadataType Specify where you upload your metadata to. You can choose one of the following. ・AWS ・IPFS ・CUSTOM
awsConfig false AWSConfig AWSConfig *1
ipfsConfig false IPFSConfig IPFSConfig *2

*1 AWS Config

name required type description
region true string AWS region
idPoolId true string idPoolId which has granted S3-put-object
cloudFrontUrl true string URL for CloudFront which is connected to S3 bucket that content is uploaded
bucketName true { content: string, metadata: string} Amazon S3 bucket name you want to upload content and metadata. It's ok to set same bucket.

*2 IPFSConfig

VWBL SDK uses Pinata to upload IPFS.

name required type description
apiKey true string API key
apiSecret false string API secret key

Step 3. Use Functions of VWBL-SDK

Sign to Server

Signing is necessary before creating token or viewing contents.

await vwbl.sign();

Create NFT

await vwbl.managedCreateToken(
  name,
  description,
  fileContent,
  thumbnailContent,
  0 // royaltiesPercentage
);

Arguments

name required type description
name true string ERC721 metadata name
description true string ERC721 metadata description
plainFile true File / File[] The data that only NFT owner can view
thumbnailImage true File ERC721 metadata image
royaltiesPercentage true number If the marketplace supports EIP2981, this percentage of the sale price will be paid to the NFT creator every time the NFT is sold or re-sold
encryptLogic false (default="base64") EncryptLogic "base64" or "binary". Selection criteria: "base64" -> sutable for small data. "binary" -> sutable for large data.
hasNonce false (default=false) boolean whether to contain account's nonce in signature
autoMigration false (default=false) boolean whether to deligate to destribute key fragments of a split key when new one was created
uploadEncryptedFileCallback true if uploadContentType is CUSTOM UploadEncryptedFile you can custom upload function
uploadThumbnailCallback true if uploadContentType is CUSTOM UploadThumbnail you can custom upload function
uploadMetadataCallback true if uploadMetadataType is CUSTOM UploadMetadata you can custom upload function

view contents ( get NFT metadata from given tokenId)

const token = await vwbl.getTokenById(tokenId);

Response

Field Type Description
id number NFT tokenId
name string Name of the NFT
description string Description of the NFT
image string Image of the NFT
mimeType string Label used to identify a type of data
encrypt_logic EncryptLogic Logic of encrypting data

Example Response(called by non-NFT owner)

{
  id: 1,
  name: 'VWBL NFT',
  description: 'This is VWBL NFT',
  image: 'https://dadt0t1exaqoh.cloudfront.net/data/74c3b520-bc17-4727-b23c-5dc7de8fcfd4-bench.jpg',
  mimeType: 'video/mp4',
  owner: '0x8b8613A2cFe9Aa546a41Eab13F0V1a4c4F0b6054'
}

If the function is called by NFT owner, extra fields listed below will be returned.

Field Type Description
fileName string Filename of the data that only owner can view
ownDataBase64 string[] Data that only owner can view encoded to base64
ownFiles ArrayBuffer[] / Stream[] Data that only owner can view

results matching ""

    No results matching ""