@pwngh/economy-lab
    Preparing search index...

    Function debit

    • Builds a debit leg for one account. Pass the amount positive; it is stored positive. A debit lowers credit-normal accounts, such as a user's spendable balance, and raises debit-normal ones. Pairing a debit with a credit of the same amount yields stored amounts that sum to zero: a balanced posting.

      Parameters

      Returns Leg

      const price = toAmount('CREDIT', 70_000n);
      const legs = [
      debit(spendable('usr_buyer'), price), // stored +70_000: buyer's balance falls
      credit(earned('usr_seller'), price), // stored -70_000: seller's balance rises
      ]; // sums to zero, so the posting balances