Skip to content

Latest commit

 

History

History
82 lines (51 loc) · 2.09 KB

README.md

File metadata and controls

82 lines (51 loc) · 2.09 KB

js2rho - JavaScript to Rholang

work in progress by Dan Connolly

In the Agoric architecture, a JavaScript dialect is used to write secure smart contracts using object capabilities. In the RChain architecture, Rholang is used likewise.

Section 3. INTERPRETING CAPABILITIES of Policies as Types sketches compiling JavaScript to RHO-calculus.

js2rho is an exploration into the feasibility of taking smart contracts written in JavaScript and compiling them to Rholang for interoperability with RChain.

Getting Started with js2rho.js (current nodejs)

note: tested with nodejs 13.12.0

git clone https://github.com/rchain-community/js2rho.git
cd js2rho
npm install
npm test

js2rho.js is based on estree / esprima.

Low-bandwidth install (no dev dependencies)

To install ~350K of essential dependencies without ~50M of typescript tooling, use:

npm install --only=prod

Getting started with tinyses.Parser

For the Jessie dialect, we have a parser and abstract syntax tree (AST) as a scala sum-of-products type.

sbt console
scala> tinyses.TestSimpleParser.main(Array())
/home/connolly/projects/tinyses2rho
trying statement at CharSequenceReader('[', ...)
trying block at CharSequenceReader('[', ...)
block --> [1.1] failure: '{' expected but '[' found
...

We're evaluating escalima for await syntax.

Cross-chain iteroperability: IBC?

Another RChain interoperability approach is to use waterken / Q style message passing between TinySES and RChain nodes.

Static Types

Scala should provide a good platform to explore the hypothesis that Jessie can be easily statically typed.

Fuzz testing Jessie

A "fuzzer" to generate arbitrary Jessie programs should be straightforward using property testing libraries.

Background

See also bounty issue 427.