https://docs.vwbl-protocol.org
npm install vwbl-sdk vwbl-core
※ for XRPL
npm install vwbl-sdk-xrpl vwbl-core
yarn add vwbl-sdk vwbl-core
※ for XRPL
yarn add vwbl-sdk-xrpl vwbl-core
npm run build:all
Package | Version | License | Description |
---|---|---|---|
vwbl-sdk | VWBL SDK for EVM compatible chain | ||
vwbl-core | VWBL core tools for sub-package | ||
vwbl-sdk-xrpl | VWBL SDK for XRPL |
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://xxx.cloudfront.net",
bucketName: {
metadata: "vwbl-metadata",
content: "vwbl-content",
},
},
});
※ for XRPL
new VWBLXRPL({
xrplChainId: 1, // Mainnet:0 / Testnet:1 / Devnet:2
vwblNetworkUrl: "https://vwbl.network",
manageKeyType: ManageKeyType.VWBL_NETWORK_SERVER,
uploadContentType: UploadContentType.S3,
uploadMetadataType: UploadMetadataType.S3,
awsConfig: {
region: "ap-northeast-1",
idPoolId: "ap-northeast-1:...",
cloudFrontUrl: "https://xxx.cloudfront.net",
bucketName: {
metadata: "vwbl-metadata",
content: "vwbl-content",
},
},
});
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 |
manageKeyType | false | ManageKeyType | how to manage key, you can choose from VWBL_NETWORK_SERVER VWBL_NETWORK_CONSORTIUM(not implemented yet) MY_SERVER(not implemented yet). |
uploadContentType | flase | UploadContentType | where to upload content, you can choose from S3 IPFS CUSTOM |
uploadMetadataType | flase | UploadMetadataType | where to upload content, you can choose from S3 IPFS CUSTOM |
awsConfig | true if you choose to upload content or metadata to S3 | AWSConfig | AWSConfig *1 |
ipfsConfig | true if you choose to upload content or metadata to IPFS | IPFSConfig | IPFSConfig *2 |
AWSConfig(*1)
name | required | type | description |
---|---|---|---|
region | true | string | AWS region |
idPoolId | true | string | idPoolId which has granted S3-put-object |
cloudFrontUrl | true | string | cloudFront url connect to s3 which is uploaded content |
bucketName | true | {content: string, metadata: string} | bucketName of metadata and content, it's ok they are same |
IPFSConfig(*2)
name | required | type | description |
---|---|---|---|
apiKey | true | string | API key |
apiSecret | false | string | API secret key |
|
Signing is necessary before creating token or viewing contents.
await vwbl.sign();
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. |
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 |
gasSettings | false | GasSettings | you can custom gas settings |
const token = await vwbl.getTokenById(tokenId);
const { mintTxJson } = await vwblXrpl.generateMintTokenTx(
// user's wallet address
walletAddress: string,
// 0~5000 (0.00% ~ 50.00%), see detail: https://xrpl.org/docs/references/protocol/transactions/types/nftokenmint
transferRoyalty: number,
// transferable NFT or not
isTransferable: boolean,
// burnable NFT or not
isBurnable: boolean
)
※ Then, you need to ask users to sign the transaction and get signed transaction hex
const { tokenId, emptyTxObject, paymentTxJson } =
await vwblXrpl.mintAndGenerateTx(
signedMintTx, // signed mint tx hex (signed by user)
walletAddress // user's wallet address
);
※ if VWBL NFT minting fee = 0, paymentTxJson
is undefined
and you can ignore
※ if VWBL NFT minting fee > 0, emptyTxObject
is undefined
and you can ignore
const { paymentTxHash, tokenId, emptyTxObject } = await vwblXrpl.payMintFee(
walletAddress, // user's wallet address
signedPaymentTx // signed `paymentTxJson` tx hex
);
const { tokenId } = await vwblXrpl.createManagedToken(
// NFTokenID
tokenId,
// signed `emptyTxObject` hex
signedEmptyTx,
// user's public key
signerPublicKey,
// NFT name
name,
// NFT description
description,
// NFT file
plainFile,
// NFT thumbnail image
thumbnailImage,
// encryption logic (default: base64)
encryptLogic,
// `paymentTxHash` if minting fee is necessary
signedPaymentTxHash?,
// custom upload file function
uploadEncryptedFileCallback?,
// custom upload thumbnail function
uploadThumbnailCallback?,
// custom upload metadata function
uploadMetadataCallBack?
);
const { emptyTxObject } = await vwblXrpl.generateTxForSigning(walletAddress);
// ... get user's signature for `emptyTxObject`
const {
id,
name,
description,
image,
mimeType,
encryptLogic,
ownDataBase64,
ownFiles,
fileName,
} = await vwblXrpl.extractMetadata(tokenId, signedEmptyTx, signerPublicKey);