You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Text claims StorageMap::get() returns a single Felt, but let x: Word = self.balances.get(&key) compiles fine. get can return anything convertible from a Word.
deposit_asset.inner[0] directly accesses the raw field without validating the asset is fungible. Ideally, this would use a FungibleAsset wrapper or similar safe API, but these do not exist in miden.
Once fees are enabled, the pattern of mutating a storage slot for initial deployment will no longer be necessary. For testing, consider MockChainBuilder::add_account_from_builder with AccountState::Exists instead (though showing how to actually deploy the account is fine as-is, using the initialize call).
Contracts are excluded from the Cargo workspace, so there's no IDE support when opening the top-level project. Users must open individual contract directories.
Not sure if this can be fixed or where, but would be nice to.
Building contracts requires changing directories
Must cd contracts/bank-account && miden build --release, then cd ../.. for testing. miden should support building from the top-level directory.
The main reason to change this is to nudge users into the "correct" direction of using little-endian layouts (suffix, prefix) rather than big-endian (prefix, suffix). This will generally make their lives easier starting from 0.14 (where layouts in Rust and in MASM / on the stack are little-endian).
Content is mine, summarized and consolidated by AI.
General
In general, cool tutorial and a good choice for introducing users to Miden's architecture (accounts, notes, etc.).
Structural suggestion: each part should follow the pattern: implement something -> get an explanation -> test that specific part.
Tests that don't compile or are incorrect
Part 2 - MockChain test is misleading (account-components#try-it-verify-your-code)
Part 2 - Deposit-without-init test doesn't test what it claims (constants-constraints#try-it-verify-constraints-work)
deposit.Part 3 - Test does not compile (asset-management#try-it-verify-deposits-work)
Part 4 - Test does not compile (note-scripts#note-scripts-vs-account-components)
Part 6 - Test does not compile (transaction-scripts#try-it-verify-initialization-works)
no field 'dep' on type '&mut Account'.Outdated / incorrect information
"Compiler auto-assigns slot numbers" is outdated (project-setup#key-takeaways, account-components#step-1)
Named slots terminology (account-components)
StorageMap::getreturn type is wrong (account-components)StorageMap::get()returns a singleFelt, butlet x: Word = self.balances.get(&key)compiles fine.getcan return anything convertible from aWord.Note Storage terminology outdated for 0.14 (note-scripts#note-scripts-vs-account-components)
NoteInputswere renamed toNoteStorage, so notes now have storage. Suggest "persistent storage" (accounts) vs "ephemeral storage" (notes).Security concerns
Overflow/underflow in deposit and withdraw (asset-management#step-1, asset-management#step-2)
current_balance + deposit_amountshould check for overflow (e.g. againstFungibleAsset::MAX_AMOUNT).checked_sub(once it exists; see Comparisons and overflow/underflow onFelt#202) instead of a manual>=check.AssetAmountwrapper type (see protocol#2532) would handle this safely viaAdd/Subimpls.No validation that asset is fungible (asset-management)
deposit_asset.inner[0]directly accesses the raw field without validating the asset is fungible. Ideally, this would use aFungibleAssetwrapper or similar safe API, but these do not exist inmiden.Withdraw note passes sender explicitly - security risk (output-notes)
bank_account::withdraw. The account should instead callactive_note::get_senderitself.withdraw, draining their balance into notes.Tutorial structure / ordering issues
require_initializedintroduced too early (account-components)require_initializedis unused. Consider moving it to the part where it's actually used.Part 5 explains cross-component calls after Part 4 already uses them (cross-component-calls)
bank_account::deposit, but the explanation of how that works comes in Part 5.balancesStorageMap already present from Part 0 (account-components#step-1)StorageMapfor balance tracking, but it already exists from Part 0.Account deployment pattern will need rethinking (transaction-scripts#account-deployment-pattern)
MockChainBuilder::add_account_from_builderwithAccountState::Existsinstead (though showing how to actually deploy the account is fine as-is, using theinitializecall).Developer experience / workflow issues
No IDE support for contracts (project-setup)
Building contracts requires changing directories
cd contracts/bank-account && miden build --release, thencd ../..for testing.midenshould support building from the top-level directory.Cargo.toml updates are no-ops (transaction-scripts#step-3, output-notes#update-workspace)
Cargo.toml, but the contracts are excluded anyway, making these steps pointless.Part 0 Cargo.toml already up to date (project-setup#step-4)
Cargo.tomlalready looks like the target state; the step is redundant.Nits
Typo: "from outside" -> "from the outside" (account-components#public-vs-private-methods)
Storage map key layout should use little-endian (account-components, asset-management#step-1)
[prefix, suffix, 0, 0]but the canonical layout is[0, 0, suffix, prefix](little-endian). Nudge users toward correct layout for 0.14 compatibility.Part 5 bindings visualization unclear (cross-component-calls#building-on-part-4)
use crate::bindings::miden::bank_account::bank_account;has an unclear target.cc @Keinberger