如何使用 SDK 回收或重新发布 NFT
概述#
如果您需要开发 NFT Studio 并希望回收或转移 NFT,可以通过与 SDK 交互来实现
让我们以空投 NFT 应用程序为例,说明如何使用 /api/sdk/mint-asset-by-factory-trusted-issuer 回收或重新分配 NFT
How To Use#
- 安装 NFT Maker, 相关资料
- 本地开发顶层应用程序填写 DID Spaces 的端点,该端点可添加到 .env.local 文件中
APP_SPACE_ENDPOINT=https://<your-did-spaces-endpoint>
- 映射到 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 ----------------- - 要完善顶层应用程序的逻辑,可在 NFT Maker 中创建一个集合,使用上述方法获取地址
参数描述#
参数名称 | 必填 | 默认值 / 可选值 | 备注 |
---|---|---|---|
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 |
常见问题#
为什么要在 NFT Maker 中创建收藏集?#
NFT Maker创建收藏集时,会将顶层应用程序的钱包地址添加到trustedIssuers中。
这样,顶层应用程序就可以通过 SDK 链接到 NFT Maker,从收藏中回收或转移 NFT。