0

I have the following code:

    import { clusterApiUrl, Connection, Keypair, PublicKey, } from "@solana/web3.js"; import { createMint, createAccount, mintTo,getAccount,getMint, getOrCreateAssociatedTokenAccount,getAssociatedTokenAddress,getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { config } from "dotenv"; import {ASSOCIATED_TOKEN_PROGRAM_ID } from "@solana/spl-token"; config(); const fs = require("fs"); export const PROGRAM_ADDRESS = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'; export const PROGRAM_ID = new PublicKey(PROGRAM_ADDRESS); const connection = new Connection("https://api.devnet.solana.com");
    
    async function createToken() { // Load payer's secret key from environment variable const secretPayer = JSON.parse(fs.readFileSync("tokkZSgCL6B9ZHkTEQbcJBgNJayr7btwetSATHzqmFm.json").toString()) as number[]; const secretKeyPayer = Uint8Array.from(secretPayer); const payer = Keypair.fromSecretKey(secretKeyPayer); const decimals = 9; const mintAuthority = payer; const freezeAuthority = payer;
    
    // Load token mint addresss secret key const secretToken = JSON.parse(fs.readFileSync("PUf45Z1gwWh4b3Vmei3rNc1mRbvzoewL6FVypydDU6i.json").toString()) as number[]; const secretKeyToken = Uint8Array.from(secretToken); const tokenKeypair = Keypair.fromSecretKey(secretKeyToken);
    
    // Load token account's secret key const secretTokenAccount = JSON.parse(fs.readFileSync("TAjATuew96UZ3bqjZf4MYdExGXDmFquptfGG9iLGR9C.json").toString()) as number[]; const secretKeyTokenAccount = Uint8Array.from(secretTokenAccount); const tokenAccountKeypair = Keypair.fromSecretKey(secretKeyTokenAccount);
    
    // Create mint const mint = await createMint( connection, payer, payer.publicKey, payer.publicKey, decimals, tokenKeypair ); console.log("Token Mint Address:", mint.toBase58()); console.log("Tokens minted successfully!");
    
    //createTokenAccount const tokenAccount = await createAccount( connection, payer, tokenKeypair.publicKey, //token mint address key payer.publicKey, tokenAccountKeypair ) console.log(tokenAccount.toBase58());
    
    const ata = await getOrCreateAssociatedTokenAccount( connection, payer, tokenKeypair.publicKey, //token mint address key tokenAccountKeypair.publicKey, false );
    
    await getAssociatedTokenAddressSync( payer.publicKey, payer.publicKey, ); console.log(ata.address.toBase58());
    
    const tokenAccountInfo = await getAccount( connection, ata.address );
    
    console.log(tokenAccountInfo.amount); //0
    
    await mintTo( connection, payer, tokenKeypair.publicKey, ata.address, payer.publicKey, 1000000000000000000 // because decimals for the mint are set to 9 )
    
    const mintInfo = await getMint( connection, tokenKeypair.publicKey )
    
    console.log(mintInfo.supply); // 100
    
    const TokenAccountInfo = await getAccount( connection, ata.address )
    
    console.log(tokenAccountInfo.amount);
    
    /* // 1000000000 const ata = await getOrCreateAssociatedTokenAccount( connection, payer, tokenKeypair.publicKey, payer.publicKey,
    
    );
    
    console.log(ata.address.toBase58());
    
    */
    
    }
    
    createToken(); 

This keeps giving me the below error though. How can I fix this?

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
Token Mint Address: PUf45Z1gwWh4b3Vmei3rNc1mRbvzoewL6FVypydDU6i
Tokens minted successfully!
C:\Users\HP\node_modules\@solana\spl-token\src\state\mint.ts:95
    if (!info) throw new TokenAccountNotFoundError();
                     ^
TokenAccountNotFoundError
    at unpackMint (C:\Users\HP\node_modules\@solana\spl-token\src\state\mint.ts:95:22)
    at C:\Users\HP\node_modules\@solana\spl-token\src\state\mint.ts:82:12
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\HP\node_modules\@solana\spl-token\lib\cjs\state\mint.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.