codeninja819 / create-solana-token

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can we mint on frontend using solana wallet adapter

umaid56 opened this issue · comments

Hi Thanks for this, I am facing an issue while minting the SPLToken2022 using a React app. Encounters an issue when using the Solana wallet adapter as the signer.

const signerTokenAccount = await createAccount(
    connection,
    payer,   //Here
    mint,
    payer.publicKey,
    undefined,
    undefined,
    TOKEN_2022_PROGRAM_ID
  );
  console.log('signerTokenAccount :>> ', signerTokenAccount);
  await mintTo(
    connection,
    payer, // Here
    mint,
    signerTokenAccount,
    mintAuthority,
    mintAmount,
    [],
    undefined,
    TOKEN_2022_PROGRAM_ID
  );


Can you give me more context?
And I think payer parameter is an address not signer.

Thanks for reply
basically payer is a signer, when we do with the keypair then we have to pass the keypair from here but I'm stuck for a while as I am minting from phantom wallet using Solana wallet adapter package.

here is import params

mintTo(connection: Connection, payer: Signer, mint: PublicKey, destination: PublicKey, authority: PublicKey | Signer, amount: number | bigint, multiSigners?: Signer[] | undefined, confirmOptions?: ConfirmOptions | undefined, programId?: PublicKey | undefined): Promise<...>

Hi @codeninja819
createAccount(connection: Connection, payer: Signer, mint: PublicKey, owner: PublicKey, keypair?: Keypair | undefined, confirmOptions?: ConfirmOptions | undefined, programId?: PublicKey | undefined):

create Account take payer as a signer