comments-v1
SP203NZ4Q7C7XRQCY0C38091CPAXYW95JDB7G6QA2Source Code
;; Comments
(define-map comments uint {author: principal, content: (string-ascii 300), target-id: uint})
(define-data-var comment-id uint u0)
(define-public (post-comment (content (string-ascii 300)) (target-id uint))
(let ((id (var-get comment-id)))
(map-set comments id {author: tx-sender, content: content, target-id: target-id})
(var-set comment-id (+ id u1))
(ok id)))
(define-read-only (get-comment (id uint))
(map-get? comments id))
Functions (2)
| Function | Access | Args |
|---|---|---|
| post-comment | public | content: (string-ascii 300 |
| get-comment | read-only | id: uint |