-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e9d064
commit b0ab8d5
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |