I recently built a simple vue.js app that can create spl token with metadata.
Please check this site.
https://solana-create-spl-token.vercel.app/
This works well on mainnet, devnet.
I hope you find the following script snippet helpful.
import {Connection, LAMPORTS_PER_SOL, PublicKey, Transaction, SystemProgram, Keypair, TransactionSignature} from @solana/web3.js
import { PROGRAM_ID, createCreateMetadataAccountV3Instruction } from '@metaplex-foundation/mpl-token-metadata'
import { MINT_SIZE, AuthorityType, TOKEN_PROGRAM_ID, createSetAuthorityInstruction, getMinimumBalanceForRentExemptMint, createInitializeMintInstruction, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createMintToInstruction } from '@solana/spl-token';
...
const mintKeypair = Keypair.generate();
const tokenATA = await getAssociatedTokenAddress(mintKeypair.publicKey, publicKey.value);
const metadata = PublicKey.findProgramAddressSync(
[
Buffer.from("metadata"),
PROGRAM_ID.toBuffer(),
mintKeypair.publicKey.toBuffer(),
],
PROGRAM_ID,
)[0];
const createMetadataInstruction = createCreateMetadataAccountV3Instruction(
{
metadata: metadata,
mint: mintKeypair.publicKey,
mintAuthority: publicKey.value,
payer: publicKey.value,
updateAuthority: publicKey.value,
},
{
createMetadataAccountArgsV3: {
data: {
name: tokenName.value,
symbol: tokenSymbol.value,
uri: metadataUri.value,
creators: null,
sellerFeeBasisPoints: 0,
uses: null,
collection: null,
},
isMutable: !immutable.value,
collectionDetails: null,
},
},
);