- None
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.
Name of the person to greet: "Fred Blogs". Thank you!
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.
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:
Unzip the library with your favourite tool
Then from the command-line, change the current directory to the folder containing this README.md file.
cd helloworld
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":[]}
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"
}
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.
npm install
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)