Fork me on GitHub

Template helloworld@0.0.5

This is the Hello World of Accord Protocol Templates. Executing the clause will simply echo back the text that occurs after the string `Hello` prepended to text that is passed in the request.

Download Archive

Model Dependencies

  • None

Sample

Name of the person to greet: "Fred Blogs".
Thank you!
                

README

Hello World

This is a smart legal clause that conforms to the Accord Protocol Template Specification, the protocol is managed by the open-source community of the Accord Project. The clause can be parsed and executed by the Cicero engine.

Description

This is the Hello World of Accord Protocol Templates. Executing the clause will simply echo back the text that occurs after the string Hello prepended to text that is passed in the request.

This clause contains:

Running this clause

On your own machine

  1. Download the Cicero template library

  2. Unzip the library with your favourite tool

  3. Then from the command-line, change the current directory to the folder containing this README.md file.

cd helloworld
  1. With the Cicero command-line tool:
cicero execute --template ./ --sample ./sample.txt --request ./request.json --state ./state.json

Note, all of the command-line flags (like --template) are optional.

Alternatively you can use the simpler command below if you want to use all of the default files.

cicero execute

You should see the following output in your terminal:

mattmbp:helloworld matt$ cicero execute
18:25:22 - info: Logging initialized. 2018-05-15T22:25:22.827Z
18:25:23 - info: Using current directory as template folder
18:25:23 - info: Loading a default sample.txt file.
18:25:23 - info: Loading a single default request.json file.
18:25:23 - info: Loading a default state.json file.
18:25:23 - info: {"clause":"helloworld@0.0.5-3119b65d48818b038883b0846738d34a61df5ac895093eb88003f07c96ee39c7","request":{"$class":"org.accordproject.helloworld.Request","input":"Accord Project"},"response":{"$class":"org.accordproject.helloworld.Response","output":"Hello Fred Blogs Accord Project","transactionId":"71013a48-dfd2-4e90-bbf4-c1cb744ac48c","timestamp":"2018-05-15T22:25:23.503Z"},"state":{"$class":"org.accordproject.common.ContractState","stateId":"org.accordproject.common.ContractState#1"},"emit":[]}

Sample Payload Data

Request, as in request.json

{
    "$class": "org.accordproject.helloworld.Request",
    "input": "Accord Project"
}

For the request above, you should see the following response:

{
    "$class":"org.accordproject.helloworld.Response",
    "output":"Hello Fred Blogs Accord Project",
    "transactionId":"1831144a-a329-4c4e-83f4-c50c238d561c",
    "timestamp":"2018-02-18T11:01:16.572Z"
}

Testing this clause

This clause comes with an automated test that ensures that it executes correctly under different conditions. To test the clause, complete the following steps.

You need npm and node to test a clause. You can download both from here.

This clause was tested with Node v8.9.3 and NPM v5.6.0

From the helloworld directory.

  1. Install all of the dependencies.
npm install
  1. Run the tests
npm test

If successful, you should see the following output

mattmbp:helloworld matt$ npm test

> helloworld@0.0.5 test /Users/matt/dev/accordproject/cicero-template-library/helloworld
> mocha

10:59:43 - info: Logging initialized. 2018-02-18T10:59:43.781Z


  Logic
    #Hello
      ✓ should produce correct result


  1 passing (217ms)