Skip to main content
added 46 characters in body
Source Link
denimcodes
  • 139
  • 1
  • 9

I amget 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);
}

I am trying to mint tokens on web3.

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);
}

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);
}
Source Link
denimcodes
  • 139
  • 1
  • 9

Error: Signature verification failed when trying to mint tokens

I am trying to mint tokens on web3.

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);
}