message-board
SP3CPTJFP3TQK00DV0B5SGE8R0N3Z40MWJ6QZD38YSource Code
;; message-board.clar
;; On-chain posts
(define-map posts uint { author: principal, content: (string-utf8 280) })
(define-data-var next-id uint u0)
(define-public (write-post (content (string-utf8 280)))
(let
(
(id (var-get next-id))
)
(asserts! (> (len content) u0) (err u105))
(map-set posts id { author: tx-sender, content: content })
(var-set next-id (+ id u1))
(ok id)
)
)
(define-read-only (get-post (id uint))
(ok (map-get? posts id))
)
Functions (2)
| Function | Access | Args |
|---|---|---|
| write-post | public | content: (string-utf8 280 |
| get-post | read-only | id: uint |