XRPL Support

A quick step-by-step overview of VWBL SDK for XRPL and basic usages

Below example code is here.

  • Mint VWBL NFT for XRPL
  • Decrypt and view VWBL NFT

1. Install VWBL SDK for XRPL

yarn
npm
// Install via yarn
yarn add vwbl-sdk-xrpl
// Install via npm
npm install vwbl-sdk-xrpl

2. Create instance of VWBLXRPL

Upload File to AWS
Upload File to IPFS
import { VWBLXRPL } from 'vwbl-sdk';
import {
  ManageKeyType,
  UploadContentType,
  UploadMetadataType
} from "vwbl-core";

const vwblXrpl = new VWBLXRPL({
    xrplChainId: 1, // Mainnet:0 / Testnet:1 / Devnet:2
    // [Mainnet]: https://vwbl.network, [Testnet, Devnet]: https://dev.vwbl.network
    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",
    },
  },
});
import { VWBLXRPL } from 'vwbl-sdk';
import {
  UploadContentType,
  UploadMetadataType
} from "vwbl-core";

const vwblXrpl = new VWBLXRPL({
    xrplChainId: 1, // Mainnet:0 / Testnet:1
    // [Mainnet]: https://vwbl.network, [Testnet]: https://dev.vwbl.network
    vwblNetworkUrl: "https:/dev.vwbl.network",
    uploadContentType: UploadContentType.IPFS,
    uploadMetadataType: UploadMetadataType.IPFS,
    ipfsConfig: {
      apiKey: "{YOUR_PINATA_API_KEY}",
      apiSecret:
        "{YOUR_PINATA_API_SECRET}",
    },
});

3. Generate Mint tx

metadata on AWS S3
metadata on IPFS
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, get user's signature for mintTxJson
const { mintTxJson, metadataUrl } = await vwblXrpl.generateMintTokenTxForIPFS(
    // user's wallet address
    walletAddress: string,
    // 0~5000 (0.00% ~ 50.00%)
    transferRoyalty: number,
    // transferable NFT or not
    isTransferable: boolean,
    // burnable NFT or not
    isBurnable: boolean,
    // VWBL NFT name
    name: string,
    // VWBL NFT description
    description: string,
    // metadata file object
    plainFile: FileOrPath | FileOrPath[],
    // VWBL NFT thumbnail image object
    thumbnailImage: FileOrPath,
  );
// ...then, get user's signature for mintTxJson

(Xaman Wallet example)

Example code for signing any tx object with xaman wallet.

*Make sure DO NOT submit tx on your client side

import { XummSdk } from "xumm-sdk";

const xumm = new XummSdk({XUMM_API_KEY}, {XUMM_API_SECRET});

const mintTxPayload: XummPostPayloadBodyJson = {
    // use `mintTxJson` you got on previous step
    txjson: mintTxJson as unknown as XummJsonTransaction,
    options: {
      submit: false,
    },
  };

let signedMintTxHex = "";
try {

    const response = await xumm.payload.create(json, true);
    if (response) {
        // redirect to `response.next.always`
    }

    const status = await xumm.payload.get(response.uuid);
    if (status?.meta?.resolved) {
        completed = true;
        if (status.meta.signed && status.response.hex) {
            signedMintTxHex = status.response.hex;  // get user's signature tx hex
        }
    }
} catch (e) {
    // error handle
}

4. Mint & Genarate next tx

VWBL NFT mint fee is currently 0, so you can skip payment tx step now

metadata on AWS S3
metadata on IPFS
const { tokenId, emptyTxObject, paymentTxJson } = await vwblXrpl.mintAndGenerateTx(
    // signed tx hex (generated on previous step)
    signedMintTx: string,
    // user's wallet address
    walletAddress: string
)
// currently `paymentTxJson` is `undefined`, you can ignore now
// ...then, get user's signature for `emptyTxObject`
const { tokenId, emptyTxObject, paymentTxJson } = await vwblXrpl.mintAndGenerateTxForIPFS(
    // signed tx hex (generated on previous step)
    signedMintTx: string,
    // NFT metadata URL (generated on previous step)
    metadataUrl: string,
    // user's wallet address
    walletAddress: string
);
// ...then, get user's signature for `emptyTxObject`

5. Encrypt VWBL NFT and Store Encrypto Key

metadata on AWS S3
metadata on IPFS
const tokenId = await vwblXrpl.createManagedToken(
    // VWBL NFT tokenId
    tokenId: string,
    // signed empty tx hex (generated on previous step)
    signedEmptyTx: string,
    // user's wallet public key
    signerPublicKey: string,
    // VWBL NFT name
    name: string,
    // VWBL NFT description
    description: string,
    // VWBL NFT file object
    plainFile: FileOrPath | FileOrPath[],
    // VWBL NFT thumbnail image object
    thumbnailImage: FileOrPath,
)
const tokenId = await vwblXrpl.createManagedTokenForIPFS(
    // // VWBL NFT tokenId
    tokenId: string,
    // signed empty tx hex (generated on previous step)
    signedEmptyTx: string,
    // user's wallet public key
    signerPublicKey: string,
);

6. Decrypt VWBL NFT contents

Generate tx to get user's signature

const emptyTxObject = await vwblXrpl.generateTxForSigning(walletAddress);

decrypt & fetch metadata

const {
    id,
    name,
    description,
    image,
    mimeType,
    encryptLogic,
    ownDataBase64,
    ownFiles,
    fileName,
} = extractMetadata(
    // VWBL NFT tokenId
    tokenId: string,
    // signed empty tx hex (generated on previous step)
    signedEmptyTx: string,
    // user's wallet public key
    signerPublicKey: string
)

results matching ""

    No results matching ""