assets-sdk icon indicating copy to clipboard operation
assets-sdk copied to clipboard

Cannot load metadata of NFT item when use deployNftCollection with not empty commonContent

Open VTTruong287 opened this issue 1 year ago • 2 comments

I have a problem with commonContent. I cannot load metadata of NFT item when use deployNftCollection with NOT empty commonContent, but it work when commonContent = ''.

Can you guy help me explain about this case? Many thanks :)

Here is my code:

Deploy NFT Collection

...
const commonContent = await sdk.storage.uploadFile(
  Buffer.from(JSON.stringify(content), "utf-8")
);

const collection = await sdk.deployNftCollection(
  {
    collectionContent: content,
    commonContent: commonContent, // Issue here
  },
  {
    adminAddress: adminAddress,
  }
);
...

Deploy NFT Item:

...
const collection = sdk.openNftCollection(Address.parse(COLLECTION));

const content = Buffer.from(
  JSON.stringify({
    name: "Test NFT 1",
    description: "This is a test NFT 1",
    image: uploadedImageURL,
    "attributes":[{"trait_type":"Awesomeness","value":"Super cool"}],
  }), "utf-8"
);

const metadataURL = await sdk.storage.uploadFile(content);

const { nextItemIndex: index } = await collection.getData();
await collection.sendMint(sender, {
  index: index,
  owner: sdk.sender?.address!,
  individualContent: metadataURL,
});
...

VTTruong287 avatar May 03 '24 01:05 VTTruong287

hi ser any solution?

liho00 avatar Jul 17 '24 17:07 liho00

my solution is: leave commonContent empty and add option param onchainContent: true when deployNftCollection

const collection = await sdk.deployNftCollection(
  {
    collectionContent: content,
    commonContent: ''
  },
  {
    adminAddress: adminAddress,
    onchainContent: true
  }
);

wejaikao avatar Nov 01 '24 05:11 wejaikao