Use the Smart Contract Explorer with the escrow flow

The Smart Contract Explorer also enables you to view information about the escrow smart contract you executed using the Smart Contract CLI.

Description

This article will show you how to use the Smart Contract Explorer in conjunction with the Smart Contract CLI. Specifically, the escrow flow will be covered.

Publish the contract

After publishing the escrow smart contract, navigate to the TBSP UI.

Log in with the user and password and then select the Smart Contract Explorer.

From the main screen, select Instances:

Screen Shot 2020-10-22 at 3.28.18 PM

Here, all running instances are displayed. Let's select the details of the active escrow contract:

The details of this instance are then displayed, such as the smart contract ID:

Screen Shot 2020-10-22 at 3-30-14 PM-png-1

Let's get the state of the contract:

We see that it has been initialized.

Activate the escrow function of the contract

Now, let's return to the terminal session and activate the escrow function.

The seller transfers the asset to the escrow with the command:

tymlez-sc transferCall --functionName=transferAsset --assetId=<SELLER_ASSET_ID>

Change the context to the buyer and then transfer the buyer asset to the escrow:

tymlez-sc transferCall --functionName=transferAsset --assetId=<BUYER_ASSET_ID>

In the Smart Contract Explorer, let's get the state of the contract:

We see that the state of the contract is "locked". That is, the smart contract holds both buyer and seller assets in escrow.

Assets are released to the different entities

The buyer begins with taking delivery of the car asset:
tymlez-sc transferCall --functionName=transferReward --assetId=<BUYER_ASSET_ID>

In the Smart Contract Explorer, let's check the state of the contract:

We see that the buyer has obtained the asset.

In order for the seller to obtain the buyer asset, a specific condition must be met: the buyer must indicate he/she is satisfied with the asset he received.

To indicate buyer satisfaction, assume the role of the buyer:
tymlez-dev config setContext --defaultContext=cloud1

Now, the buyer indicates satisfaction:

tymlez-sc call --functionName=setCancel false

Let's see the state of the contract:

Now, assume the role of the seller:

tymlez-dev config setContext --defaultContext=cloud

and take delivery of the buyer asset:

tymlez-sc transferCall --functionName=transferReward --assetId=<SELLER_ASSET_ID>

Let's now check the state of the smart contract in the Smart Contract Explorer:

The smart contract has now been updated. 

Navigation

Return to the smart contract explorer main menu.