3

I am creating an NFT that stores a small amount of data - less than 1KB - inside it. The data should be on-chain - not in an external JSON file - as the owner should be able to destroy the NFT easily using their wallet without external traces left over.

How can I write more data into the on-chain NFT?

I was hoping to use Metaplex (both the Metaplex JS SDK and the on-chain program) to write the data into an NFT. I overloaded the uri field (as it's a string) with the data to see if I could write the NFT there.

The program [TokenMetadataProgram] at address 
[metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code
[13] that translates to "URI too long".

Some hunting through the metaplex on-chain program code shows pub const MAX_URI_LENGTH: usize = 200; which seems to indicate the maximum length of the URI field is 200 bytes.

What's the best way to make NFTs with more data inside?

Edit: I've also checked out Need assistance creating a custom type of NFT which may indicate there only way to do this is use SPL to mint the token, and make a PDA for the additional metadata that accepts the larger data.

2
  • 1
    According to the metaplex's NFT standards, we can't increase the data account. You can use another program to increase the data account. You can save the data to on-chain with your own program. The data account should be indicated with NFT mint key. Mar 13, 2023 at 12:27
  • Thanks @DoublersKay. From my understanding, the NFT has a mint account, I want to deploy my own Rust app at a Program Derived Address, derived from the mint account pubkey. How do apps (dapps, wallets etc) resolve the PDA from the mint account? Would the dapp / wallet have to build logic in to do this, or is there some other way a mint account can point to a metadata account? Feel free to answer as an actual answer BTW that way I can vote you up!
    – mikemaccana
    Mar 13, 2023 at 13:21

1 Answer 1

4

The createMetadata() function from Candy Machine creates a metadata account using the NFT mint address.

Similarly, you can create a PDA for your own NFT metadata. The PDA account should be indicated with the NFT mintAddress. You can make the account similar to the metadata account.

const metadataAccount = (
  await findProgramAddress(
    [
      Buffer.from("metadata"),
      toPublicKey(metadataProgramId).toBuffer(),
      toPublicKey(mintAddress).toBuffer(),
    ],
    toPublicKey(metadataProgramId)
  )
)[0];

The Dapp has to build the logic to find the account and get the account data. So your Dapp should be able to see what the additional metadata are. You can't see the additional metadata in a wallet (unless you're building your own wallet).

1
  • Thanks for your help, I've added the link you provided to the answer.
    – mikemaccana
    Mar 14, 2023 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.