ton-community / assets-sdk

MIT License
76 stars 13 forks source link

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

Open VTTruong287 opened 6 months ago

VTTruong287 commented 6 months ago

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,
});
...
liho00 commented 4 months ago

hi ser any solution?

wejaikao commented 3 weeks ago

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
  }
);