0

I am facing an issue while minting the SPLToken2022 using a React app. the problem arises when minting the transaction. The process works fine when passing the keypairs directly, but encounters an issue when using the Solana wallet adapter as the signer. While using the keypair, I called this function like

const mintSig = await mintTo(connection, userWallet, mintAddress.publicKey, sourceAccount, userWallet, mintAmount, [], undefined, TOKEN_2022_PROGRAM_ID);

When I've to mint a token using react, which function should I pass? If someone shares the rust program also with test cases, it'll be the helpful.

Thanks

1 Answer 1

1

When working with web wallets, things are always a little trickier because you don't have direct access to the signing keypair. The utility functions like mintTo are unfortunately not usable in web apps because of that.

Instead, you'll need to create the instruction, add it to a transaction, and ask for the wallet to sign that. To create the instruction, you can do:

const ix = createMintToInstruction(
    mintAddress.publicKey,
    sourceAccount,
    userWallet, // assuming this is a pubkey
    mintAmount,
    [],
    TOKEN_2022_PROGRAM_ID
);

And then provide that to whatever wallet connector you're using.

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.