//! Register an asset, open two accounts, fund one from the boundary and pay the //! other. Needs no database and no feature, so it is the shortest whole program //! the ledger has. //! //! Run with: //! ```sh //! cargo run -p kuatia --example quickstart //! ``` use kuatia::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { let ledger = Ledger::new(InMemoryStore::new()); let usd = ledger.asset("USD", "$", 2).await?; let alice = AccountId::new(1); let bob = AccountId::new(2); let external = AccountId::new(99); ledger .create_account(Account::debit_must_not_exceed_credit(alice)) .await?; ledger .create_account(Account::debit_must_not_exceed_credit(bob)) .await?; ledger.create_account(Account::new(external)).await?; ledger .commit( TransferBuilder::new() .deposit(alice, ("100.00", &usd), external) .build()?, ) .await?; ledger .commit( TransferBuilder::new() .pay(alice, bob, ("25.00", &usd)) .build()?, ) .await?; println!("alice: {}", ledger.balance(&alice, &usd).await?); println!("bob: {}", ledger.balance(&bob, &usd).await?); Ok(()) }