11import "dotenv/config" ;
22import {
33 Keypair ,
4+ SystemProgram ,
45 Transaction ,
56 sendAndConfirmTransaction ,
67} from "@solana/web3.js" ;
78import { createRpc } from "@lightprotocol/stateless.js" ;
9+ import { LightTokenProgram } from "@lightprotocol/compressed-token" ;
810import {
9- LightTokenProgram ,
10- createMintInterface ,
11- } from "@lightprotocol/compressed-token" ;
12- import { TOKEN_PROGRAM_ID } from "@solana/spl-token" ;
11+ MINT_SIZE ,
12+ TOKEN_PROGRAM_ID ,
13+ createInitializeMint2Instruction ,
14+ } from "@solana/spl-token" ;
1315import { homedir } from "os" ;
1416import { readFileSync } from "fs" ;
1517
@@ -26,27 +28,40 @@ const payer = Keypair.fromSecretKey(
2628) ;
2729
2830( async function ( ) {
29- const { mint : existingMint } = await createMintInterface (
30- rpc ,
31- payer ,
32- payer ,
31+ const mintKeypair = Keypair . generate ( ) ;
32+ const decimals = 9 ;
33+ const rentExemptBalance = await rpc . getMinimumBalanceForRentExemption (
34+ MINT_SIZE
35+ ) ;
36+
37+ const createMintAccountIx = SystemProgram . createAccount ( {
38+ fromPubkey : payer . publicKey ,
39+ lamports : rentExemptBalance ,
40+ newAccountPubkey : mintKeypair . publicKey ,
41+ programId : TOKEN_PROGRAM_ID ,
42+ space : MINT_SIZE ,
43+ } ) ;
44+
45+ const initializeMintIx = createInitializeMint2Instruction (
46+ mintKeypair . publicKey ,
47+ decimals ,
48+ payer . publicKey ,
3349 null ,
34- 9 ,
35- undefined ,
36- undefined ,
3750 TOKEN_PROGRAM_ID
3851 ) ;
3952
40- // Register SPL interface PDA to enable interop with Light Tokens
4153 const ix = await LightTokenProgram . createSplInterface ( {
4254 feePayer : payer . publicKey ,
43- mint : existingMint ,
55+ mint : mintKeypair . publicKey ,
4456 tokenProgramId : TOKEN_PROGRAM_ID ,
4557 } ) ;
4658
47- const tx = new Transaction ( ) . add ( ix ) ;
48- const signature = await sendAndConfirmTransaction ( rpc , tx , [ payer ] ) ;
59+ const tx = new Transaction ( ) . add ( createMintAccountIx , initializeMintIx , ix ) ;
60+ const signature = await sendAndConfirmTransaction ( rpc , tx , [
61+ payer ,
62+ mintKeypair ,
63+ ] ) ;
4964
50- console . log ( "Mint:" , existingMint . toBase58 ( ) ) ;
65+ console . log ( "Mint:" , mintKeypair . publicKey . toBase58 ( ) ) ;
5166 console . log ( "Tx:" , signature ) ;
5267} ) ( ) ;
0 commit comments