How to create a spl22 token?

19 Views Asked by At

it creates a token, the transaction is executed. But in the end the token does not appear in the wallet, why? What have I done wrong?

export const createToken22 = async ({
    wallet,
    connection,
    name,
    symbol,
    decimals,
    metadata,
    sellerFeeBasisPoints,
  }: {
    wallet: Wallet;
    connection: Connection;
    name: string;
    symbol: string;
    decimals: number;
    metadata: string;
    sellerFeeBasisPoints: number;
  }): Promise<string> =>{
    enqueueSnackbar("initialize umi", { variant: "info" });
    const umi = createUmi(connection.rpcEndpoint);
    umi.use(mplTokenMetadata());
    umi.use(walletAdapterIdentity(wallet.adapter));
    const mint = generateSigner(umi);

    try {
      const result = await createV1(umi, {
        mint,
        name,
        symbol,
        decimals,
        uri: metadata,
        sellerFeeBasisPoints: percentAmount(sellerFeeBasisPoints), 
      }).sendAndConfirm(umi);

      console.log("Transaction hash: " + bs58.encode(result.signature));
  
      console.log("Mint: " + mint.publicKey);
      console.log("Signature: " + bs58.encode(result.signature));
      if (result.signature) {
        enqueueSnackbar("Token created", { variant: "success" });
      }
      return mint.publicKey;
    } catch (error) {
      enqueueSnackbar("Error creating Token: " + error, { variant: "error" });
      console.log(error);
      return "Error creating Token: " + error;
    }
  };

I tried to make the transaction with transaction.add from the solana library but doesnt work. I tried to convert the metadata into a json string but the result is the same.

0

There are 0 best solutions below