This is to announce the first release of JSON dApp Environment (JDE), a tool for interacting with the Ergo blockchain.
The Ergo platform allows sophisticated dApps via smart contracts written in ErgoScript. Some notable examples are the Sigma-USD stable coin bank and ErgoMixer.
Interacting with such smart contracts requires a developer to write code in a language such as Scala (using the App-Kit framework) or Rust (using HDF / sigma-rust)
JSON dApp Environment (JDE) is another programming tool that can be used to interact with Ergo dApps. The differentiating feature of JDE is that its programming language is JSON.
JDE is designed with the following goals:
Enable tech-savvy users and developers to interact with existing (and future) Ergo dApps such as Sigma USD by programming the off-chain logic in a user-friendly way.
Provide a “sandbox” mode, where users can send arbitrary scripts for execution such that the server does not have to worry about malicious programs. This enables JDE service to be hosted remotely. An example is Kiosk-Web, where you can post arbitrary scripts (such as this, which gets the reserve coin rate) in “Tx Builder” and obtain results.
Goal #2 rules out many programming languages such as Java/Scala and Rust. In fact, this rules out all the so-called “Turing-complete” languages.
Let us take the use-case of purchasing, say, 10 Sigma-USD reserve coins as an example, which involves the following steps:
- Find the current oracle pool box and obtain the rate from register R4.
- Find the current bank box and obtain the relevant parameters (tokens in circulation and base reserves).
- Use the formulae to obtain the delta in base-reserves.
- Compute the details of the new bank box to be created (nano-Ergs, tokens, registers)
- Compute the details of the new receipt box to be created (nano-Ergs, tokens, registers)
- Make a transaction creation request to the Ergo node with above details.
All the above tasks can be programmed in JDE, as done in this script.
In general, JDE allows us to do the following:
- Find some boxes by address and/or box Id
- Extract values from those boxes (nanoErgs, registers and tokens), and define variables using those.
- Define constant values
- Perform computation using the constants and variables. JDE supports if-then-else construct for control flow. However, it does not support loops.
- Define outputs using the values computed
- Make a transaction creation request to the Ergo node
A compiled JAR is available in the release page. You can also generate the JAR yourself using the command
The following are the steps in using JDE.
- Understand the scripting language by looking at the sample scripts and the documentation.
- Ensure you have a fully synced Ergo node running.
- Write your script or edit existing script for the task at hand.
- Invoke JDE via CLI to generate a transaction creation request (aka unsigned transaction) along with some returned values.
Depending on your use-case, you will be using the output of Step 4 differently
- End users will use the it to send a transaction on the Ergo blockchain
- Wallet authors will append some of their own inputs/outputs before sending the transaction.
- dApp authors will use the returned values for further computation.
JDE also includes a web-service mode for the last two use-cases.
Please see the documentation for details.
- JDE is experimental. Please use with caution at your own risk. Always inspect the created transaction before sending.
- If you discover a bug, please make an issue and a PR if possible.
- If you find some feature missing, please make an issue.