Hello, first of all, thanks for working on this. Very helpful in learning Solana/Metaplex as a Go dev. Kudos.
Hoping to get some help on this, I'm trying to mint a new edition from an existing master edition to a new address and I'm hitting this error:
Program 11111111111111111111111111111111 invoke [1]
Program 11111111111111111111111111111111 success
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
Program log: Instruction: InitializeMint
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2390 of 200000 compute units
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]
Program log: Transfer 2039280 lamports to the associated token account
Program 11111111111111111111111111111111 invoke [2]
Program 11111111111111111111111111111111 success
Program log: Allocate space for the associated token account
Program 11111111111111111111111111111111 invoke [2]
Program 11111111111111111111111111111111 success
Program log: Assign the associated token account to the SPL Token program
Program 11111111111111111111111111111111 invoke [2]
Program 11111111111111111111111111111111 success
Program log: Initialize the associated token account
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]
Program log: Instruction: InitializeAccount
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3449 of 179470 compute units
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 24660 of 200000 compute units
Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]
Program log: Instruction: MintTo
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2879 of 200000 compute units
Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success
Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]
Program log: Instruction: Mint New Edition from Master Edition Via Token
Program log: Incorrect account owner
Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 5204 of 200000 compute units
Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39"
This is how I am doing it:
payer
is solana.privateKey
of account that created and has the master edition
withdrawalAddress
is account to send the new edition to
masterMint
is the public key of the NFT
- generated new keypair called
newMintAccount
- created token account: mint auth and freeze auth are
payer.PublicKey()
, mint account is newMintAccount.PublicKey()
- created associated token account: wallet is
withdrawalAddress
, mint is newMintAccount
associatedTokenAddress
is found via solana.FindAssociatedTokenAddress()
using withdrawalAddress
and newMintAccount.PublicKey()
- MintTo instruction: amount
1
, mint account is newMintAccount.PublicKey()
, destination account is associatedTokenAddress
and auth account is payer.PublicKey()
newMetadataKey
is found via:
newMetadataKey, _, err := solana.FindProgramAddress(
[][]byte{
[]byte(token_metadata.PREFIX),
solana.TokenMetadataProgramID.Bytes(),
newMintAccount.PublicKey().Bytes(),
},
solana.TokenMetadataProgramID,
)
newEditionPDA
is found via:
newEditionPDA, _, err := solana.FindProgramAddress(
[][]byte{
[]byte(token_metadata.PREFIX),
solana.TokenMetadataProgramID.Bytes(),
newMintAccount.PublicKey().Bytes(),
[]byte(token_metadata.EDITION),
},
solana.TokenMetadataProgramID,
)
masterRecordMetadata
is found via:
masterRecordMetadata, _, err := solana.FindProgramAddress(
[][]byte{
[]byte(token_metadata.PREFIX),
solana.TokenMetadataProgramID.Bytes(),
masterMint.Bytes(),
},
solana.TokenMetadataProgramID,
)
masterRecordEditionV2PDA
is found via:
masterRecordEditionV2PDA, _, err := solana.FindProgramAddress(
[][]byte{
[]byte(token_metadata.PREFIX),
solana.TokenMetadataProgramID.Bytes(),
masterRecordMetadata.Bytes(),
[]byte(token_metadata.EDITION),
},
solana.TokenMetadataProgramID,
)
editionPDA
is found via:
edition := uint64(1)
x := math.Floor(float64(edition) / token_metadata.EDITION_MARKER_BIT_SIZE)
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, math.Float64bits(x))
editionPDA, _, err := solana.FindProgramAddress(
[][]byte{
[]byte(token_metadata.PREFIX),
solana.TokenMetadataProgramID.Bytes(),
masterRecordMetadata.Bytes(),
[]byte(token_metadata.EDITION),
b,
},
solana.TokenMetadataProgramID,
)
tokenAccountOfMasterMint
is found via:
tokenAccountOfMasterMint, _, err := solana.FindAssociatedTokenAddress(
payer.PublicKey(),
masterMint,
)
- Finally, this is the instruction for minting a new edition:
printEditionInstruction := token_metadata.NewMintNewEditionFromMasterEditionViaTokenInstructionBuilder().
SetArgs(token_metadata.MintNewEditionFromMasterEditionViaTokenArgs{Edition: edition}).
SetNewMetadataKeyAccount(newMetadataKey). // pda from token_metadata.PREFIX, solana.TokenMetadataProgramID, newMintAccount.PublicKey()
SetNewEditionPDAAccount(newEditionPDA).
SetMasterRecordEditionV2Account(masterRecordEditionV2PDA).
SetMintOfNewTokenAccount(newMintAccount.PublicKey()).
SetEditionPDAAccount(editionPDA).
SetMintAuthorityAccount(payer.PublicKey()).
SetPayerAccount(payer.PublicKey()).
SetOwnerOfTokenAccount(payer.PublicKey()).
SetTokenAccount(tokenAccountOfMasterMint).
SetUpdateAuthorityInfoAccount(payer.PublicKey()).
SetMasterRecordMetadataAccount(masterRecordMetadata).
SetTokenProgramAccount(solana.TokenProgramID).
SetSystemProgramAccount(solana.SystemProgramID).
SetRentInfoAccount(solana.SysVarRentPubkey)