How do I set_accounts() for a token Mint?
#380
-
|
Hi, everyone! I'm working on a Trident fuzz test for our Solana program - and am blocked trying to set_accounts() for an Ix of ours that involves the following token mint account: #[account(
init,
payer = initializer,
seeds = [b"nft_collection_mint"],
bump,
mint::authority = nft_collection_mint,
mint::decimals = 0,
mint::freeze_authority = nft_collection_mint,
mint::token_program = nft_token_program,
)]
pub nft_collection_mint: Box<InterfaceAccount<'info, Mint>>,Here's how I'm currently trying to set the account up: impl InstructionHooks for InitializeInstruction {
type IxAccounts = FuzzAccounts;
fn set_accounts(&mut self, trident: &mut Trident, fuzz_accounts: &mut Self::IxAccounts) {
let nft_collection_mint = fuzz_accounts.nft_collection_mint.get_or_create_mint_account(
self.accounts.nft_collection_mint.account_id,
trident,
Some(PdaSeeds {
seeds: &[NFT_COLLECTION_MINT],
program_id: self.accounts.nft_token_program.pubkey(),
}),
0u8,
&self.accounts.nft_collection_mint.pubkey(),
Some(self.accounts.nft_collection_mint.pubkey()),
);
self.accounts.nft_collection_mint.set_address(nft_collection_mint);
}
}What am I doing wrong? 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
Hello, thanks for the question, this looks alright, can you share error you are receiving ? If you enable metrics (dashboard or json), you can see what is the error returned :), can you share that ? |
Beta Was this translation helpful? Give feedback.
-
|
I see, the issue is, with Trident you are trying to initialize the mint before the transaction is executed. If you have experience with for example Anchor test, if the program initializes the mint, you cant initialize it before the instruction execution as you will get this already in use error. What you need to do instead is just get_or_create with correct seeds in order to obtain just address. The mint initialization will be handled by the program :) |
Beta Was this translation helpful? Give feedback.
-
|
Closing this, in favor of #382. |
Beta Was this translation helpful? Give feedback.


I see, the issue is, with Trident you are trying to initialize the mint before the transaction is executed. If you have experience with for example Anchor test, if the program initializes the mint, you cant initialize it before the instruction execution as you will get this already in use error. What you need to do instead is just get_or_create with correct seeds in order to obtain just address. The mint initialization will be handled by the program :)