-1

I tried using mint account info (which obviously wouldn't work) and I also tried to deserialise the mint.to_account_info().data into the metadata struct from the mpl_token_metadata::state::Metadata. This gave errors.

I need the sellerFeeBasisPoints and the creators info from the NFT Metadata.

Also, is there a way to update the primarySaleHappened parameter? (I am writing a custom auction contract for an NFT Marketplace).

Thanks in Advance :)

mousetail
  • 7,009
  • 4
  • 25
  • 45
  • Please show us some code and which errors you got. – AlexN Jul 05 '22 at 12:39
  • I lost my code, but I was using the wrong approach for the same. I was doing something like: `let mint_account = ctx.accounts.mint.to_account_info(); let mint_metadata = &mint_account.data; msg!("mint account {:?}", mint_account); msg!("mint metadata {:?}", mint_metadata);` – Shaivik Semwal Jul 06 '22 at 05:35
  • Please create two questions since your questions target in two different areas. – AlexN Jul 06 '22 at 13:42

2 Answers2

3

You can deserialize the Metadata-struct by using the mpl_token_metadata-crate provided by Metaplex:

use mpl_token_metadata::state::Metadata;
let metadata: Metadata = Metadata::from_account_info(metadata_account_info)?;

For your second question, please open a new question.

AlexN
  • 1,613
  • 8
  • 21
0

For the second question if you are planning to update the primarySaleHappened from the program then you can do a CPI (Cross Program Invocation) to the Token metadata program to this function update_primary_sale_happened_via_token. Similarly, you can find createUpdatePrimarySaleHappenedViaTokenInstruction in the @metaplex-foundation/mpl-token-metadata npm package to do it in the js/ts side.

Pratik.js
  • 250
  • 1
  • 9