dasy icon indicating copy to clipboard operation
dasy copied to clipboard

a lisp built on top of vyper

#+title: Dasy #+EXPORT_FILE_NAME: index #+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup

#+begin_quote The Dasypeltis, gansi, is considered an egg-eating snake. Their diet consists of all forms of eggs considering they have no teeth in which to eat living prey with. #+end_quote

Dasy is an experimental smart contract programming language in the lisp family. It is implemented by compiling to Vyper and benefits from the extensive optimizations and excellent performance of Vyper.

Learn more in the [[file:docs.org][documentation]]

  • Examples [[https://dasy-by-example.github.io][More examples at Dasy By Example]] #+begin_src clojure (defvars :public myMap (hash-map :address :uint256) nums (dyn-arr :uint256 3) owner :address)

(defn init [] :external (set self/owner msg/sender) (set-at self/myMap msg/sender 10) (do ;; wrap statements in do (.append self/nums 11)))

(defn getOwnerNum [] :uint256 :external (get-at self/myMap self/owner)) #+end_src

  • Installation ** For use as a library #+begin_src bash pip install git+https://github.com/dasylang/dasy.git #+end_src ** For use as an executable via =pipx= #+begin_src bash pipx install git+https://github.com/dasylang/dasy.git #+end_src ** [[https://github.com/dasylang/ape-dasy][Ape Plugin]] #+begin_src bash pip install ape-dasy #+end_src ** [[https://github.com/dasylang/foundry-dasy][Foundry plugin]]
  • Motivation ** Macros There are a lot of opportunities for macros in smart contracts. They can also be used to prototype features before implementing them at a lower level in the vyper compiler.

macros are written in Hy, a pythonic lisp. They allow us to transform our code at compile time, allowing the developer to tailor the language itself to their needs.

=cond= and =condp= are examples of useful macros that help make your code shorter, yet easier to understand. #+begin_src clojure (defn useIf [:uint256 x] :uint256 :external (if (<= x 10) (return 1) (if (<= x 20) (return 2) (return 3))))

;; cond macro helps prevent deeply nested ifs (defn useCond [:uint256 x] :uint256 :external (cond (<= x 10) (return 1) (<= x 20) (return 2) :else (return 3)))

;; condp saves you from repeating the same operation (defn useCondp [:uint256 x] :uint256 :external (condp <= x 10 (return 1) 20 (return 2) :else (return 3))) #+end_src

** For fun