Money-Native Basics — Wallet, Price, Pay
Larz covers the thing that makes Larzscript different: wallet and price are real types that print as currency, and pay moves money between wallets as a single, safe statement - no library required.
wallet and pay
wallet holds real money, price names an amount, and pay AMOUNT from A to B transfers it - all in the language itself:
wallet alice = $50.00
wallet bob = $10.00
pay $20.00 from alice to bob
print("alice:", alice.balance)
print("bob:", bob.balance)Output
alice: $30.00 bob: $30.00
price and insufficient funds
pay checks the balance for you - try to pay more than a wallet holds and it throws, the same try/catch from last lesson:
wallet alice = $10.00
price ticket = $25.00
wallet venue = $0.00
try {
pay ticket from alice to venue
} catch e {
print("payment failed:", e["message"])
}
print("alice:", alice.balance)Output
payment failed: wallet 'alice' has insufficient funds (line 6) alice: $10.00
Every snippet on this page is run through the real larzscript interpreter, not hand-typed — what you see in the Output blocks is the actual output, for everything shown: a real transfer and a real rejected payment.
Related
LarzBank — A Real Bank, Built in LarzscriptSee wallet, pay and require composed into a real, open-source app.→Lesson 10: Paywalls & Subscriptionspaywall, subscribe, and require has - what's next after wallet, price, pay.→Lesson 8: Error Handling — try/catchtry/catch and require - the same error handling pay uses when a payment can't go through.→Lesson 3: Control Flowif/else, unless, while, for - where this course's first wallet and price example actually appeared.→What Is Larzscript?The full explainer on the money-native pitch - wallet, price, pay and require, from the start.→Learn Larzscript Cookbook29 short "how to X in Larzscript" recipes, including splitting a bill and holding funds in escrow.→