Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

chainblocks example: basic

The minimum runnable chainblocks demo. Opens a ledger backed by a temp-directory FileStore, appends three blocks, reads them back, verifies the chain, and cleans up.

Run

npm install
npm start

Expected output:

--- chain ---
  seq=0 kind=ledger.genesis hash=sha256:...
  seq=1 kind=demo.event     hash=sha256:...
  seq=2 kind=demo.event     hash=sha256:...
  seq=3 kind=demo.event     hash=sha256:...

✓ Chain valid: 4 blocks, head sha256:...

What this demonstrates

  • openLedger({ store, name, writer }) — creating / opening a ledger
  • ledger.append({ kind, payload }) — appending typed entries
  • ledger.read() — async-iterating the chain
  • ledger.verify() — checking the integrity of every link
  • ledger.close() — releasing the store's resources