Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7836

can anyone tell me why i am getting this error when i trying to create a token

$
0
0

i am getting this errorError in create mint Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1

import { useConnection, useWallet } from "@solana/wallet-adapter-react";import * as token from "@solana/spl-token";import * as web3 from "@solana/web3.js";import { useState } from "react";const CreateMint = () => {  const { connection } = useConnection();  const { publicKey, sendTransaction } = useWallet();  const [minttoken, setMintToken] = useState<web3.PublicKey>();  async function createMint() {    if (!publicKey) return;    const payer = web3.Keypair.generate();    console.log("Payer:", payer.publicKey.toString());    const lamports = await token.getMinimumBalanceForRentExemptMint(connection);    const transaction = new web3.Transaction();    const instruction = web3.SystemProgram.transfer({      fromPubkey: publicKey,      toPubkey: payer.publicKey,      lamports,    });    transaction.add(instruction);    const sign = await sendTransaction(transaction, connection);    console.log("sol transfered from your wallet to payer account", sign);       try {        const Token = await token.createMint( //getting error in this line            connection,            payer,            payer.publicKey,            payer.publicKey,            2,          );          console.log( `Token Mint: https://explorer.solana.com/address/${Token}?cluster=devnet`)          setMintToken(Token);       } catch (error) {        console.log("Error in create mint", error);       }    }  return (<div className=" w-fit mx-auto mt-4">      {publicKey ? (<button className="bg-white text-black px-4 py-2 rounded-xl font-bold"        onClick={createMint}>          Create Mint</button>      ) : null}<div>        {minttoken ? (<div><div className="text-xl">Mint Token Address:</div><a              className="text-blue-500"              href={`https://explorer.solana.com/address/${minttoken}?cluster=devnet`}              target="_blank">              {minttoken?.toString()}</a></div>        ) : null}</div></div>  );};export default CreateMint;

Viewing all articles
Browse latest Browse all 7836

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>