How to use the SDK to recycle or redistribute NFTs
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#
- Mounting NFT Maker as a component, related information
- Developing locally The top-level application fills in the Endpoint of DID Spaces, which can be added to the .env.local file
APP_SPACE_ENDPOINT=https://<your-did-spaces-endpoint>
- In Top-Level Applications Mapping to the NFT Maker SDK
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 ----------------- - 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 Name | Required | Default / Enum | Tips |
---|---|---|---|
factoryAddress | ✅ | undefined | The address of the Collection |
assetOwnerAddress | ❌ | appWallet.address | The address of the asset owner, default is the application wallet address. |
userPk | ❌ | undefined | The collection trusted issuer address, defaults to the application wallet address |
locale | ❌ | en / ['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.