1

How can I solve this? as far as I have seen, it has the typ connection..

export async function createMint(
  wallet: WalletAdapter,
  mintAuthority: Keypair,
  decimals: number
) {
  if (!wallet.connected) {
    throw new Error('Wallet is not connected');
  }

  const mint = Keypair.generate();
  const instructions: TransactionInstruction[] = [];

  instructions.push(
    TokenInstructions.initializeMint({
      mint: mint.publicKey,
      decimals: decimals,
      mintAuthority: mintAuthority.publicKey,
    })
  );
  if (!mintAuthority.secretKey || mintAuthority.secretKey.length === 0) {
    throw new Error('mintAuthority does not contain a private key');
  }

  const connection = new Connection('https://devnet.helius-rpc.com/?api-key=5d69c879-36f4-4acf-87b4-e44a64c07acc');
  const transaction = new Transaction().add(...instructions);
  transaction.feePayer = wallet.publicKey;
  transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;

  // Sign the transaction with the payer
  transaction.sign(mintAuthority);
    
  // Serialize and send the transaction
  try{
    const signature = await connection.sendAndConfirmTransaction(transaction,[mintAuthority]);  // sendAndConfirmTransaction does not exist for typ connection
    return {
      mint,
      transaction: signature,
    };
  } catch (error) {
    console.error('Transaction error', error);
    throw error;
  }
}  ```

1 Answer 1

0

sendAndConfirmTransaction is a helper function in the web3.js library, and you can see its implementation at https://github.com/solana-labs/solana-web3.js/blob/5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be/packages/library-legacy/src/utils/send-and-confirm-transaction.ts#L18

Be sure to import it properly using something like:

import { sendAndConfirmTransaction } from '@solana/web3.js';

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.