Skip to content

DemoScenariesEng_GettingStarted_PrivEth

Puzanira edited this page Feb 24, 2020 · 7 revisions

Getting Started scenario

This scenario is executed in the Private Ethereum (PrivEth) cluster.

Here you will see how Kekker creates a deal and distributes it across the nodes. Then you can try switching the deal status from one to another and test how Kekker prevents unauthorized transitions.

We already prepared a smart contract (FirstDeal) for you. It has a pre-installed status map for simplicity. Later you can try to set a status map on your own.

The scenario involves consistent execution of the following steps:

  1. A deal with DocNumber, DocDate, DocSumma attributes is created on the PrivEth-1 node
  2. Switching the deal status to Status1 on the PrivEth-1 node
  3. Make sure that the deal arrives at the PrivEth-1 and PrivEth-2 nodes, and that there is no deal at the PrivEth-3 node
  4. On the PrivEth-2 node, the deal status is switched to Status2, the PaymentDate attribute is added and the DocSumma attribute is changed
  5. Ensure that changes in the deal are made to PrivEth-1 and PrivEth-2 nodes.
  6. On the PrivEth-1 node, the status of the deal is switched to Closed
  7. Ensure that changes in the deal are made to PrivEth-1 and PrivEth-2 nodes, and that there is still no deal at PrivEth-3 node

ATTENTION! In the examples of calls, the ID of the trial deal is substituted - You should substitute the ID obtained when creating a deal at step 1.

ATTENTION! In queries in the CHANNEL header, you must use the personal identifier you received during registration. This will not interfere with simultaneous work of several users, and will facilitate the work of the Technical Support Service if you have any questions. Demo personal identifier is used in request examples.

1. Deal creation

The creation of the deal consists of the following steps:

  • Getting the deal identifier
  • Checking for the absence of a deal at other nodes (this step is purely a demo step, in order to make sure that the deal is nowhere "in advance" and its replication will occur only after creation).
  • Deal creation itself

Getting a deal identifier

GET method call /api/uid is used. The method returns GUID, which can be used once to create a deal.

Example call Example answer
curl -X GET "http://democlient1.kekker.com/api/uid" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" "840a0671-4afa-4f87-9f3f-12c252bXXXXX"

Checking for no deal

GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier, for example, obtained at the previous step

Example call (the difference is in the node URL) Example answer
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" { "ErrorMessage": "Deal not found" }
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"

Deal creation

POST method call /api/deals/ is used. The json-specification of the deal is specified as the request data, in our case:

{
  "dealUid": "[UID]",
  "kind": "FirstDeal",
  "parties": [  {  "key": "CLIENT1", "role": "Role1" },
                {  "key": "ClIENT2", "role": "Role2" }
             ],
  "parameters": [  { "key": "DocNumber",  "value": "1"          },
                   { "key": "DocDate",    "value": "11.02.2020" },
                   { "key": "DocSumma",   "value": "10000"      }
                ],
  "parentDealUid": null
}
Example call Example answer
curl -X POST "http://democlient1.kekker.com/api/deals" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" -d "{ \"dealUid\": \"840a0671-4afa-4f87-9f3f-12c252bXXXXX\", \"kind\": \"FirstDeal\", \"parties\": [ { \"key\": \"CLIENT1\", \"role\": \"Role1\" } ,{ \"key\": \"CLIENT2\", \"role\": \"Role2\" } ], \"parameters\": [ { \"key\": \"DocNumber\", \"value\": \"1\" },{ \"key\": \"DocDate\", \"value\": \"11.02.2020\" },{ \"key\": \"DocSumma\", \"value\": \"10000\" } ], \"parentDealUid\": null}" Empty if no errors

2. Switching the deal status to Status1 on the PrivEth-1 node

POST method call /api/deals/setstatus is used. The json-specification of the deal is specified as the request data, in our case:

{
  "dealUid": "[UID]",
  "status": "Status1__",
  "remark": "Status changed to Status1 by CLIENT1",
  "parameters": []
}
Example call Example answer
curl -X POST "http://democlient1.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252bXXXXX\", \"status\":\"Status1__\", \"remark\":\"Status changed to Status1 by CLIENT1\", \"parameters\": []}" Empty if no errors

3. Make sure that the deal arrives at the PrivEth-1 and PrivEth-2 nodes, and that there is no deal at the PrivEth-3 node

GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier

It is better to take a pause of 2-3 minutes after step [2] before making requests.

Example call (the difference is in the node URL) Example answer (special interest on the fields "kind", "status" and "parameters" collection)
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" On the PrivEth-1 and PrivEth-2 nodes the answer is
{
  "uid": "840a0671-4afa-4f87-9f3f-12c252bXXXXX",
  "kind": "FirstDeal",
  "status": "Status1__",
  "remark": "Status changed to Status1 by CLIENT1",
  "parameters": [{ "key": "DocNumber", "value": "1" },
                 { "key": "DocDate", "value": "11.02.2020" },
                 { "key": "DocSumma", "value": "10000" }],
  "parties": [{ "key": "CLIENT1", "role": "Role1" },
              { "key": "CLIENT2", "role": "Role2" }],
  "files": [],
  "history": [{"status": "Status1__",
               "party": { "key": "CLIENT1", "role": "Role1" },
               "remark": "Status changed to Status1 by CLIENT1",
               "version": 2 }],
  "statusMap": []
}
    
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" On the PrivEth-3 node the answer should be {"ErrorMessage":"Deal not found"}

4. On the PrivEth-2 node, the deal status is switched to Status2, the PaymentDate attribute is added and the DocSumma attribute is changed

POST method call /api/deals/setstatus is used. The json-specification of the new deal status is specified as the request data, in our case:

{
  "dealUid": "[UID]",
  "status": "Status2__",
  "remark": "Status changed to Status2 by CLIENT2",
  "parameters": [  { "key": "DocSumma",    "value": "20022"       },
                   { "key": "PaymentDate", "value": "15.03.2020"  }
                ],
}
Example call Example answer
curl -X POST "http://democlient2.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252bXXXXX\", \"status\":\"Status2__\", \"remark\":\"Status changed to Status2 by CLIENT2\", \"parameters\": [{\"key\":\"DocSumma\",\"value\":"20022"}, {\"key\":\"PaymentDate\",\"value\":\"15.03.2020\"}]}" Empty if no errors

5. Ensure that changes in the deal are made to PrivEth-1 and PrivEth-2 nodes.

GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier

It is better to take a pause of 1-2 minutes after step [4] before making requests.

Example call (the difference is in the node URL) Example answer (special interest on the fields "status", "history" and "parameters" collections)
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"
{
  "uid": "840a0671-4afa-4f87-9f3f-12c252bXXXXX",
  "kind": "FirstDeal",
  "status": "Status2__",
  "remark": "Status changed to Status2 by CLIENT2",
  "parameters": [{ "key": "DocNumber", "value": "1" },
                 { "key": "DocDate", "value": "11.02.2020" },
                 { "key": "DocSumma", "value": "20022" },
                 { "key": "PaymentDate", "value": "15.03.2020" }],
  "parties": [{ "key": "CLIENT1", "role": "Role1" },
              { "key": "CLIENT2", "role": "Role2" }],
  "files": [],
  "history": [{ "status": "Status1__",
                "party": { "key": "CLIENT1", "role": "Role1" },
                "remark": "Status changed to Status1 by CLIENT1",
                "version": 2 },
              { "status": "Status2__",
                "party": { "key": "CLIENT2", "role": "Role2" },
                "remark": "Status changed to Status2 by CLIENT2",
                "version": 3 }],
  "statusMap": []
}
    
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"

6. On the PrivEth-1 node, the status of the deal is switched to Closed

POST method call /api/deals/setstatus is used. The json-specification of the new deal status is specified as the request data, in our case:

{
  "dealUid": "[UID]",
  "status": "Closed___",
  "remark": "Deal closed by CLIENT1",
  "parameters": []
}
Example call Example answer
curl -X POST "http://democlient1.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252bXXXXX\", \"status\":\"Closed___\", \"remark\":\"Deal closed by CLIENT1\", \"parameters\": []}" Empty if no errors

7. Ensure that changes in the deal are made to PrivEth-1 and PrivEth-2 nodes, and that there is still no deal at PrivEth-3 node

GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier

It is better to take a pause of 1-2 minutes after step [6] before making requests.

Example call (the difference is in the node URL) Example answer (special interest on the fields "status" and "history" collection)
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" On the PrivEth-1, PrivEth-2 the answer is
{
  "uid": "840a0671-4afa-4f87-9f3f-12c252XXXXX",
  "kind": "FirstDeal",
  "status": "Closed___",
  "remark": "Deal closed by CLIENT1",
  "parameters": [{ "key": "DocNumber", "value": "1" },
                 { "key": "DocDate", "value": "11.02.2020" },
                 { "key": "DocSumma", "value": "20022" },
                 { "key": "PaymentDate", "value": "15.03.2020" }],
  "parties": [{ "key": "CLIENT1", "role": "Role1" },
              { "key": "CLIENT2", "role": "Role2" }],
  "files": [],
  "history": [{ "status": "Status1__",
                "party": { "key": "CLIENT1", "role": "Role1" },
                "remark": "Status changed to Status1 by CLIENT1",
                "version": 2  },
              { "status": "Status2__", 
                "party": { "key": "CLIENT2", "role": "Role2" },
                "remark": "Status changed to Status2 by CLIENT2",
                "version": 3 },
              { "status": "Closed___",
                "party": { "key": "CLIENT1", "role": "Role1" },
                "remark": "Deal closed by CLIENT1",
                "version": 4 }],
  "statusMap": []
}
    
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo"
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252bXXXXX" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZXXXXX" -H "channel: Demo" On the PrivEth-3 node the answer should be { "ErrorMessage": "Deal not found" }

Clone this wiki locally