Azure Blockchain Workbench – Write Smart Contract for Asset Transfer DApp with Solidity

This is an series of post to build Blockchain solutions with Azure Blockchain Workbench. Before reading this post, please go through Overview of Azure Blockchain Workbench .

Step by step guide Build and Deploy Blockchain solution with Ethereum

In this post we will work on Step 3: Write Smart Contract for Asset Transfer DApp with Solidity

Steps to write Smart Contract for Asset Transfer DApp with Solidity

  1. Create Configuration file
  2. Write business login smart contract with Solidity programming language

In this post we will write business logic for Asset Transfer application.

This sample application is available in Azure Samples Github

Asset Transfer application

The asset transfer smart contract covers the scenario for buying and selling high value assets, which require an inspector and appraiser. Sellers can list their assets by instantiating an asset transfer smart contract. Buyers can make offers by taking an action on the smart contract, and other parties can take actions to inspect or appraise the asset. Once the asset is marked both inspected and appraised, the buyer and seller will confirm the sale again before the contract is set to complete. At each point in the process, all participants have visibility into the state of the contract as it is updated. Screenshot_43.png

There are four personas in this demo contract – the seller as the initiator, and the other three personas (buyer, appraiser, and inspector) as participants. As indicated in the visual above, at certain stages in the contract, there are various actions which participants can take. The logic written in the smart contract will modify the state accordingly based on which actions are taken.



The following state transition diagram articulates the possible flows, and the various transition functions at each state. Each user is only allowed to take certain actions depending on the application role. Instance roles indicate that only the user with the application role assigned to the specific contract is able to take actions on the contract.

The happy path highlighted shows in a given asset transfer contract, an instance owner can place an asset up for sale, and a potential buyer can place an offer. The two parties can negotiate and once an offer amount is agreed upon, an inspector and an appraiser working for the instance buyer will participate. After their involvement, the buyer and the owner can choose to move forward and ultimately complete the transaction.

1. Create Configuration file

Download the configuration file AssetTransfer.json

Configuration file AssetTransfer.json  has High-level workflows stages and Interaction model.

We define below configuration in AssetTransfer.json

  1. Application metadata – Define application name, description, display name

  2. Application roles – Define user role

  3. Workflows – Define stages and actions

2. Write business login smart contract with Solidity programming language 

Download the Asset Transfer Smart Contract file AssetTransfer.sol

Ethereum smart contract are written in a language called Solidity

AssetTransfer.sol smart contract has following functions, these functioned are called to take respective action.

  • Constructor
  • Terminate
  • Modify
  • MakeOffer
  • AcceptOffer
  • Reject
  • Accept
  • ModifyOffer
  • RescindOffer
  • MarkAppraised
  • MarkInspected


So far we have completed 3 steps in our series

In the next step we will Deploy Asset Transfer application.

Step 4: Deploy Asset Transfer application

Reference/Further reading

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s