I get the error when trying to mint tokens on web3 with mintToChecked
function.
Here's the code:
async function mintToken(
connection: web3.Connection,
payer: web3.Keypair,
userAddress: web3.PublicKey
) {
const tokenMint = await spl.createMint(
connection,
payer,
userAddress,
userAddress,
8
);
console.log("token mint: ", tokenMint.toBase58());
const userTokenAddress = await spl.createAssociatedTokenAccount(
connection,
payer,
tokenMint,
userAddress
);
console.log("user token address: ", userTokenAddress.toBase58());
const tx = await spl.mintToChecked(
connection,
payer,
tokenMint,
userTokenAddress,
userAddress,
100,
8
);
console.log("mint tx: ", tx);
const userTokenAmount = await connection.getTokenAccountBalance(
userTokenAddress
);
console.log("user token amount: ", userTokenAmount);
}