A Solana program built with Anchor that enables easy creation of SPL Token-2022 tokens with metadata. This program provides a simple interface to create tokens with custom metadata, mint an initial supply, and automatically disable further minting.
- Token-2022 Support: Built on the latest SPL Token-2022 standard
- Metadata Integration: Includes name, symbol, and URI metadata
- One-Shot Creation: Create, mint, and lock tokens in a single transaction
- Automatic Rent Calculation: Handles rent-exempt lamports for metadata storage
- Mint Authority Removal: Automatically disables further minting after initial creation
- Program ID:
CVn1nLhL57hZbAELkFXMEZzMiNLf8ayrcKC3cqLWr3w2 - Framework: Anchor
- Token Standard: SPL Token-2022
- Rust
- Solana CLI
- Anchor Framework
- Node.js (for client integration)
- Clone the repository:
git clone <repository-url>
cd token-launcher- Install dependencies:
anchor build- Deploy the program:
anchor deployThe program exposes a single instruction: create_token_2022
pub struct Token2022MetadataArgs {
pub name: String, // Token name (e.g., "My Token")
pub symbol: String, // Token symbol (e.g., "MTK")
pub uri: String, // Metadata URI (JSON metadata)
pub supply: u64, // Initial token supply (before decimals)
}pub struct CreateTokenAccount<'info> {
#[account(mut)]
pub payer: Signer<'info>, // Transaction fee payer
#[account(
init,
payer = payer,
mint::decimals = 6,
mint::authority = payer.key(),
extensions::metadata_pointer::authority = payer,
extensions::metadata_pointer::metadata_address = mint,
)]
pub mint: InterfaceAccount<'info, Mint>, // New token mint
#[account(
init,
payer = payer,
associated_token::mint = mint,
associated_token::authority = payer,
)]
pub payer_token_account: InterfaceAccount<'info, TokenAccount>, // Payer's token account
pub associated_token_program: Program<'info, AssociatedToken>,
pub system_program: Program<'info, System>,
pub token_program: Interface<'info, TokenInterface>,
}import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { TokenLauncher } from "../target/types/token_launcher";
const program = anchor.workspace.TokenLauncher as Program<TokenLauncher>;
async function createToken() {
const tokenKeypair = anchor.web3.Keypair.generate();
const [payerTokenAccount] = await anchor.web3.PublicKey.findProgramAddress(
[
wallet.publicKey.toBuffer(),
TOKEN_PROGRAM_ID.toBuffer(),
tokenKeypair.publicKey.toBuffer(),
],
ASSOCIATED_TOKEN_PROGRAM_ID
);
const tx = await program.methods
.createToken2022({
name: "My Token",
symbol: "MTK",
uri: "https://example.com/metadata.json",
supply: new anchor.BN(1000000), // 1M tokens
})
.accounts({
payer: wallet.publicKey,
mint: tokenKeypair.publicKey,
payerTokenAccount,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
systemProgram: anchor.web3.SystemProgram.programId,
tokenProgram: TOKEN_2022_PROGRAM_ID,
})
.signers([tokenKeypair])
.rpc();
console.log("Token created:", tx);
}use anchor_client::solana_sdk::signature::{Keypair, Signer};
use anchor_client::{Client, Cluster};
let payer = Keypair::new();
let mint = Keypair::new();
let client = Client::new(Cluster::Devnet, Rc::new(payer));
let program = client.program(program_id);
let tx = program
.request()
.instruction(instruction::create_token_2022(
program_id,
Token2022MetadataArgs {
name: "My Token".to_string(),
symbol: "MTK".to_string(),
uri: "https://example.com/metadata.json".to_string(),
supply: 1_000_000,
},
))
.accounts(/* ... */)
.signer(&mint)
.send()?;- Decimals: 6 (hardcoded)
- Standard: SPL Token-2022
- Metadata: Stored on-chain using Token-2022 metadata extension
- Mint Authority: Automatically removed after creation
- Supply: Fixed at creation time
- Rent-Exempt Calculation: Automatically calculates and transfers required lamports for metadata storage
- Authority Management: Removes mint authority after initial supply creation
- Metadata Validation: Ensures proper metadata initialization
- Account Constraints: Uses Anchor's account constraints for security
Run the test suite:
anchor testanchor buildsolana-keygen new -o path/to/your/buffer/token-launcher-buffer.jsonsolana program deploy --buffer path/to/your/buffer/token-launcher-buffer.json path/to/your/token-launcher/target/deploy/token_launcher.so- Buffer Method: Useful for large programs or when you need to deploy in multiple steps
- Anchor Method: Simpler and handles most deployment scenarios automatically
- Program Binary: Located at
target/deploy/token_launcher.soafter runninganchor build - Buffer Benefits: Allows for staged deployments and better resource management
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- email : aneeshm.rem@gmail.com
- linkedin : https://www.linkedin.com/in/aneeshmaniyappan/
Note: This program is designed for educational and development purposes. Please audit thoroughly before using in production environments.