// Example 9: Money - Accounts, Assets, and Transactions print("=== Money Example ===\n"); // Get a context to work with print("1. Getting context..."); let ctx = get_context(["alice", "bob", "charlie"]); print(" ✓ Context created: " + ctx.context_id()); // Create an asset (e.g., a token) print("\n2. Creating a digital asset..."); let tft_asset = new_asset() .address("TFT_ASSET_001") .asset_type("utility_token") .issuer(1) .supply(1000000.0); print(" ✓ Created TFT asset"); print(" Address: " + tft_asset.get_address()); print(" Type: " + tft_asset.get_asset_type()); print(" Supply: " + tft_asset.get_supply()); // Save the asset print("\n3. Saving asset to context..."); let asset_id = ctx.save(tft_asset); print(" ✓ Saved asset with ID: " + asset_id); // Create accounts for users print("\n4. Creating user accounts..."); let alice_account = new_account() .owner_id(100) .address("ALICE_TFT_ACCOUNT") .balance(10000.0) .currency("TFT") .assetid(1); print(" ✓ Created Alice's account"); print(" Owner ID: " + alice_account.get_owner_id()); print(" Address: " + alice_account.get_address()); print(" Balance: " + alice_account.get_balance() + " " + alice_account.get_currency()); let bob_account = new_account() .owner_id(101) .address("BOB_TFT_ACCOUNT") .balance(5000.0) .currency("TFT") .assetid(1); print(" ✓ Created Bob's account"); print(" Owner ID: " + bob_account.get_owner_id()); print(" Address: " + bob_account.get_address()); print(" Balance: " + bob_account.get_balance() + " " + bob_account.get_currency()); // Save accounts print("\n5. Saving accounts to context..."); let alice_account_id = ctx.save(alice_account); print(" ✓ Saved Alice's account with ID: " + alice_account_id); let bob_account_id = ctx.save(bob_account); print(" ✓ Saved Bob's account with ID: " + bob_account_id); // Create a transaction print("\n6. Creating a transaction..."); let transaction = new_transaction() .source(100) .destination(101) .amount(500.0) .assetid(1); print(" ✓ Created transaction"); print(" From: " + transaction.get_source()); print(" To: " + transaction.get_destination()); print(" Amount: " + transaction.get_amount()); print(" Asset ID: " + transaction.get_assetid()); // Save transaction print("\n7. Saving transaction to context..."); let tx_id = ctx.save(transaction); print(" ✓ Saved transaction with ID: " + tx_id); // Create a multi-currency account print("\n8. Creating multi-currency account..."); let charlie_usd_account = new_account() .owner_id(102) .address("CHARLIE_USD_ACCOUNT") .balance(25000.0) .currency("USD") .assetid(2); print(" ✓ Created Charlie's USD account"); print(" Balance: " + charlie_usd_account.get_balance() + " " + charlie_usd_account.get_currency()); let charlie_id = ctx.save(charlie_usd_account); print(" ✓ Saved Charlie's account with ID: " + charlie_id); // List all accounts print("\n9. Listing all accounts in context..."); let account_ids = ctx.list("accounts"); print(" ✓ Found " + account_ids.len() + " accounts"); // List all assets print("\n10. Listing all assets in context..."); let asset_ids = ctx.list("assets"); print(" ✓ Found " + asset_ids.len() + " assets"); // List all transactions print("\n11. Listing all transactions in context..."); let tx_ids = ctx.list("transactions"); print(" ✓ Found " + tx_ids.len() + " transactions"); print("\n=== Money Example Complete ==="); print("Summary:"); print(" - Created 1 asset (TFT)"); print(" - Created 3 accounts (Alice TFT, Bob TFT, Charlie USD)"); print(" - Created 1 transaction (Alice → Bob: 500 TFT)");