I am trying to creat fungible token using metaplex(here)
The rest is working fine but when sending transaction there was error.
I found that createCreateMetadataAccountV2Instruction
in add transaction has different type of props in guide. If I use typescript for this, it throws createMetadataAccountArgsV2 is not a type of PublicKey
.
So I checked @metaplex-foundation/mpl-token-metadata
and it's props were account: createMetadataAccountV2InstructionAccounts
and programId?: PublicKey
which is different from here.
How can I pass parameters in createCreateMetadataAccountV2Instruction
?
Or if it's not a problem, what is wrong with the project(I just copy and paste the guide)?
Okay, Finally I create token.
I didn't use createCreateMetadataAccountV2Instruction
.
Instead I use createCreateMetadataAccountV3Instruction
for transaction and it works fine.
const createNewTokenTransaction = new Transaction().add(
SystemProgram.createAccount({
fromPubkey: payer.publicKey,
newAccountPubkey: mintKeypair.publicKey,
space: MINT_SIZE,
lamports: requiredBalance,
programId: TOKEN_PROGRAM_ID,
}),
createInitializeMintInstruction(
mintKeypair.publicKey,
MINT_CONFIG.numDecimals,
mintAuthority,
freezeAuthority,
TOKEN_PROGRAM_ID),
createAssociatedTokenAccountInstruction(
payer.publicKey,
tokenATA,
payer.publicKey,
mintKeypair.publicKey,
),
createMintToInstruction(
mintKeypair.publicKey,
tokenATA,
mintAuthority,
MINT_CONFIG.numberTokens * Math.pow(10, MINT_CONFIG.numDecimals),
),
createCreateMetadataAccountV3Instruction(
{
metadata: metadataPDA,
mint: mintKeypair.publicKey,
mintAuthority: mintAuthority,
payer: payer.publicKey,
updateAuthority: mintAuthority,
},
{
createMetadataAccountArgsV3:
{
data: ON_CHAIN_METADATA,
isMutable: true,
collectionDetails: null
},
}
),
);
It's modified code.
Hope this will help you. :)