All money and stocks are represented as tokens, and all stock sales are represented as blockchain transactions. All transactions are mediated by a smart contract, which takes in money tokens from the buyer and stock tokens from the seller, runs some checks, then swaps them.

