In this series we describe our experiences trying to implement a "smart contract" solution on an Ethereum network.

We have all heard of Blockchain, the secure distributed ledger on which all cryptocurrencies rely. Many will also be aware of “Smart Contracts”, the extension to Blockchain implemented by the Ethereum network, and by now we have all heard how these new technologies and developments are predicted to change the face of business over the coming years.

Yet when the hype and marketing are stripped away how should a typical developer get to grips with Blockchain, what do they need to know, and what tools and platforms are available?

Recently a colleague and I were asked to build a blockchain demo to simulate a simple supply chain, such as coffee production, you know the sort of thing, a coffee farmer, an importer, a producer and supplier and finally a retailer. Each participant would have access to the private blockchain network on which we would develop a smart contract implementing the above roles, allowing farmers to offer priced goods and importers to bid for them, and so on. 

Once a bid has been accepted by the farmer the transaction between themselves and importer would be written to the encrypted imputable digital ledger and ownership past to the importer, everything “sorted”, as they say. When the coffee beans were in the hands of the importer they in turn would be able to offer the product to producers or roasters, and so on up the supply chain. All this would be available via the Web with a friendly UI allowing invited users to follow and monitor each of the transactions and view a historical record. Well that was the idea, implement traceability and trust at each stage of the process.

So we set about it using Solidity and the online Remix editor, we built and tested our smart contract whilst at the same time sought a solution to the hosting problem. Being familiar with Azure we decided to host our private blockchain there employing one of the built in Blockchain templates, specifically the Ethereum POA (Proof of Authority). Setting this up was relatively straightforward, merely a question of following a simple templated wizard; things were looking good.

Having tested our smart contract locally we installed MetaMask, a free plugin that allows Dapps (decentralized apps) to run in a browser and provides a secure identity vault. We could now log in and simulate the multiple personas implemented in the smart contract. Although MetaMask was not without difficulties (bugs?), we were getting somewhere despite the long address names we were required to remember.

Next we build a simple Angular Web app, uploaded it to an Azure Web service host, connected and proved it worked. This was to be our front end which would connect to our private blockchain instance.  Next step was to upload the smart contract, and that’s when our luck ran out. No matter what we tried we were unable to get our contract, or indeed any contract, to install on a node of our private Ethereum network. Hours, indeed days spent SSH'ing'into the node and playing around with Geth (Go Ethereum configuration tool) proved fruitless, as were our searches on web for a solution.

We began to concede that ignorance or plain lack of experience had finally caught up with us, and realised that Blockchain development has its pitfalls; amongst them, lack of information. Much of our time was spent trying to understand and debug the uploading of our smart contract. Finally, we decided to remove all security on the node and this time the contract uploaded and worked. We were then able to configure users, and via MetaMask, assign them ether, log in to the website and register as one of the personas we’d created e.g.  a farmer, producer importer, whatever and then actually interact with the contract and see things happen. The next day, however, Microsoft decided to remove the Ethereum POA template from the Azure platform.  Finding ourselves back at square one with a new Ethereum installation, we felt we’d had enough of Blockchain for the time being; there had to be a better way.

In part 2, we’ll dig into Azure Blockchain Workbench, explaining how to set it up and what it offers, and show how months of pain can be reduced to minutes!

We have all heard of Blockchain, the secure distributed ledger on which all cryptocurrencies rely. Many will also be aware of “Smart Contracts”, the extension to Blockchain implemented by the Ethereum network, and by now we have all heard how these new technologies and developments are predicted to change the face of business over the coming years.

Yet when the hype and marketing are stripped away how should a typical developer get to grips with Blockchain, what do they need to know, and what tools and platforms are available?

 

Part 1. Building a Blockchain demo; how hard can that be?   

Recently a colleague and I were asked to build a blockchain demo to simulate a simple supply chain, such as coffee production, you know the sort of thing, a coffee farmer, an importer, a producer and supplier and finally a retailer. Each participant would have access to the private blockchain network on which we would develop a smart contract implementing the above roles, allowing farmers to offer priced goods and importers to bid for them, and so on. Once a bid has been accepted by the farmer the transaction between themselves and importer would be written to the encrypted imputable digital ledger and ownership past to the importer, everything “sorted”, as they say. When the coffee beans were in the hands of the importer they in turn would be able to offer the product to producers or roasters, and so on up the supply chain. All this would be available via the Web with a friendly UI allowing invited users to follow and monitor each of the transactions and view a historical record. Well that was the idea, implement traceability and trust at each stage of the process.

Photo by Stevie McCusker, Horsham Coffee Roaster

So we set about it using Solidity and the online Remix editor, we built and tested our smart contract whilst at the same time sought a solution to the hosting problem. Being familiar with Azure we decided to host our private blockchain there employing one of the built in Blockchain templates, specifically the Ethereum POA (Proof of Authority). Setting this up was relatively straightforward, merely a question of following a simple templated wizard; things were looking good.

Having tested our smart contract locally we installed MetaMask, a free plugin that allows Dapps (decentralized apps) to run in a browser and provides a secure identity vault. We could now log in and simulate the multiple personas implemented in the smart contract. Although MetaMask was not without difficulties (bugs?), we were getting somewhere despite the long address names we were required to remember.

 

Next step was to upload the smart contract, and that’s when our luck ran out.

Next we build a simple Angular Web app, uploaded it to an Azure Web service host, connected and proved it worked. This was to be our front end which would connect to our private blockchain instance.  Next step was to upload the smart contract, and that’s when our luck ran out. No matter what we tried we were unable to get our contract, or indeed any contract, to install on a node of our private Ethereum network. Hours, indeed days spent SSH’ing’into the node and playing around with Geth (Go Ethereum configuration tool) proved fruitless, as were our searches on web for a solution.

How hard can that be?  Quite hard actually!   

We began to concede that ignorance or plain lack of experience had finally caught up with us, and realised that Blockchain development has its pitfalls; amongst them, lack of information. Much of our time was spent trying to understand and debug the uploading of our smart contract. Finally, we decided to remove all security on the node and this time the contract uploaded and worked. We were then able to configure users, and via MetaMask, assign them ether, log in to the website and register as one of the personas we’d created e.g.  a farmer, producer importer, whatever and then actually interact with the contract and see things happen. The next day, however, Microsoft decided to remove the Ethereum POA template from the Azure platform.  Finding ourselves back at square one with a new Ethereum installation, we felt we’d had enough of Blockchain for the time being; there had to be a better way.

In part 2, we’ll dig into Azure Blockchain Workbench, explaining how to set it up and what it offers, and show how months of pain can be reduced to minutes!