Command Line Interface (CLI) for the Discovery Enigma Protocol developer testnet.
- Docker
- Docker Compose version 1.23.2 or higher. Please be aware that docker-compose introduced a bug in 1.23.0 (also present in 1.23.1) that appended random strings to container names that causes this network configuration to break.
- Git
- Node.js (version 10 or higher):
node
andnpm
- Rust:
rustup
,rustc
andcargo
discovery-cli
should be installed as a global package:
npm install -g @enigmampc/discovery-cli
For detailed instructions on how to install all the required dependencies, see the Installation instructions
$ discovery <command>
Commands:
discovery init Initialize Enigma Discovery development environment
discovery compile Compile Secret Contracts and Smart Contracts
discovery migrate Migrate Secret Contracts and Smart Contracts
discovery pull Pull the latest images for the containers in the network
discovery start Launch the Discovery Docker network
discovery stop Stop the network by stopping and removing all containers
discovery test Test Secret Contracts and Smart Contracts
Options:
--help Show help [boolean]
--version Show version number [boolean]
By default discovery-cli
will run a docker network with one worker. As of version 0.1.0
, if you want to have more than 1 worker node in the network, you can specify the environment variable NODES
to specify any number of nodes between 1 and 9. For example, to have 3 worker nodes, we would run:
NODES=3 discovery start
NOTE: In order for the network to operate robustly with more than one node, you have to edit your .env
file and change the following line (until we merge the changes in develop
to stable
in the docker images, at which point we will remove this notice)
DOCKER_TAG=develop
As of version 0.1.6
, the initialization of discovery init
can be automated to bypass user input on the terminal, by adding the following optional parameters:
discovery init -y --mode=hw|sw
where --mode
takes either hw
for hardware mode or sw
for software mode.
npm remove -g @enigmampc/discovery-cli
This repo provides an intuitive and user-friendly interface for dApp developers of secret contracts. It uses an analogous workflow and functionality to Truffle Suite. In fact, it builds on truffle packages and adapts the existing workflow to incorporate the functionality needed to compile, migrate and test secret contracts when having a running instance of the Enigma network.
For a detailed walkthrough guide on how to use this repo following a step-by-step example, refer to Getting Started with Enigma: An Intro to Secret Contracts.
What follows is more geared to advanced users that want to understand what happens under the hood:
-
discovery init
calls init() to initialize the folder structure and download the required files for any given project. Specifically:- Checks that the following list of dependecies exist in the system.
- Creates the following directory structure:
{your_project_folder} | ├-- build | ├-- enigma_contracts | └-- secret_contracts ├-- client ├-- migrations ├-- smart_contracts ├-- secret_contracts | └-- sample_contract └-- test
- Downloads the required files populating the above folder structure
- Asks the user whether to run in SGX Hardware or Software mode, and configures it accordingly
- Pulls the required docker images from enigmampc Docker Hub
-
discovery start
launches a dockerized version of the Discovery release of the Enigma network. This is the analogous command totruffle develop
organache-cli
. It is a more streamlined version of the discovery-docker-network configured through either one of the followingdocker-compose.yml
files: hardware version, software version. It exposes these two ports to the host:9545
(Ganache/Truffle) and3333
(Peer-to-Peer/Nginx proxy: the client entry point to the P2P network). Make sure that these two ports are free and available on the host. Having this command running is a prerequisite to runningdiscovery compile
,discovery migrate
anddiscovery test
. -
discovery stop
is the countercommand todiscovery start
to properly shut down the network. It is automatically called before starting the network to ensure that it starts from a blank state every time. -
discovery pull
pulls the latest docker images for the network. It's a shortcut fordocker-compose pull
-
discovery compile
calls deps/compile which in turn calls firsttruffle compile
and then executes Rustcargo
to compile all secret contract to their WebAssembly format. Puts both sets of contracts under their respective subfolders under thebuild
folder. -
discovery migrate
runs the migrations in themigrations
folder. Specifically, the 2_deploy_contracts.js file is a customized migration Javascript file that migrates both the Smart Contracts and Secret Contracts, following the Truffle specs. -
discovery test
run the tests in thetest
folder. Similarly as above, test_simple_addition.js is a customized Javascript test file that tests the samplesimple_addition
contract provided in this repo, following the Truffle specs.