Skip to content

Commit 524b0d6

Browse files
committed
docs(web-client): implement bech32 formatting for v12 tutorials
1 parent 44d0c5f commit 524b0d6

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

docs/src/web-client/counter_contract_tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export async function incrementCounterContract(): Promise<void> {
117117

118118
// dynamic import → only in the browser, so WASM is loaded client‑side
119119
const {
120-
AccountId,
120+
Address,
121121
AccountBuilder,
122122
AccountComponent,
123123
AccountStorageMode,
@@ -182,9 +182,9 @@ export async function incrementCounterContract(): Promise<void> {
182182

183183
// Building the counter contract
184184
// Counter contract account id on testnet
185-
const counterContractId = AccountId.fromHex(
186-
'0xe59d8cd3c9ff2a0055da0b83ed6432',
187-
);
185+
const counterContractId = Address.fromBech32(
186+
'mtst1arjemrxne8lj5qz4mg9c8mtyxg954483',
187+
).accountId();
188188

189189
// Reading the public state of the counter contract from testnet,
190190
// and importing it into the WebClient

docs/src/web-client/create_deploy_tutorial.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ export async function createMintConsume(): Promise<void> {
243243
return;
244244
}
245245

246-
const { WebClient, AccountStorageMode } = await import(
246+
// dynamic import → only in the browser, so WASM is loaded client‑side
247+
const { WebClient, AccountStorageMode, NoteType, Address } = await import(
247248
'@demox-labs/miden-sdk'
248249
);
249250

docs/src/web-client/creating_multiple_notes_tutorial.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,10 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
267267
const {
268268
WebClient,
269269
AccountStorageMode,
270-
AccountId,
270+
Address,
271271
NoteType,
272272
TransactionProver,
273+
NetworkId,
273274
Note,
274275
NoteAssets,
275276
OutputNoteArray,
@@ -346,15 +347,15 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
346347

347348
// ── build 3 P2ID notes (100 MID each) ─────────────────────────────────────────────
348349
const recipientAddresses = [
349-
'0xbf1db1694c83841000008cefd4fce0',
350-
'0xee1a75244282c32000010a29bed5f4',
351-
'0x67dc56bd0cbe629000006f36d81029',
350+
'mtst1aqezqc90x7dkzypr9m5fmlpp85w6cl04',
351+
'mtst1apjg2ul76wrkxyr5qlcnczaskypa4ljn',
352+
'mtst1arpee6y9cm8t7ypn33pc8fzj6gkzz7kd',
352353
];
353354

354355
const assets = new NoteAssets([new FungibleAsset(faucet.id(), BigInt(100))]);
355356

356357
const p2idNotes = recipientAddresses.map((addr) => {
357-
const receiverAccountId = AccountId.fromHex(addr);
358+
const receiverAccountId = Address.fromBech32(addr).accountId();
358359
const note = Note.createP2IDNote(
359360
alice.id(),
360361
receiverAccountId,

docs/src/web-client/foreign_procedure_invocation_tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export async function foreignProcedureInvocation(): Promise<void> {
134134
const {
135135
AccountBuilder,
136136
AccountComponent,
137-
AccountId,
137+
Address,
138138
AccountType,
139139
MidenArrays,
140140
SecretKey,
@@ -218,9 +218,9 @@ export async function foreignProcedureInvocation(): Promise<void> {
218218
console.log('\n[STEP 2] Building counter contract from public state');
219219

220220
// Define the Counter Contract account id from counter contract deploy (same as Rust)
221-
const counterContractId = AccountId.fromHex(
222-
'0xe59d8cd3c9ff2a0055da0b83ed6432',
223-
);
221+
const counterContractId = Address.fromBech32(
222+
'mtst1arjemrxne8lj5qz4mg9c8mtyxg954483',
223+
).accountId();
224224

225225
// Import the counter contract
226226
let counterContractAccount = await client.getAccount(counterContractId);

docs/src/web-client/mint_consume_create_tutorial.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ import { NoteType } from "@demox-labs/miden-sdk";
113113
// ...
114114

115115
// 7. Send tokens from Alice to Bob
116-
const bobAccountId = "0x599a54603f0cf9000000ed7a11e379";
116+
const bobAccountId = Address.fromBech32(
117+
'mtst1apve54rq8ux0jqqqqrkh5y0r0y8cwza6_qruqqypuyph',
118+
).accountId();
117119
console.log("Sending tokens to Bob's account...");
118120

119121
const sendTxRequest = client.newSendTransactionRequest(
120122
alice.id(), // Sender account
121-
AccountId.fromHex(bobAccountId), // Recipient account
123+
boxAccountId, // Recipient account
122124
faucet.id(), // Asset ID (faucet that created the tokens)
123125
NoteType.Public, // Note visibility
124126
BigInt(100), // Amount to send
@@ -152,23 +154,23 @@ export async function createMintConsume(): Promise<void> {
152154
}
153155

154156
// dynamic import → only in the browser, so WASM is loaded client‑side
155-
const { WebClient, AccountStorageMode, AccountId, NoteType } = await import(
157+
const { WebClient, AccountStorageMode, NoteType, Address } = await import(
156158
'@demox-labs/miden-sdk'
157159
);
158160

159161
const nodeEndpoint = 'https://rpc.testnet.miden.io';
160162
const client = await WebClient.createClient(nodeEndpoint);
161163

162-
// 1. Sync and log block
164+
// 1. Sync with the latest blockchain state
163165
const state = await client.syncState();
164166
console.log('Latest block number:', state.blockNum());
165167

166-
// 2. Create Alices account
168+
// 2. Create Alice's account
167169
console.log('Creating account for Alice…');
168170
const alice = await client.newWallet(AccountStorageMode.public(), true, 0);
169171
console.log('Alice ID:', alice.id().toString());
170172

171-
// 3. Deploy faucet
173+
// 3. Deploy a fungible faucet
172174
console.log('Creating faucet…');
173175
const faucet = await client.newFaucet(
174176
AccountStorageMode.public(),
@@ -185,7 +187,7 @@ export async function createMintConsume(): Promise<void> {
185187
// 4. Mint tokens to Alice
186188
await client.syncState();
187189

188-
console.log('Minting 1000 tokens to Alice...');
190+
console.log('Minting tokens to Alice...');
189191
const mintTxRequest = client.newMintTransactionRequest(
190192
alice.id(),
191193
faucet.id(),
@@ -204,7 +206,7 @@ export async function createMintConsume(): Promise<void> {
204206
const mintedNoteIds = mintedNotes.map((n) =>
205207
n.inputNoteRecord().id().toString(),
206208
);
207-
console.log('Consumable note IDs:', mintedNoteIds);
209+
console.log('Minted note IDs:', mintedNoteIds);
208210

209211
// 6. Consume minted notes
210212
console.log('Consuming minted notes...');
@@ -216,11 +218,13 @@ export async function createMintConsume(): Promise<void> {
216218
console.log('Notes consumed.');
217219

218220
// 7. Send tokens to Bob
219-
const bobAccountId = '0x599a54603f0cf9000000ed7a11e379';
221+
const bobAccountId = Address.fromBech32(
222+
'mtst1apve54rq8ux0jqqqqrkh5y0r0y8cwza6_qruqqypuyph',
223+
).accountId();
220224
console.log("Sending tokens to Bob's account...");
221225
const sendTxRequest = client.newSendTransactionRequest(
222226
alice.id(),
223-
AccountId.fromHex(bobAccountId),
227+
bobAccountId,
224228
faucet.id(),
225229
NoteType.Public,
226230
BigInt(100),

docs/src/web-client/unauthenticated_note_how_to.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ This tutorial assumes you have a basic understanding of Miden assembly. To quick
3737
## Step-by-step process
3838

3939
1. **Next.js Project Setup:**
40+
4041
- Create a new Next.js application with TypeScript.
4142
- Install the Miden WebClient SDK.
4243

4344
2. **WebClient Initialization:**
45+
4446
- Set up the WebClient to connect with the Miden testnet.
4547
- Configure a delegated prover for improved performance.
4648

4749
3. **Account Creation:**
50+
4851
- Create wallet accounts for Alice and multiple transfer recipients.
4952
- Deploy a fungible faucet for token minting.
5053

5154
4. **Initial Token Setup:**
55+
5256
- Mint tokens from the faucet to Alice's account.
5357
- Consume the minted tokens to prepare for transfers.
5458

@@ -154,7 +158,6 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
154158
const {
155159
WebClient,
156160
AccountStorageMode,
157-
AccountId,
158161
NoteType,
159162
TransactionProver,
160163
Note,
@@ -255,11 +258,9 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
255258
console.log('Receiver:', receiver.id().toString());
256259

257260
const assets = new NoteAssets([new FungibleAsset(faucet.id(), BigInt(50))]);
258-
const receiverAccountId = AccountId.fromHex(receiver.id().toString());
259-
260261
const p2idNote = Note.createP2IDNote(
261262
sender.id(),
262-
receiverAccountId,
263+
receiver.id(),
263264
assets,
264265
NoteType.Public,
265266
new Felt(BigInt(0)), // aux value

0 commit comments

Comments
 (0)