Coder Social home page Coder Social logo

evm-clojure's Introduction

An EVM Low Level Lisp compiler, in Clojure.

Start REPL:

lein repl

Then load the module

(require 'clll.core :reload)

Compile a minimal program:

(clll.core/genbinary '[
    (mstore 0 0xaabbcc)
    (return 0 32)
])

; => "62aabbcc60005260206000f3"

Run with EVM CLI:

evm  --statdump --code 62aabbcc60005260206000f3 --input aabb run
evm execution time: 119.82µs
heap objects:       10424
allocations:        1516432
total allocations:  1516432
GC calls:           0
Gas used:           18

0x0000000000000000000000000000000000000000000000000000000000aabbcc

A Minimal Deployable Contract

(def code '[
  (codecopy 0x0 (blockoffset :contract) (blocksize :contract))
  (return 0x0 (blocksize :contract))

  (block :contract
    (mstore 0 0xaabbcc)
    (return 0 32))
])

Compile expression to instructions:

=> (clll.core/genassembly code)
((:blocksize :contract) (:blockoffset :contract) 0 :codecopy (:blocksize :contract) 0 :return (:block :contract 11189196 0 :mstore 32 0 :return))

Convert instructions to bytecode:

=> (clll.core/genbinary code)
"600c600c600039600c6000f35b62aabbcc60005260206000f3"

evm-clojure's People

Contributors

hayeah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.