Skip to main content

How to use the SDK to recycle or redistribute NFTs

Overview

Overview

If you need to develop NFT Studio and want to recycle or transfer NFTs, you can do so by interfacing with the SDK.

Let's take an airdrop NFT application as an example of how to recycle or redistribute NFTs using /api/sdk/mint-asset-by-factory-trusted-issuer.

How To Use

  1. Mounting NFT Maker as a component, related information
  2. Developing locally The top-level application fills in the Endpoint of DID Spaces, which can be added to the .env.local file javascript APP_SPACE_ENDPOINT=https://<your-did-spaces-endpoint>
  3. In Top-Level Applications Mapping to the NFT Maker SDK javascript const component = require('@blocklet/sdk/lib/component'); // ----------------- NFT Maker SDK ----------------- // Success returned a tx hash const { data: txHash } = await component.call({ // In-app calls, no need to worry about encryption and decryption issues name: 'nft-maker', // This is where you need to look at the name definition in blocklet.yml. path: '/api/sdk/mint-asset-by-factory-trusted-issuer', // This api cannot be called externally data: { factoryAddress, // Required, factory address assetOwnerAddress, // Optional, asset owner address, default mint to the application's corresponding wallet address locale, // Optional, Language of incorrect information userPk, // Optional, will be parsed as a mint-asset wallet, app wallet is used by default, tweet token doesn't use this parameter. }, }); // ----------------- NFT Maker SDK -----------------
  4. To refine the logic of the top-level application, create a Collection in NFT Maker to get the address using the method described above.

Parameter Description

Parameter NameRequiredDefault / EnumTips
factoryAddressundefinedThe address of the Collection
assetOwnerAddressappWallet.addressThe address of the asset owner, default is the application wallet address.
userPkundefinedThe collection trusted issuer address, defaults to the application wallet address
localeen / ['zh', 'en']Multi-language support

Common Problems

Why create a Collection in NFT Maker?

When NFT Maker creates a Collection, it adds the top-level app's wallet address to trustedIssuers.

This allows the top-level app to link to NFT Maker via the SDK to reclaim or transfer NFTs from the Collection.