A transaction is a transfer record: a sender transfers an amount of funds to a recipient. In this blockchain model, transactions wait pending before being collected into blocks. Once recorded, changing a transaction would change the block’s hash and invalidate the chain. section 1.6
The JavaScript Transaction object holds the transfer details and gains behavior through composition. HasHash, HasSignature, and HasValidation can add hashing, signing, and validation without making every behavior part of a transaction-specific inheritance hierarchy. The illustrated hash implementation is not cryptographically secure; cryptographic algorithms and key handling are left outside this model. section 3.4.1 section 3.5
A coffee payment
A digital-wallet payment for coffee creates a pending transaction. Introductory objects use email addresses for sender and recipient and a number for funds; an actual public ledger uses public keys rather than personal email addresses. The payment joins other transactions in a block after validation. section 1.6 section 3.5
Listing 3.20 Assigning mixins to a single instance of Transaction
Object.assign( new Transaction(...), #1 HasHash(['timestamp', 'sender', 'recipient', 'funds']), HasSignature(['sender', 'recipient', 'funds']), HasValidation() )
The listing attaches hashing, signing, and validation to one Transaction instance. It also shows which transaction properties participate in its hash and signature. section 3.5
Transaction need not be built only as a class. A prototype-linked object, a constructor function, or a class inside an immediately invoked function can model or package it. The IIFE version keeps its hash helper private while exposing Transaction through an application namespace. section 2.1 section 2.2.1 section 6.2.2













