@@ -44,16 +44,15 @@ Add this to the end of your `createMintConsume` function in `lib/createMintConsu
4444// 4. Mint tokens from the faucet to Alice
4545await client .syncState ();
4646
47- console .log (" Minting 1000 tokens to Alice..." );
47+ console .log (" Minting tokens to Alice..." );
4848const mintTxRequest = client .newMintTransactionRequest (
4949 alice .id (), // Target account (who receives the tokens)
5050 faucet .id (), // Faucet account (who mints the tokens)
51- NoteType .Public , // Note visibility (public = on-chain )
51+ NoteType .Public , // Note visibility (public = onchain )
5252 BigInt (1000 ), // Amount to mint (in base units)
5353);
5454
55- const mintTx = await client .newTransaction (faucet .id (), mintTxRequest );
56- await client .submitTransaction (mintTx );
55+ await client .submitNewTransaction (faucet .id (), mintTxRequest );
5756
5857// Wait for the transaction to be processed
5958console .log (" Waiting 10 seconds for transaction confirmation..." );
@@ -92,10 +91,10 @@ Now let's consume the notes to add the tokens to Alice's account balance:
9291
9392``` ts
9493// 6. Consume the notes to add tokens to Alice's balance
95- console .log (" Consuming notes..." );
96- const consumeTxRequest = client .newConsumeTransactionRequest (noteIds );
97- const consumeTx = await client . newTransaction ( alice . id (), consumeTxRequest );
98- await client .submitTransaction ( consumeTx );
94+ console .log (" Consuming minted notes..." );
95+ const consumeTxRequest = client .newConsumeTransactionRequest (mintedNoteIds );
96+
97+ await client .submitNewTransaction ( alice . id (), consumeTxRequest );
9998
10099await client .syncState ();
101100console .log (" Notes consumed." );
@@ -117,8 +116,8 @@ import { NoteType } from "@demox-labs/miden-sdk";
117116
118117// 7. Send tokens from Alice to Bob
119118const bobAccountId = " 0x599a54603f0cf9000000ed7a11e379" ;
120- console .log (" Sending 100 tokens to Bob..." );
121-
119+ console .log (" Sending tokens to Bob's account ..." );
120+
122121const sendTxRequest = client .newSendTransactionRequest (
123122 alice .id (), // Sender account
124123 AccountId .fromHex (bobAccountId ), // Recipient account
@@ -127,10 +126,9 @@ const sendTxRequest = client.newSendTransactionRequest(
127126 BigInt (100 ), // Amount to send
128127);
129128
130- const sendTx = await client .newTransaction (alice .id (), sendTxRequest );
131- await client .submitTransaction (sendTx );
129+ await client .submitNewTransaction (alice .id (), sendTxRequest );
132130
133- console .log (" Tokens sent successfully!" );
131+ console .log (' Tokens sent successfully!' );
134132```
135133
136134<!-- prettier-ignore-end -->
@@ -149,6 +147,7 @@ Here's the complete `lib/createMintConsume.ts` file:
149147
150148``` ts
151149// lib/createMintConsume.ts
150+ // lib/createMintConsume.ts
152151export async function createMintConsume(): Promise <void > {
153152 if (typeof window === " undefined" ) {
154153 console .warn (" webClient() can only run in the browser" );
@@ -169,7 +168,7 @@ export async function createMintConsume(): Promise<void> {
169168
170169 // 2. Create Alice’s account
171170 console .log (" Creating account for Alice…" );
172- const alice = await client .newWallet (AccountStorageMode .public (), true );
171+ const alice = await client .newWallet (AccountStorageMode .public (), true , 0 );
173172 console .log (" Alice ID:" , alice .id ().toString ());
174173
175174 // 3. Deploy faucet
@@ -180,6 +179,7 @@ export async function createMintConsume(): Promise<void> {
180179 " MID" ,
181180 8 ,
182181 BigInt (1_000_000 ),
182+ 0 ,
183183 );
184184 console .log (" Faucet ID:" , faucet .id ().toString ());
185185
@@ -189,15 +189,14 @@ export async function createMintConsume(): Promise<void> {
189189 await client .syncState ();
190190
191191 console .log (" Minting tokens to Alice..." );
192- let mintTxRequest = client .newMintTransactionRequest (
192+ const mintTxRequest = client .newMintTransactionRequest (
193193 alice .id (),
194194 faucet .id (),
195195 NoteType .Public ,
196196 BigInt (1000 ),
197197 );
198198
199- let txResult = await client .newTransaction (faucet .id (), mintTxRequest );
200- await client .submitTransaction (txResult );
199+ await client .submitNewTransaction (faucet .id (), mintTxRequest );
201200
202201 console .log (" Waiting 10 seconds for transaction confirmation..." );
203202 await new Promise ((resolve ) => setTimeout (resolve , 10000 ));
@@ -212,29 +211,26 @@ export async function createMintConsume(): Promise<void> {
212211
213212 // 6. Consume minted notes
214213 console .log (" Consuming minted notes..." );
215- let consumeTxRequest = client .newConsumeTransactionRequest (mintedNoteIds );
214+ const consumeTxRequest = client .newConsumeTransactionRequest (mintedNoteIds );
216215
217- let txResult_2 = await client .newTransaction (alice .id (), consumeTxRequest );
218-
219- await client .submitTransaction (txResult_2 );
216+ await client .submitNewTransaction (alice .id (), consumeTxRequest );
220217
221218 await client .syncState ();
222219 console .log (" Notes consumed." );
223220
224221 // 7. Send tokens to Bob
225222 const bobAccountId = " 0x599a54603f0cf9000000ed7a11e379" ;
226223 console .log (" Sending tokens to Bob's account..." );
227- let sendTxRequest = client .newSendTransactionRequest (
224+ const sendTxRequest = client .newSendTransactionRequest (
228225 alice .id (),
229226 AccountId .fromHex (bobAccountId ),
230227 faucet .id (),
231228 NoteType .Public ,
232229 BigInt (100 ),
233230 );
234231
235- let txResult_3 = await client .newTransaction (alice .id (), sendTxRequest );
236-
237- await client .submitTransaction (txResult_3 );
232+ await client .submitNewTransaction (alice .id (), sendTxRequest );
233+ console .log (" Tokens sent successfully!" );
238234}
239235```
240236
0 commit comments