Skip to main content
Version: 0.15 (unstable)

Standard Notes

Standard notes are prebuilt note scripts from miden-standards. They cover the common asset flows builders need before writing custom note scripts.

Use the Rust APIs to construct standard notes in client or transaction-building code. The scripts themselves are MASM modules, so direct MASM authors can inspect or import the same standard scripts when they need exact procedure behavior.

Which note should I use?

NoteUse it whenRust typeMASM module
P2IDYou are sending assets to a specific account ID.P2idNotemiden::standards::notes::p2id
P2IDEYou are sending to a specific account ID with a timelock and/or reclaim path.P2ideNotemiden::standards::notes::p2ide
SWAPYou are offering one asset and requiring a specific asset in return.SwapNotemiden::standards::notes::swap
PSWAPYou need a partially fillable swap note.PswapNotemiden::standards::notes::pswap
MINTA faucet is minting fungible tokens into a note.MintNotemiden::standards::notes::mint
BURNA faucet is burning fungible tokens returned through a note.BurnNotemiden::standards::notes::burn

For the note model itself, start with What are Notes?. This page focuses on how the standards fit into builder workflows.

Create a public P2ID note
use miden_protocol::Word;
use miden_protocol::account::{AccountId, AccountIdVersion, AccountStorageMode, AccountType};
use miden_protocol::asset::{Asset, FungibleAsset};
use miden_protocol::crypto::rand::RandomCoin;
use miden_protocol::note::{NoteAttachments, NoteType};
use miden_standards::note::P2idNote;

fn dummy_account(byte: u8, account_type: AccountType) -> AccountId {
let mut bytes = [0; 15];
bytes[0] = byte;
AccountId::dummy(
bytes,
AccountIdVersion::Version1,
account_type,
AccountStorageMode::Public,
)
}

fn create_p2id_note() -> Result<(), Box<dyn std::error::Error>> {
let sender = dummy_account(1, AccountType::RegularAccountImmutableCode);
let target = dummy_account(2, AccountType::RegularAccountImmutableCode);
let faucet_id = dummy_account(3, AccountType::FungibleFaucet);
let asset: Asset = FungibleAsset::new(faucet_id, 100)?.into();
let mut rng = RandomCoin::new(Word::from([1, 2, 3, 4u32]));

let note = P2idNote::create(
sender,
target,
vec![asset],
NoteType::Public,
NoteAttachments::default(),
&mut rng,
)?;

assert_eq!(note.metadata().sender(), sender);
Ok(())
}

PSWAP is part of the current unstable standards surface, but it is not available in the v0.14 standards snapshot. Use the v0.14 versioned docs if you are building against the v0.14 crates.

Account requirements

Standard notes assume the consuming account exposes the procedures the note script calls.

NoteConsuming account needs
P2ID / P2IDEA wallet-compatible receive procedure, usually from BasicWallet.
SWAP / PSWAPWallet-compatible receive and asset-to-note procedures.
MINTA compatible faucet/account flow for mint authorization and recipient delivery.
BURNA compatible faucet burn procedure.

If you write a custom wallet or faucet component, test it against the standard notes you expect it to consume.

Attachments and execution hints

Standard notes can use attachments and execution hints to help clients and indexers route notes and decide when a note might be consumable.

HelperUse it for
StandardNoteAttachmentStandard attachment schemes for note metadata.
NetworkAccountTargetAttaching network-account targeting data to notes.
AccountTargetNetworkNoteWrapping notes known to target network accounts.
NetworkNoteExtConvenience helpers for network-targeted notes.
NoteExecutionHintEncoding when clients should attempt note execution.

Execution hints do not replace note-script checks. The note script still enforces consumption rules during transaction execution.

Rust and MASM entry points

Rust constructors are the usual way to create standard notes in client-side code. Direct MASM authors should use the standard note modules as the source of truth for stack effects and script behavior.

The Rust types live under miden_standards::note. The MASM scripts live under miden::standards::notes::*.