Skip to content

Commit 183b9b6

Browse files
stackdumpclaude
andcommitted
Use voting example for .btw DSL section in README
Replace ERC-20 transfer example with a Poll schema showing castVote with nullifier and tally arcs — matches the project focus and is more relatable for newcomers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 132da06 commit 183b9b6

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,34 +141,38 @@ public/ Frontend JS/CSS/HTML (go:embed)
141141

142142
## .btw schema language
143143

144+
Models can also be written as `.btw` files — a compact DSL for defining Petri net state machines. Here's a simplified poll:
145+
144146
```
145-
schema ERC20 {
146-
version "1.0.0"
147+
schema Poll {
148+
version "1.0"
147149
148-
register ASSETS.AVAILABLE map[address]uint256 observable
149-
register ASSETS.TOTAL_SUPPLY uint256 observable
150+
register voterRegistry map[uint256]uint256 observable
151+
register nullifiers map[uint256]bool observable
152+
register tallies map[uint256]uint256 observable
150153
151-
event TransferBalanceChange {
152-
from: address indexed
153-
to: address indexed
154-
amount: uint256
154+
event VoteCast {
155+
nullifier: uint256 indexed
156+
choice: uint256
155157
}
156158
157-
fn(transfer) {
158-
var from address
159-
var to address
160-
var amount amount
159+
fn(castVote) {
160+
var nullifier uint256
161+
var choice uint256
162+
var weight uint256
161163
162-
require(ASSETS.AVAILABLE[from] >= amount && amount > 0)
163-
@event TransferBalanceChange
164+
require(nullifiers[nullifier] == false)
165+
@event VoteCast
164166
165-
ASSETS.AVAILABLE[from] -|amount|> transfer
166-
transfer -|amount|> ASSETS.AVAILABLE[to]
167+
castVote -|weight|> tallies
168+
castVote -|weight|> nullifiers
167169
}
168170
}
169171
```
170172

171-
Compile to JSON: `bitwrap -compile token.btw`
173+
The arrows (`-|weight|>`) are arcs — they describe how tokens flow through the net. `castVote` increments the tally for the chosen option and marks the nullifier as used, all in one atomic transition.
174+
175+
Compile to JSON: `bitwrap -compile poll.btw`
172176

173177
## License
174178

0 commit comments

Comments
 (0)