vote-records
SP101YT8S9464KE0S0TQDGWV83V5H3A37DKEFYSJ0Source Code
;; Vote Records
(define-map votes {proposal-id: uint, voter: principal} {choice: uint})
(define-public (cast-vote (proposal-id uint) (choice uint))
(begin (map-set votes {proposal-id: proposal-id, voter: tx-sender} {choice: choice}) (ok true)))
(define-read-only (get-vote (proposal-id uint) (voter principal))
(map-get? votes {proposal-id: proposal-id, voter: voter}))
Functions (2)
| Function | Access | Args |
|---|---|---|
| cast-vote | public | proposal-id: uint, choice: uint |
| get-vote | read-only | proposal-id: uint, voter: principal |