You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Tutorial on how to use the Azure Blockchain Development Kit for Ethereum extension in Visual Studio Code to create, build, and deploy a smart contract on Azure Blockchain Service.
4
-
ms.date: 12/05/2019
4
+
ms.date: 12/06/2019
5
5
ms.topic: tutorial
6
6
ms.reviewer: chrisseg
7
7
@@ -10,15 +10,14 @@ ms.reviewer: chrisseg
10
10
11
11
# Tutorial: Create, build, and deploy smart contracts on Azure Blockchain Service
12
12
13
-
In this tutorial, use the Azure Blockchain Development Kit for Ethereum extension in Visual Studio Code to create, build, and deploy a smart contract on Azure Blockchain Service. You also use Truffle to execute a smart contract function via a transaction.
13
+
In this tutorial, use the Azure Blockchain Development Kit for Ethereum extension in Visual Studio Code to create, build, and deploy a smart contract on Azure Blockchain Service. You also use the development kit to execute a smart contract function via a transaction.
14
14
15
15
You use Azure Blockchain Development Kit for Ethereum to:
16
16
17
17
> [!div class="checklist"]
18
18
> * Create a smart contract
19
19
> * Deploy a smart contract
20
20
> * Execute a smart contract function via a transaction
@@ -88,68 +87,19 @@ The **HelloBlockchain** contract's **SendRequest** function changes the **Reques
88
87
89
88

90
89
91
-
When you execute a contract's function via a transaction, the transaction isn't processed until a block is created. Functions meant to be executed via a transaction return a transaction ID instead of a return value.
90
+
1. The interaction page allows you to choose a deployed contract version, call functions, view current state, and view metadata.
Smart contract functions can return the current value of state variables. Let's add a function to return the value of a state variable.
94
+
1. To call smart contract function, select the contract action and pass your arguments. Choose **SendRequest** contract action and enter **Hello, Blockchain!** for the **requestMessage** parameter. Select **Execute**to call the **SendRequest** function via a transaction.
96
95
97
-
1. In **HelloBlockchain.sol**, add a **getMessage** function to the **HelloBlockchain** smart contract.
function getMessage() public view returns (string memory)
101
-
{
102
-
if (State == StateType.Request)
103
-
return RequestMessage;
104
-
else
105
-
return ResponseMessage;
106
-
}
107
-
```
98
+
Once the transaction is processed, the interaction section reflects the state changes.
108
99
109
-
The function returns the message stored in a state variable based on the current state of the contract.
100
+

110
101
111
-
1. Right-click **HelloBlockchain.sol** and choose **Build Contracts** from the menu to compile the changes to the smart contract.
112
-
1. To deploy, right-click **HelloBlockchain.sol** and choose **Deploy Contracts** from the menu. When prompted, choose your Azure Blockchain consortium network in the command palette.
113
-
1. Next, create a script using to call the **getMessage** function. Create a new file in the root of your Truffle project and name it `getmessage.js`. Add the following Web3 JavaScript code to the file.
114
-
115
-
```javascript
116
-
var HelloBlockchain = artifacts.require("HelloBlockchain");
117
-
118
-
module.exports = function(done) {
119
-
console.log("Getting the deployed version of the HelloBlockchain smart contract")
console.log("Calling getMessage function for contract ", instance.address);
122
-
return instance.getMessage();
123
-
}).then(function(result) {
124
-
console.log("Request message value: ", result);
125
-
console.log("Request complete");
126
-
done();
127
-
}).catch(function(e) {
128
-
console.log(e);
129
-
done();
130
-
});
131
-
};
132
-
```
133
-
134
-
1. In VS Code's terminal pane, use Truffle to execute the script on your blockchain network. In the terminal pane menu bar, select the **Terminal** tab and **PowerShell** in the dropdown.
Notice the value is not **Hello, blockchain!**. Instead, the returned value is a placeholder. When you change and deploy the contract, the changed contract is deployed at a new address and the state variables are assigned values in the smart contract constructor. The Truffle sample **2_deploy_contracts.js** migration script deploys the smart contract and passes a placeholder value as an argument. The constructor sets the **RequestMessage** state variable to the placeholder value and that's what is returned.
147
-
148
-
1. To set the **RequestMessage** state variable and query the value, run the **sendrequest.js** and **getmessage.js** scripts again.
**sendrequest.js** sets the **RequestMessage** state variable to **Hello, blockchain!** and **getmessage.js** queries the contract for value of **RequestMessage** state variable and returns **Hello, blockchain!**.
102
+
The SendRequest function sets the **RequestMessage** and **State** fields. The current state for **RequestMessage** is the argument you passed **Hello, Blockchain**. The **State** field value remains **Request**.
0 commit comments