Experiment #101 How To Create a Blockchain Workbench App

In our Experiment 101# we have implemented an IoT  device with BlockChain . In this post learn how to create a Blockchain Worbench App.

 

  1. Add a new Azure Blockchain Workbench

An Azure Blockchain Workbench is not a unique resource that we can add to our resource group.

 

It is a whole container with certain preset and linked resources.

 

Wait for Blockchain Workbench to deploy. This process can take from 60 to 90 minutes to complete.

 

  1. Configure the Azure App Service registration

The App Service resource gives us the URL to start with the Blockchain Workbench Web Client set up.

 

 

Follow all the steps to configure the Azure Blockchain Workbench application registration.

 

 

Now, we are ready to build a new application accessing to the mentioned URL.

 

  1. Create a Solidity (.sol) Blockchain Smart Contract

Specify the Solidity version:

pragma solidity >=0.4.25 <0.6.0;

Begin the Smart Contract to fill it:

contract OrganTransportApp { }

Define the donation states:

enum StateType {Creating, Created, Ready, InTransit, Monitoring, Completed, Spoiled} 

Create the donation state property:

StateType public DonationState;

Add the participating agents:

address public DonationCenter;
address public OrganSender;
address public TransportVehicle;
address public TelemetryDevice;
address public OrganReceiver;

Add the temperature threshold properties:

int public MinTemperature;
int public MaxTemperature;

Create the real-time temperature reading property:

int public SensorTemperature;

Add a property to store donated organ information:

string public DonationInfo;

Define the Organ Transport App Smart Contract constructor:

Constructor (address sending, address vehicle, address device, address receiving, 
             string memory donation, int max, int min) public {
    DonationCenter = msg.sender;
    OrganSender = sending;
    TransportVehicle = vehicle;
    TelemetryDevice = device;
    OrganReceiver = receiving;
    MinTemperature = min;
    MaxTemperature = max;
    DonationInfo = donation;
    DonationState = StateType.Created;
    if (MinTemperature >= MaxTemperature) {
        revert();
    }
}

The donation center is who starts the process by creating the Smart Contract and adding all needed information about the donation.

Create a function to report that the organ is ready in the sending hospital:

function OrganReady() public {
    if (DonorHospital != msg.sender || DonationState != StateType.Created) {
        revert();
    }
    DonationState = StateType.Ready;
}

Create a function to report that the organ is inside the transport vehicle:

function OrganInTransit() public {
    if (TransportVehicle != msg.sender || 
        DonationState != StateType.Ready) {
        revert();
    }
    DonationState = StateType.InTransit;
}

Create a function to report that the organ has arrived at the receiving hospital:

function OrganArrived() public
{
    if (OrganReceiver != msg.sender || 
        DonationState != StateType.Monitoring) {
        revert();
    }
    DonationState = StateType.Completed;
}

Add a function to check the temperature inside the organ transport fridge:

function TemperatureCheck(int temperature) public {
    if ( TransportVehicle != msg.sender || 
        (DonationState != StateType.InTransit &&
         DonationState != StateType.Monitoring) ) {
        revert();
    } else {
        if (temperature > MaxTemperature || 
            temperature < MinTemperature) {
            DonationState = StateType.Spoiled;
        }
        SensorTemperature = temperature;
        if (DonationState == StateType.InTransit) {
            DonationState = StateType.Monitoring;
        }
    }
}
  1. Create a JSON Metadata Configuration File

Define the Smart Contract object in a JSON format:

{
    "ApplicationName": "OrganTransportApp",
    "DisplayName": "Organ Transport Application",
    "ApplicationRoles": [ {“Name": "Admin”}, {"Name": "User”} ],
    "Workflows": [ {
            "Initiators": [ "Admin" ],
            "StartState": "Creating",
            "Properties": [ ],
            "Constructor": { "Parameters": [ ] },
            "Functions": [ ],
            "States": [ ]
    } ]
}

Add metadata for all the Properties of the object:

{
    "Name": "DonationState",
    "Type": { "Name": "state" }
}, {
    "Name": "DonationCenter",
    "Type": { "Name": "user" }
}, {
    "Name": "OrganSender",
    "Type": { "Name": "user" }
}, {
    "Name": "TransportVehicle",
    "Type": { "Name": "user" }
}, {
    "Name": "TelemetryDevice",
    "Type": { "Name": "user" }
}, {
    "Name": "OrganReceiver",
    "Type": { "Name": "user" }
}, {
    "Name": "MinTemperature",
    "Type": { "Name": "int" }
}, {
    "Name": "MaxTemperature",
    "Type": { "Name": "int" }
}, {
    "Name": "SensorTemperature",
    "Type": { "Name": "int" }
}, {
    "Name": "DonationInfo",
    "Type":{ "Name": "string" }
}

Define the Constructor parameters for the Smart:

{
    "Name": "sending",
    "DisplayName": "Organ Sender",
    "Type": { "Name": "user" } 
}, {
    "Name": "vehicle",
    "DisplayName": "Transport Vehicle",
    "Type": { "Name": "user" }
}, {
    "Name": "device",
    "DisplayName": "Telemetry Device",
    "Type": { "Name": "user" } 
}, {
    "Name": "receiving",
    "DisplayName": "Organ Receiver",
    "Type": { "Name": "user" } 
}, {
    "Name": "donation",
    "DisplayName": "Donation",
    "Type": { "Name": "string" }

}, {
    "Name": "min",
    "DisplayName": "Min Temperature",
    "Type": { "Name": "int" } 
} , {
    "Name": "max",
    "DisplayName": "Max Temperature",
    "Type": { "Name": "int" } 
}

Add metadata to define the States of the Smart Contract:

{
    "Name": "Creating",
    "PercentComplete": 0,
    "Value": 0,
    "Style": "Success",
    "Transitions": []
}, {
    "Name": "Created",
    "PercentComplete": 20,
    "Value": 1,
    "Style": "Success",
    "Transitions": [ {
            "AllowedRoles": [ "Admin", "User" ],
            "AllowedInstanceRoles": [ "OrganSender" ],
            "Function": "OrganReady",
            "NextStates": [ "Ready" ]
        } ]
}, {
    "Name": "Ready",
    "PercentComplete": 40,
    "Value": 2,
    "Style": "Success",
    "Transitions": [ {
            "AllowedRoles": [ "Admin", "User" ],
            "AllowedInstanceRoles": [ "TransportVehicle" ],
            "Function": "OrganInTransit",
            "NextStates": [ "InTransit" ]
        } ]
}, {
    "Name": "InTransit",
    "PercentComplete": 60,
    "Value": 3,
    "Style": "Success",
    "Transitions": [ {
        "AllowedRoles": [ "Admin", "User" ],
        "AllowedInstanceRoles": [ "TelemetryDevice" ],
        "Function": "TemperatureCheck",
        "NextStates": [ "Monitoring", "Spoiled " ]
    }, {
    "Name": "Monitoring",
    "PercentComplete": 80,
    "Value": 4,
    "Style": "Success",
    "Transitions": [ {
        "AllowedRoles": [ "Admin", "User" ],
        "AllowedInstanceRoles": [ "OrganReceiver" ],
        "Function": "OrganArrived",
        "NextStates": [ "Completed" ]
    }, {
        "AllowedRoles": [ "Admin", "User" ],
        "AllowedInstanceRoles": [ "TelemetryDevice" ],
        "Function": "TemperatureCheck",
        "NextStates": [ "Monitoring", "Spoiled " ]
    } ]
}, {
    "Name": "Completed",
    "PercentComplete": 100,
    "Value": 5,
    "Style": "Success",
    "Transitions": []
}, {
    "Name": "Spoiled",
    "PercentComplete": 100,
    "Value": 6,
    "Style": "Failure",
    "Transitions": []
}

The process jumps from a State to another through a Function that can only be run by certain kind of role. This is called ‘Transition’.

 

  1. Build the Blockchain Workbench Application

Create a new Blockchain Workbench application by accessing to the app service URL and clicking the ‘New’ button.

 

 

Upload the JSON metadata configuration file and the Solidity Blockchain Smart Contract. Finally, click on the ‘Deploy’ button.

 

 

Once the Blockchain Workbench application is deployed, you can start adding members to it and start creating contracts and blocks.

 

Check the demo video in our Youtube channel 

 

 

Official links:

Microsoft Cloud Workshop Azure Blockchain HoL


Step by step

Idiwork has arrived and we invite you to join us!
Raspberry Pi4 – All of a sudden!
Experiment #101 How to set up an IoT device in Azure IoT Hub
Start your own video game with Unity3D and CreatorKits
XR World: Minecraft Earth
Experiment #101 Architectural Diagram
Cyberpunk 2077 and The Future
Experiment #101 How to create an Azure Function App to record telemetry readings
An Introduction to neural networks
Microsoft Mixer, streaming your life !
Introduction to Azure Notebooks applying Cognitive Services with Jupyter
AR [T] Walk
Return of Age of Empires
Idiwork and Uno Platform partnership!!
The differences between Augemented Reality, Mixed Reality and Virtual Reality !
Experiment #102 How to Create an Azure Notebooks Project and Deploy a Summarization Service
Uno Platform Conference
YouTube Video: Creator Kits, learn how to create a RPG with Unity3D !! 🤖
Experiment #102 How to construct and train a Deep Neural Network using Keras and deploy the model as an Azure Web Service 🧠☁️
Uno Platform Conference Recap 😎
How to create a Uno Platform project in Visual Studio 💻🤓
What is a Neural Network? by Alberto Pinedo 🧠💻
Experiment #102 How to Deploy and Integrate Azure Cognitive Services: Computer Vision and Text Analytics 💻📑
Next stop: Madrid Games Week 👉🤖
Our Madrid Games Week experience ! 😎🤖
Experiment #102 How to use Microsoft Flow to send an email when an event occurs 📧📌
How to create your own controllers for Mixed Reality ToolKit 🎮🤓
Experiment #102 Architectural Diagram 📍
The magic of Hytale ⚔️
Start programming your own app in Uno Platform 📲👨‍💻
Avalonia, a big candidate to create cross-platform apps with XAML 😎📲
The value of Blockchain for business by Pablo Junco ⛓️🏢
Living in the night: Bloodlines 2 🧛🎮
Uno Platform Workshop Recap 💻📌
EasyRPC. Be proud of your APIs (First Part) 🤓🚀
Paralives, reimagine your virtual life 👾👩‍💻
Experiment #103 How to Modify the Project to Work with Face Cognitive Service and Servo Motor 👩‍💻📙
Experiment #103 How to Set Up the IoT Device Hardware: Peripherals and Electronics 🔈💡
We are going to be in the GDG DevFest in Málaga! 😎👾
EasyRPC. Be proud of your APIs (Second Part) 🤓🚀
Experiment #103 How to Build a 3D Printed Box to Pack and Run the IoT Project 🚀
MediEvil, remember the fear💀
Never forget the Fallen Order 🏹🎮
Experiment #103 Architectural Diagram 📍
Grace: The perfect DI IoC container [part 1] 💻🤓
Death Stranding: a story of death and connection ☠🏹
Experiment #204 How to assembly the 3D printed parts and servo motors of the robotic arm 🦾🤖
TemTem: a dream come true 🐹💥
Grace: The perfect DI IoC container [part 2] 💻🤓
Exploring the Outer Worlds 🎇⚔
Our review from Hololens 2 👓👷
Learn to code on your iPhone for FREE 📲🚀
New life, new horizons in Animal Crossing 🎮🐱
What’s WinUI? 💻🚀
Half Life Alyx ☠🧟‍♂
How to deploy a Censorship Resistant Website for FREE 🔓🌎
Superpower: The parser combinator library [Part 1] 💻🤓
UnoPlatform and WinUI, what to expect? 🚀📲
Happiness begins in Stardew Valley 🍎🐓
Science fiction in Assassin’s Creed 👽
The Cyber Attack Lifecycle 🕵‍♀💻
Superpower: The parser combinator library [Part 2] 💻🤓
Learn more about UnoPlatform! 😜📢
Create cybernetically enhanced web apps with SvelteJS 💻👇
Six Fun Drag & Drop 🧩 Programming Languages To Learn How To Code! 💻
Riot and Hytale unite! 👾😉
A new home called EVE Online 👽👇
Rejoice with UnoPlatform! May 2020 📲👇
UnoPlatform arrives to macOS 💻👈
Your new empire in Civilization VI 🎮🏹
Play Station 5 is near!
Build and defend your city, this is Manor Lords
Customization, landscape generation and more in Hytale🧝🏻‍♀️🧝🏼
Welcome, MAUI! 💣📲
Zombies will be zombies (TLOU2) 👽🧟‍♂
Rejoice with UnoPlatform! August 2020 📲👇
Final Fantasy Crystal Chronicles is back🧝🏻‍♀️⚔️
Bolt is now free in Unity3D 🎮
Feel the Flutter! 🌐
Microsoft buys ZeniMax Media (including Bethesda!)
Intel and Microsoft team up to empower AI on Edge
Linux and WSL2 - Part 1 Linux and WSL2 – Part 1: How do you run Windows applications on Linux? Or vice versa.
Guide how to Run Windows applications on Linux Linux and WSL2 – Part 2: How do you run Windows applications on Linux? Or vice versa.
Domain-driven design Domain-Driven Design: the elephant in the room
azure object anchors Azure Object Anchors: the third tool
Experiment #205 Step by step 1 Experiment #205 Applied Artificial Intelligence, the real one 🤖📹
AI Assembling the system Experiment #205 Applied Artificial Intelligence – Assembling the system ⚙️🦾
Redit Conquer all the APIs Refit – Conquer all the APIs
Experiment #205 Applied AI: the Information analysis Experiment #205 Applied Artificial Intelligence – Analysis of the information
Brand Presence step by step 1 Blog Experiment #206 Brand Presence
Experiment #206 Brand Presence - The analysis Experiment #206 Brand Presence – The analysis

Stay up to date!



1 comment

Leave a comment