Last active
April 17, 2024 20:04
-
-
Save coderwithsense/169ffce12010fcb9a57e912e93f14bc9 to your computer and use it in GitHub Desktop.
CREATING SPL-TOKEN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
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
This isn't the max supply, is it? How to specify it then?