Open lanlingxiawu opened 9 months ago
Program Logs: | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1] | Program log: IX: Mint | Program log: Incorrect account owner | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8777 of 200000 compute units | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x39
Same issue found any fix? Been struggling with this for 2 days. Thank in advance
Same issue found any fix? Been struggling with this for 2 days. Thank in advance
The document is incorrect,I adopted another approach. Create tokens using "@solana/spl-token" and upload metadata using @metaplex-foundation/mpl-token-metadata CreateMetadataAccountV3InstructionAccounts
Still trying to figure this ut still. This is what I have, I have gone with your method of spl-tokens but still having quite a hard time: This is m code:
`**
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults' import { MPL_TOKEN_METADATA_PROGRAM_ID, TokenStandard, createFungible, createV1, mintV1, mplTokenMetadata } from '@metaplex-foundation/mpl-token-metadata' import { createSignerFromKeypair, generateSigner, keypairIdentity, percentAmount, signerIdentity } from '@metaplex-foundation/umi' import { Connection, Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, clusterApiUrl, sendAndConfirmTransaction } from '@solana/web3.js' import { createMint, getOrCreateAssociatedTokenAccount, mintTo, transfer, Account, getMint, getAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'; import { createMetadataAccountV3, DataV2, CreateMetadataAccountV3InstructionArgs } from '@metaplex-foundation/mpl-token-metadata'; require('dotenv').config(); // Special setup to add a Buffer class, because it's missing const {Buffer} = require('buffer'); const bs58 = require('bs58'); import * as path from 'path'; import { Mint, Token, fetchMint, fetchToken, findAssociatedTokenPda, } from '@metaplex-foundation/mpl-toolbox'; import Irys from "@irys/sdk";
let secretKey = bs58.decode(process.env.SECRET_KEY!)
const umi = createUmi('https://api.devnet.solana.com').use(mplTokenMetadata())
const connection = new Connection(clusterApiUrl('devnet'), 'confirmed'); // Generate a new wallet keypair and airdrop SOL const fromWallet = Keypair.generate(); // Public Key to your Phantom Wallet const toWallet = new PublicKey("MyKeyPublic"); let fromTokenAccount:any; let mint:any;
const authorityKeyPair = umi.eddsa.createKeypairFromSecretKey(secretKey); const authoritySigner = createSignerFromKeypair(umi, authorityKeyPair) umi.use(signerIdentity(authoritySigner)) console.log(umi.identity.publicKey)
const createToken = async()=>{
const fromAirdropSignature = await connection.requestAirdrop(fromWallet.publicKey, LAMPORTS_PER_SOL);
await connection.confirmTransaction(fromAirdropSignature, "finalized");
// Create new token mint
mint = await createMint(
connection,
fromWallet,
fromWallet.publicKey,
null,
9 // 9 here means we have a decmial of 9 0's
);
console.log(Create token: ${mint.toBase58()}
);
// Get the token account of the fromWallet address, and if it does not exist, create it
fromTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
fromWallet,
mint,
fromWallet.publicKey
);
console.log(Create Token Account: ${fromTokenAccount.address.toBase58()}
);
}
// const UploadMetadata = async()=>{ // const uri = await umi.uploader.uploadJson({ // name:"FAME", // description:"Official Reward for Fanatica, The Watch to Earn Platform", // image:"https://raw.githubusercontent.com/bl4ckh401/FaeMetadata/main/FAMELogo.png", // symbol:"$FAME" // }) // console.log(uri) // return uri; // }
const getIrys = async () => { const url = "https://devnet.irys.xyz"; // Devnet RPC URLs change often, use a recent one from https://chainlist.org/chain/80001 const providerUrl = "https://api.devnet.solana.com"; const token = "solana";
const irys = new Irys({
url, // URL of the node you want to connect to
token, // Token used for payment
key: process.env.SECRET_KEY, // ETH or SOL private key
config: { providerUrl }, // Optional provider URL, only required when using Devnet
});
return irys;
};
const fundNode = async () => {
const irys = await getIrys();
try {
const fundTx = await irys.fund(0.00005*LAMPORTS_PER_SOL);
console.log(Successfully funded ${irys.utils.fromAtomic(fundTx.quantity)} ${irys.token}
);
} catch (e) {
console.log("Error uploading data ", e);
}
};
const uploadFile = async () => { const irys = await getIrys(); await fundNode() // Your file const fileToUpload = path.resolve(__dirname,"../src/famemetadata.json");
const tags = [{ name: "FAME", value: "FAME" }];
try {
const receipt = await irys.uploadFile(fileToUpload, { tags });
console.log(`File uploaded ==> https://gateway.irys.xyz/${receipt.id}`);
return receipt
} catch (e) {
console.log("Error uploading file ", e);
}
};
async function mintToken() {
// Mint 1 new token to the "fromTokenAccount" account we just created
await createToken()
const signature = await mintTo(
connection,
fromWallet,
mint,
fromTokenAccount.address,
fromWallet.publicKey,
10000000000 // 10 billion
);
console.log(Mint signature: ${signature}
);
}
// const CreateAccount = async()=>{
// // const uri = await UploadMetadata()
// const receipt = await uploadFile()
// const mintAccount = await createV1(umi, {
// mint,
// name: 'FAME',
// uri: https://gateway.irys.xyz/${receipt?.id}
,
// sellerFeeBasisPoints: percentAmount(5.5),
// tokenStandard: TokenStandard.Fungible,
// decimals:9,
// symbol:"$FAME",
// }).sendAndConfirm(umi)
// console.log(mintAccount.result) // return mintAccount; // }
const CreateAccount = async()=>{
const receipt = await uploadFile()
const data = {
name: 'FAME',
uri: https://gateway.irys.xyz/${receipt?.id}
,
sellerFeeBasisPoints: 5.5,
tokenStandard: TokenStandard.Fungible,
decimals:9,
symbol:"$FAME",
creators:[],
collection:authoritySigner,
uses:TokenStandard.Fungible,
};
const metadataaccount = createMetadataAccountV3(
umi,
{
mint,
payer: authoritySigner,
mintAuthority: authoritySigner,
updateAuthority: authoritySigner,
data,
}
)
}
const MintTokens = async () => { console.log("Starting MintTokens function");
// Minting tokens
console.log("Minting tokens...");
await mintToken();
// Create the token account
console.log("Creating token account...");
await CreateAccount()
// console.log("Mint account created:", mintAccount.result);
await mintV1(umi, { mint: mint, tokenOwner: authorityKeyPair.publicKey, amount: 42, tokenStandard: TokenStandard.Fungible, }).sendAndConfirm(umi);
};
MintTokens().catch(console.error);
**`
I'm not sure if it's the case here, but sometimes this error happens if you are trying to use Token-2022 and not specifically deriving the token account with that program id and passing it in.
I had this problem too. Just retried 4 times and it worked randomly.
I also retried 4 times and it worked randomly. I don't know why
I have this problem too. What about using createFungible helper method?
hey all! I had the same issue, shout out to @MarkSackerberg from Metaplex for solving it:
// See https://developers.metaplex.com/token-metadata/collections
await verifyCollectionV1(umi, {
// The metadata PDA for the NFT we want to verify inside the collection.
metadata: findMetadataPda(umi, { mint: publicKey(nftAddress) }),
// The Collection NFT that is already set on the Metadata account of the NFT but not yet verified.
collectionMint: publicKey(collectionAddress),
// The Update Authority of the Collection NFT as a signer, in this case the umiKeypair
authority: umi.identity,
}).sendAndConfirm(umi);
console.log(`Collection verified!`);