...by Daniel Szego
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Thursday, January 12, 2017

Creating a simple order process on the Ethereum Blockchain

Let we create a simple order workflow on the Ethereum Blockchain. The workflow imitates an order request, containing information on which material was ordered, how many items and on the order price. We define two smart contracts, on the one hand similarly to our previous example we define an ApprovementActivity. The activity realizes the usual Approve, Reject and Delegate functionalities as in our previous example, However the functionalities are extended with a callback function, that informs the original workflow as soon as the internal state has been changed. Additionally, there is an event that is raised to the client side, as soon as a new Approval set.

Code of ApprovementActivity is the following:

Workflow itself is realized by another smart contract, called OrderWF. The workflow is pretty simple, it is initiated with the necessary input parameters, sets the initial state and creates an activity to be approved. Communication regarding the state changed is realized by the callback function. As a second possible communication way a reference for the original workflow has been given over to the Activity, however this functionality is currently not used.

Certainly the process just an over simplified prototype version.  For a real scale solution additional functionalities should be built up, like reading the order details from the ApprovementActivity smart contract, working rather with groups than with individual addresses, fine tuning permissions and so on...