Git Product home page Git Product logo

ergo-accordproject's Introduction

Ergo

Build Status CircleCI Coverage Status lerna npm version Netlify Status

About

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.

Try Ergo online

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.

Documentation

The most recent Ergo documentation is in the Ergo Language Guide.

Quickstart

Install Ergo

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

Compile a contract

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

Invoke a contract

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 Logo

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.

Learn More About Accord Project

Overview

Documentation

Contributing

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.

License

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.

ergo-accordproject's People

Contributors

dselman avatar irmerk avatar jbesq777 avatar jeromesimeon avatar kach avatar mttrbrts avatar peterhunn avatar petrgazarov 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.