@@ -11,6 +11,10 @@ import CTokenClientPrerequisites from "/snippets/light-token-guides/light-token-
1111import ClientCustomRentConfig from " /snippets/light-token-guides/client-custom-rent-config.mdx" ;
1212import { CodeCompare } from " /snippets/jsx/code-compare.jsx" ;
1313import WelcomePageInstall from " /snippets/setup/welcome-page-install.mdx" ;
14+ import {
15+ splMintToCode ,
16+ lightMintToCode ,
17+ } from " /snippets/code-samples/code-compare-snippets.jsx" ;
1418
15191 . Mint To creates new tokens of a mint and deposits them to a specified token account.
16202 . Before we can mint any tokens, we need an initialized mint account (SPL, Token-2022 or Light) for which we hold the mint authority.
@@ -28,30 +32,10 @@ The function auto-detects the token program (SPL, Token-2022, or Light) from the
2832Compare to SPL:
2933
3034<CodeCompare
31- firstCode = { ` // SPL mintTo
32- import { mintTo } from "@solana/spl-token";
33-
34- const tx = await mintTo(
35- connection,
36- payer,
37- mint,
38- destination,
39- mintAuthority,
40- amount
41- ); ` }
42- secondCode = { ` // light-token mintTo
43- import { mintToInterface } from "@lightprotocol/compressed-token";
44-
45- const tx = await mintToInterface(
46- rpc,
47- payer,
48- mint,
49- destination,
50- mintAuthority,
51- amount
52- ); ` }
53- firstLabel = " SPL"
54- secondLabel = " light-token"
35+ firstCode = { splMintToCode }
36+ secondCode = { lightMintToCode }
37+ firstLabel = " SPL"
38+ secondLabel = " light-token"
5539/>
5640
5741<Info >
@@ -84,25 +68,24 @@ import {
8468} from " @lightprotocol/compressed-token" ;
8569
8670async function main() {
87- const rpc = createRpc ();
88- const payer = Keypair .generate ();
89- const sig = await rpc .requestAirdrop (payer .publicKey , 10e9 );
90- await rpc .confirmTransaction (sig );
71+ const rpc = createRpc ();
72+ const payer = Keypair .generate ();
73+ const sig = await rpc .requestAirdrop (payer .publicKey , 10e9 );
74+ await rpc .confirmTransaction (sig );
9175
92- const { mint } = await createMintInterface (rpc , payer , payer , null , 9 );
76+ const { mint } = await createMintInterface (rpc , payer , payer , null , 9 );
9377
94- const recipient = Keypair .generate ();
95- await createAtaInterface (rpc , payer , mint , recipient .publicKey );
78+ const recipient = Keypair .generate ();
79+ await createAtaInterface (rpc , payer , mint , recipient .publicKey );
9680
97- const destination = getAssociatedTokenAddressInterface (mint , recipient .publicKey );
98- const tx = await mintToInterface (rpc , payer , mint , destination , payer , 1_000_000_000 );
81+ const destination = getAssociatedTokenAddressInterface (mint , recipient .publicKey );
82+ const tx = await mintToInterface (rpc , payer , mint , destination , payer , 1_000_000_000 );
9983
100- console .log (" Tx:" , tx );
84+ console .log (" Tx:" , tx );
10185}
10286
10387main ().catch (console .error );
104-
105- ````
88+ ```
10689
10790``` typescript Instruction
10891import " dotenv/config" ;
@@ -180,7 +163,7 @@ const payer = Keypair.fromSecretKey(
180163
181164 console .log (" Tx:" , signature );
182165})();
183- ````
166+ ```
184167
185168</CodeGroup >
186169
0 commit comments