Using Azure Blockchain Development Kit with OpenZeppelin Contracts

The Azure Blockchain Development Kit for Ethereum extension for Visual Studio Code (VS Code) now supports OpenZeppelin Contracts. :rocket:

You can read all the details in the Microsoft announcement:

The following guide will walk through using the Azure Blockchain Development Kit for Ethereum with OpenZeppelin Contracts to create an ERC20 token, including deploying and interacting.


If you haven’t already, install VS Code as per the instructions on the website:


Install Azure Blockchain Development Kit for Ethereum extension by selecting install from the website:

Create a new project

Create an empty directory for your new project e.g. mkdir demo
Open VS Code
From the VS Code Command Palette (View menu -> Command Palette), type Azure Blockchain: New Solidity Project
Then Select type of solidity project choose Create basic project
Then choose the empty directory you created previously.
This will do a truffle unbox of Azure-Samples/Blockchain-Ethereum-Template so could be a good time to make a cup of tea.

Add OpenZeppelin Contracts

Select an existing contract in the contracts directory e.g. Migrations.sol and open the context menu (e.g. in Windows right click).
Choose Add contracts from OpenZeppelin
Then Select category for downloading and choose Tokens/ERC20
This will download the OpenZeppelin Contracts for ERC20 Tokens in contracts/openZeppelin.
The contracts in contracts/openZeppelin are read only so that you can’t save any changes.

Create an ERC20 Token

We will now create a simple ERC20 token where the total supply will be issued to the deployer of the contract.

In the contracts directory create a file named SimpleToken.sol.
Paste the following smart contract code into SimpleToken.sol.
We can see that the contract imports from the OpenZeppelin contracts we just added to our project.

pragma solidity ^0.5.0;

import "./openZeppelin/token/ERC20/ERC20.sol";
import "./openZeppelin/token/ERC20/ERC20Detailed.sol";

 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
contract SimpleToken is ERC20, ERC20Detailed {

     * @dev Constructor that gives msg.sender all of existing tokens.
    constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
        _mint(msg.sender, 10000 * (10 ** uint256(decimals())));


In the migrations directory, we can replace the contents of 2_deploy_contract.js with the following:

var SimpleToken = artifacts.require("SimpleToken");
module.exports = deployer => {

We don’t need 99_deploy_openzeppelin.js so this can be deleted.


From the Command Palette, type Azure Blockchain: Deploy Contracts (or select one of the contracts in the contracts directory e.g. SimpleToken.sol and from the context menu choose Deploy Contracts).
Then select development to deploy to a local test network (ganache-cli)


Select SimpleToken.sol in the contracts directory and from the context menu choose Show Smart Contract Interaction Page
This will display a Smart Contract UI for the SimpleToken.

Currently read functions that take parameters such as balanceOf and allowance are not supported.

Change the Contract Action to transfer.
Set the recipient to an address e.g. 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0
Set the amount e.g. 23
Press the Execute button to create a transaction.

Next steps

We can also deploy to public networks such as public testnets or mainnet using Infura.

See the Infura blog post for instructions:


Thanks for this guide, confirming it works.
Do we know when they will begin supporting other functions e.g. balanceOf allowance

1 Like

Hi @pkr,

The Smart Contract Interaction Page is nice.
I don’t know when they will support read functions that take parameters. I will see if I can find out.

transfer works, is there a way to look up the balance of the account where the tokens were sent?

Hi @pkr,

In VS Code in a terminal you could run truffle console, get the token and then check the balance of an account.

I don’t know if there is an easier way of doing this, if you find one, let the community know.

$ truffle console
truffle(development)> token = await SimpleToken.deployed()
truffle(development)> (await token.balanceOf("0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0")).toString()