Skip to content

Instantly share code, notes, and snippets.

@coderwithsense
Last active April 17, 2024 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderwithsense/169ffce12010fcb9a57e912e93f14bc9 to your computer and use it in GitHub Desktop.
Save coderwithsense/169ffce12010fcb9a57e912e93f14bc9 to your computer and use it in GitHub Desktop.
CREATING SPL-TOKEN
import { percentAmount, generateSigner, signerIdentity, createSignerFromKeypair } from '@metaplex-foundation/umi'
import { TokenStandard, createAndMint } from '@metaplex-foundation/mpl-token-metadata'
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { mplCandyMachine } from "@metaplex-foundation/mpl-candy-machine";
import "@solana/web3.js";
import base58 from 'bs58';
import { clusterApiUrl } from '@solana/web3.js';
// CHANGE THESE VALUES
const secret = "REPLACE WITH YOUR SECRET KEY";
const cluster = "devnet"; //Replace with the network you want to use "devnet" or "mainnet-beta
const TOKEN_name = "PASTE YOUR TOKEN NAME HERE"
const TOKEN_symbol = "PASTE YOUR TOKEN SYMBOL HERE"
const TOKEN_url = "PASTE YOUR TOKEN IMAGE URL HERE"
const TOKEN_amount = "PASTE AMOUNT OF TOKENS YOU WANT"
const TOKEN_decimals = 9;
// DO NOT CHANGE ANYTHING BELOW THIS LINE
function createmint() {
const umi = createUmi(clusterApiUrl('devnet')); //Replace with your QuickNode RPC Endpoint
const userWallet = umi.eddsa.createKeypairFromSecretKey(new Uint8Array(base58.decode(secret)));
const userWalletSigner = createSignerFromKeypair(umi, userWallet);
const mint = generateSigner(umi);
umi.use(signerIdentity(userWalletSigner));
umi.use(mplCandyMachine())
createAndMint(umi, {
mint,
authority: "umi.identity",
name: TOKEN_name,
symbol: TOKEN_symbol,
uri: TOKEN_url,
image: TOKEN_url,
sellerFeeBasisPoints: percentAmount(0),
decimals: 9,
amount: TOKEN_amount * (10 ** TOKEN_decimals), // 1 billion
tokenOwner: userWallet.publicKey,
tokenStandard: TokenStandard.Fungible,
}).sendAndConfirm(umi).then(() => {
console.log("Successfully minted 1 billion tokens (", mint.publicKey, ")");
});
}
createmint();
@tabatinga0xffff
Copy link

    amount: TOKEN_amount * (10 ** TOKEN_decimals), // 1 billion

This isn't the max supply, is it? How to specify it then?

@coderwithsense
Copy link
Author

    amount: TOKEN_amount * (10 ** TOKEN_decimals), // 1 billion

This isn't the max supply, is it? How to specify it then?

Yes it's the max supply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment