This is the source code for the Ergo compiler. Ergo is the Accord Project language for Smart Legal Contracts.
The Ergo compiler is distributed as an npm package.
The Ergo compiler is written using the Coq proof assistant, with parsing and support code written in OCaml. It makes extensive use of the Q*cert compiler for code generation and type checking.
Both the Ergo language and its compiler are in early development phase. If you would like to build from source or to contribute, consult the DEVELOPERS file.
If you want to take a peek at Ergo without installing anything, check out the interactive REPL (read-eval-print-loop) for Ergo stand-alone, or the Accord Project Template Studio which illustrates Ergo in Accord Project templates.
The most recent Ergo documentation is in the Ergo Language Guide.
The easiest way to install Ergo is as a Node.js package. Once you have Node.js installed on your machine, you can get the Ergo compiler and command-line using the Node.js package manager by typing the following in a terminal:
$ npm install -g @accordproject/ergo-cli
This will install the compiler itself (ergoc
) and command-line tools (ergorun
and ergotop
) to create and invoke Ergo contracts. You can check that both have been installed and print the version number by typing the following in a terminal:
$ ergoc --version
$ ergorun --version
Then, to get command line help:
$ ergoc --help
$ ergorun --help
To compile your first Ergo contract to JavaScript:
$ ergoc ./examples/volumediscount/model.cto ./examples/volumediscount/logic.ergo
15:17:08 - info: Logging initialized. 2018-05-24T19:17:08.024Z
Processing file: ./examples/volumediscount/logic.ergo -- compiled to: ./examples/volumediscount/logic.js
By default, Ergo compiles to JavaScript for execution. You can inspect
the compiled JavaScript code in ./examples/volumediscount/logic.js
To compile and execute a contract by sending a request:
$ ergorun execute ./examples/volumediscount/model.cto ./examples/volumediscount/logic.ergo --contract ./examples/volumediscount/contract.json --request ./examples/volumediscount/request.json --state ./examples/volumediscount/state.json
06:40:01 - info:
{
"response": {
"discountRate": 2.8,
"$class": "org.accordproject.volumediscount.VolumeDiscountResponse"
},
"state": {
"$class": "org.accordproject.cicero.contract.AccordContractState",
"stateId": "1"
},
"emit": []
}
To compile and invoke a specific contract clause:
$ ergorun invoke ./examples/volumediscount/model.cto ./examples/volumediscount/logic.ergo --clauseName volumediscount --contract ./examples/volumediscount/contract.json --params ./examples/volumediscount/params.json --state ./examples/volumediscount/state.json
To compile and obtain the initial state for the contract:
$ ergorun init ./examples/volumediscount/model.cto ./examples/volumediscount/logic.ergo --contract ./examples/volumediscount/contract.json
06:40:29 - info:
Accord Project is an open source, non-profit, initiative working to transform contract management and contract automation by digitizing contracts. Accord Project operates under the umbrella of the Linux Foundation. The technical charter for the Accord Project can be found here.
- Accord Project
- Accord Project News
- Accord Project Blog
- Accord Project Slack
- Accord Project Technical Documentation
- Accord Project GitHub
- Getting Started with Accord Project
- Concepts and High-level Architecture
- How to use the Cicero Templating System
- How to Author Accord Project Templates
- Ergo Language Guide
The Accord Project technology is being developed as open source. All the software packages are being actively maintained on GitHub and we encourage organizations and individuals to contribute requirements, documentation, issues, new templates, and code.
Find out what’s coming on our blog.
Join the Accord Project Technology Working Group Slack channel to get involved!
For code contributions, read our CONTRIBUTING guide and information for DEVELOPERS.
Accord Project source code files are made available under the Apache License, Version 2.0. Accord Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0).
Copyright 2018-2019 Clause, Inc. All trademarks are the property of their respective owners. See LF Projects Trademark Policy.