Skip to content

Commit

Permalink
DAO example draft
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 17, 2024
1 parent 4e9d064 commit b0ab8d5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions example/dao.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{--
A smart contract written for SONIC runtime environment
SONIC stands for "State machine with ownership notation for indeterministic contracts"

A contract calls are URIs and URLS, which may have multiple forms (depending on the backend).
Here are the examples for the `castVote` call:
- Using SONARE runtime:
`contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
- Using a server providing SONIC API:
`contract://any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
- Using a server providing HTTP REST SONIC API:
`https://[email protected]/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
- Using a websocket connection:
`wws://[email protected]/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
- Using a Storm node server which contains SONARE runtime:
`storm://any.storm.node/contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
--}

data PartyId: U64
data Party: name String,
identity String

data VoteId: U64
data Vote: contra | pro
data Voting: title String,
text Text

lock Signer: [U8 ^ 32]
verify: preimage [U8 ^ 32]
hash preimage =?= $ !! invalidPreimage

@issuer(indsc.org)
contract DAO
var parties: { PartyId -> Party }

var votings: { VoteId -> Voting }
var votes: { VoteId -> { PartyId -> Vote } }

var signers: { Signer -> PartyId }

op setup: () -> parties, signers

op proposal: () -> @new @oneOf votings

op castVote: with @oneOf signers -> @setUnique(votes[with]) vote Vote, next @oneOf signers

0 comments on commit b0ab8d5

Please sign in to comment.