Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (15 sloc) 756 Bytes
;; ========================================================
;; 2.4-pay
;; ========================================================
(defun pay (from to amount)
(with-read accounts-table from { "balance":= from-bal }
;; call enforce-user-auth from auth with parameter from
;; --------------------END OF CHALLENGE -------------------
(with-read accounts-table to { "balance":= to-bal }
(enforce (> amount 0.0) "Negative Transaction Amount")
(enforce (>= from-bal amount) "Insufficient Funds")
(update accounts-table from
{ "balance": (- from-bal amount) })
(update accounts-table to
{ "balance": (+ to-bal amount) })
(format "{} paid {} {}" [from to amount]))))
You can’t perform that action at this time.