Page 30 - MSDN Magazine, June 2018
P. 30
• The Resource group to use to group all these resources together. I recommend creating a new resource group for your Blockchain Workbench solution.
• The region to which you wish to deploy the resources. Step 2 requires you to have completed the prerequisite steps of registration of the blockchain client app in Azure AD, as you’ll need the Registration Application ID and key to enter when requested. You also need to specify the Tenant domain name obtained as part
of the registration of the client app in Azure AD.
In Step 3 you can specify the number of nodes in the provisioned
blockchain ledger and the size of the allocated VMs. Step 4 is for optionally opting in to the Operations Management Suite (OMS) for monitoring the deployed solution.
Steps 5 and 6 are simply a summary of the resources being pro- visioned and your acknowledgment that you understand that there is a cost implication. Once the deployment of the Workbench has completed, you’ll see a new Resource Group with the specified name. Some resources deployed here, such as Application Insights, will allow you to get more information about the state of the Work- bench, including details about the deployed VMs and networks.
As I noted earlier, Azure Blockchain Workbench leverages Azure AD for authentication, access control and workflow persona iden- tification. Only users specified in the referenced Azure AD will be able to authenticate and use the deployed resources. In addition, users must be associated with a specific user group in order to interact and perform actions. It’s therefore necessary to manage user accounts interacting with Azure Blockchain Workbench and assign them the required permissions.
Deploying a Smart Contract
Once deployed, you can access Azure Blockchain Workbench by navigating to its URL. You’ll see an Azure AD-backed login experience where you can enter your work or personal Microsoft account credentials to access the application.
Smart contracts are written
in blockchain stack-specific languages. For example, Solidity is used for Ethereum, while Go is used for Hyperledger Fabric.
You can now start leveraging smart contracts, which contain business logic that drives different scenario flows. This approach provides the immutability, deterministic execution and trans- parency required in untrusted environments. Smart contracts are written in blockchain stack-specific languages. For example, Solidity is used for Ethereum, while Go is used for Hyperledger Fabric. A smart contract is deployed to all nodes on the blockchain. During execution, the information it conveys is also replicated to all the nodes on the network.
Figure 3 LexingtonBase Contract
contract LexingtonBase {
event LexingtonContractCreated(string contractType, address originatingAddress); event LexingtonContractUpdated(string contractType, string action,
address originatingAddress);
string internal ContractType;
function LexingtonBase(string contractType) internal { ContractType = contractType;
}
function ContractCreated() internal { LexingtonContractCreated(ContractType, msg.sender);
}
function ContractUpdated(string action) internal { LexingtonContractUpdated(ContractType, action, msg.sender);
} }
Figure 4 Asset Transfer Smart Contract
contract AssetTransfer is LexingtonBase('AssetTransfer') {
enum AssetState { Created, Active, OfferPlaced, PendingInspection, Inspected, Appraised,
NotionalAcceptance, BuyerAccepted, SellerAccepted, Accepted,
Complete, Terminated } address public Owner; string public Description; uint public AskingPrice; AssetState public State;
address public Buyer; uint public OfferPrice; address public Inspector; address public Appraiser;
function AssetTransfer(string description, uint256 price) {
Owner = msg.sender; AskingPrice = price; Description = description; State = AssetState.Active; ContractCreated();
} }
24 msdn magazine
Blockchain
The main goal of Azure Blockchain Workbench is to stand up the scaffolding around the blockchain application, so users can focus on creating the smart contract-based business logic. Once a smart contract is instantiated in the Workbench, it’s written to the blockchain, and subsequent updates to the smart contract are recorded on the blockchain. After the Azure Blockchain Workbench administrator has deployed smart contracts and com- pleted user assignments for the smart contracts, other users can interact with the blockchain application and engage in the smart contract workflows.
Let’s start by deploying any of the existing demo smart contracts. After signing in successfully, you should see an Admin link on the top right. Click on the Admin link to access the Administrator Dashboard. There are currently three actions available to the Administrator in the Workbench. From here you can assign users, deploy demo contracts, and deploy custom contracts.
Clicking on Deploy Demo Contract in the Administrator Dashboard brings you to a list of all the demo contracts that can be provided. The current release of Blockchain Workbench contains a set of demo smart contracts and configuration files to get you started.