Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/src/web-client/counter_contract_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export async function incrementCounterContract(): Promise<void> {

// dynamic import → only in the browser, so WASM is loaded client‑side
const {
AccountId,
Address,
AccountBuilder,
AccountComponent,
AccountStorageMode,
Expand Down Expand Up @@ -182,9 +182,9 @@ export async function incrementCounterContract(): Promise<void> {

// Building the counter contract
// Counter contract account id on testnet
const counterContractId = AccountId.fromHex(
'0xe59d8cd3c9ff2a0055da0b83ed6432',
);
const counterContractId = Address.fromBech32(
'mtst1arjemrxne8lj5qz4mg9c8mtyxg954483',
).accountId();

// Reading the public state of the counter contract from testnet,
// and importing it into the WebClient
Expand Down
3 changes: 2 additions & 1 deletion docs/src/web-client/create_deploy_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ export async function createMintConsume(): Promise<void> {
return;
}

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

Expand Down
11 changes: 6 additions & 5 deletions docs/src/web-client/creating_multiple_notes_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,10 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
const {
WebClient,
AccountStorageMode,
AccountId,
Address,
NoteType,
TransactionProver,
NetworkId,
Note,
NoteAssets,
OutputNoteArray,
Expand Down Expand Up @@ -346,15 +347,15 @@ export async function multiSendWithDelegatedProver(): Promise<void> {

// ── build 3 P2ID notes (100 MID each) ─────────────────────────────────────────────
const recipientAddresses = [
'0xbf1db1694c83841000008cefd4fce0',
'0xee1a75244282c32000010a29bed5f4',
'0x67dc56bd0cbe629000006f36d81029',
'mtst1aqezqc90x7dkzypr9m5fmlpp85w6cl04',
'mtst1apjg2ul76wrkxyr5qlcnczaskypa4ljn',
'mtst1arpee6y9cm8t7ypn33pc8fzj6gkzz7kd',
];

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

const p2idNotes = recipientAddresses.map((addr) => {
const receiverAccountId = AccountId.fromHex(addr);
const receiverAccountId = Address.fromBech32(addr).accountId();
const note = Note.createP2IDNote(
alice.id(),
receiverAccountId,
Expand Down
8 changes: 4 additions & 4 deletions docs/src/web-client/foreign_procedure_invocation_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export async function foreignProcedureInvocation(): Promise<void> {
const {
AccountBuilder,
AccountComponent,
AccountId,
Address,
AccountType,
MidenArrays,
SecretKey,
Expand Down Expand Up @@ -218,9 +218,9 @@ export async function foreignProcedureInvocation(): Promise<void> {
console.log('\n[STEP 2] Building counter contract from public state');

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

// Import the counter contract
let counterContractAccount = await client.getAccount(counterContractId);
Expand Down
26 changes: 15 additions & 11 deletions docs/src/web-client/mint_consume_create_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ import { NoteType } from "@demox-labs/miden-sdk";
// ...

// 7. Send tokens from Alice to Bob
const bobAccountId = "0x599a54603f0cf9000000ed7a11e379";
const bobAccountId = Address.fromBech32(
'mtst1apve54rq8ux0jqqqqrkh5y0r0y8cwza6_qruqqypuyph',
).accountId();
console.log("Sending tokens to Bob's account...");

const sendTxRequest = client.newSendTransactionRequest(
alice.id(), // Sender account
AccountId.fromHex(bobAccountId), // Recipient account
alice.id(), // Sender account ID
bobAccountId, // Recipient account ID
faucet.id(), // Asset ID (faucet that created the tokens)
NoteType.Public, // Note visibility
BigInt(100), // Amount to send
Expand Down Expand Up @@ -152,23 +154,23 @@ export async function createMintConsume(): Promise<void> {
}

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

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

// 1. Sync and log block
// 1. Sync with the latest blockchain state
const state = await client.syncState();
console.log('Latest block number:', state.blockNum());

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

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

console.log('Minting 1000 tokens to Alice...');
console.log('Minting tokens to Alice...');
const mintTxRequest = client.newMintTransactionRequest(
alice.id(),
faucet.id(),
Expand All @@ -204,7 +206,7 @@ export async function createMintConsume(): Promise<void> {
const mintedNoteIds = mintedNotes.map((n) =>
n.inputNoteRecord().id().toString(),
);
console.log('Consumable note IDs:', mintedNoteIds);
console.log('Minted note IDs:', mintedNoteIds);

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

// 7. Send tokens to Bob
const bobAccountId = '0x599a54603f0cf9000000ed7a11e379';
const bobAccountId = Address.fromBech32(
'mtst1apve54rq8ux0jqqqqrkh5y0r0y8cwza6_qruqqypuyph',
).accountId();
console.log("Sending tokens to Bob's account...");
const sendTxRequest = client.newSendTransactionRequest(
alice.id(),
AccountId.fromHex(bobAccountId),
bobAccountId,
faucet.id(),
NoteType.Public,
BigInt(100),
Expand Down
5 changes: 1 addition & 4 deletions docs/src/web-client/unauthenticated_note_how_to.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
const {
WebClient,
AccountStorageMode,
AccountId,
NoteType,
TransactionProver,
Note,
Expand Down Expand Up @@ -255,11 +254,9 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
console.log('Receiver:', receiver.id().toString());

const assets = new NoteAssets([new FungibleAsset(faucet.id(), BigInt(50))]);
const receiverAccountId = AccountId.fromHex(receiver.id().toString());

const p2idNote = Note.createP2IDNote(
sender.id(),
receiverAccountId,
receiver.id(),
assets,
NoteType.Public,
new Felt(BigInt(0)), // aux value
Expand Down
8 changes: 5 additions & 3 deletions web-client/lib/createMintConsume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function createMintConsume(): Promise<void> {
}

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

Expand Down Expand Up @@ -70,11 +70,13 @@ export async function createMintConsume(): Promise<void> {
console.log('Notes consumed.');

// 7. Send tokens to Bob
const bobAccountId = '0x599a54603f0cf9000000ed7a11e379';
const bobAccountId = Address.fromBech32(
'mtst1apve54rq8ux0jqqqqrkh5y0r0y8cwza6_qruqqypuyph',
).accountId();
console.log("Sending tokens to Bob's account...");
const sendTxRequest = client.newSendTransactionRequest(
alice.id(),
AccountId.fromHex(bobAccountId),
bobAccountId,
faucet.id(),
NoteType.Public,
BigInt(100),
Expand Down
8 changes: 4 additions & 4 deletions web-client/lib/foreignProcedureInvocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function foreignProcedureInvocation(): Promise<void> {
const {
AccountBuilder,
AccountComponent,
AccountId,
Address,
AccountType,
MidenArrays,
SecretKey,
Expand Down Expand Up @@ -93,9 +93,9 @@ export async function foreignProcedureInvocation(): Promise<void> {
console.log('\n[STEP 2] Building counter contract from public state');

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

// Import the counter contract
let counterContractAccount = await client.getAccount(counterContractId);
Expand Down
8 changes: 4 additions & 4 deletions web-client/lib/incrementCounterContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function incrementCounterContract(): Promise<void> {

// dynamic import → only in the browser, so WASM is loaded client‑side
const {
AccountId,
Address,
AccountBuilder,
AccountComponent,
AccountStorageMode,
Expand Down Expand Up @@ -72,9 +72,9 @@ export async function incrementCounterContract(): Promise<void> {

// Building the counter contract
// Counter contract account id on testnet
const counterContractId = AccountId.fromHex(
'0xe59d8cd3c9ff2a0055da0b83ed6432',
);
const counterContractId = Address.fromBech32(
'mtst1arjemrxne8lj5qz4mg9c8mtyxg954483',
).accountId();

// Reading the public state of the counter contract from testnet,
// and importing it into the WebClient
Expand Down
11 changes: 6 additions & 5 deletions web-client/lib/multiSendWithDelegatedProver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export async function multiSendWithDelegatedProver(): Promise<void> {
const {
WebClient,
AccountStorageMode,
AccountId,
Address,
NoteType,
TransactionProver,
NetworkId,
Note,
NoteAssets,
OutputNoteArray,
Expand Down Expand Up @@ -90,15 +91,15 @@ export async function multiSendWithDelegatedProver(): Promise<void> {

// ── build 3 P2ID notes (100 MID each) ─────────────────────────────────────────────
const recipientAddresses = [
'0xbf1db1694c83841000008cefd4fce0',
'0xee1a75244282c32000010a29bed5f4',
'0x67dc56bd0cbe629000006f36d81029',
'mtst1aqezqc90x7dkzypr9m5fmlpp85w6cl04',
'mtst1apjg2ul76wrkxyr5qlcnczaskypa4ljn',
'mtst1arpee6y9cm8t7ypn33pc8fzj6gkzz7kd',
];

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

const p2idNotes = recipientAddresses.map((addr) => {
const receiverAccountId = AccountId.fromHex(addr);
const receiverAccountId = Address.fromBech32(addr).accountId();
const note = Note.createP2IDNote(
alice.id(),
receiverAccountId,
Expand Down
5 changes: 1 addition & 4 deletions web-client/lib/unauthenticatedNoteTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
const {
WebClient,
AccountStorageMode,
AccountId,
NoteType,
TransactionProver,
Note,
Expand Down Expand Up @@ -112,11 +111,9 @@ export async function unauthenticatedNoteTransfer(): Promise<void> {
console.log('Receiver:', receiver.id().toString());

const assets = new NoteAssets([new FungibleAsset(faucet.id(), BigInt(50))]);
const receiverAccountId = AccountId.fromHex(receiver.id().toString());

const p2idNote = Note.createP2IDNote(
sender.id(),
receiverAccountId,
receiver.id(),
assets,
NoteType.Public,
new Felt(BigInt(0)), // aux value
Expand Down