How to use openzeppelin CLI with a Kaleido network?

OpenZeppelin is a very powerful and popular smart contract library, with high quality and secure Solidity code for implementing many types of Ethereum smart contracts like tokens, and role-based permissioning.

OpenZeppelin CLI is a useful tool to manage smart contracts life cycles. It integrates with the upgradable contracts library which makes it even more interesting to Solidity developers.

Due to the security protection on Kaleido blockchain nodes, all connections require authentication with the app credentials. This requires some custom coding to replace the simple protocol, host, port based settings in the CLI's network definition.

Use the following technique in network.js to create provider instances for the openzeppelin CLI to use:

const HttpProvider = require('web3-providers-http');

module.exports = {
  networks: {
    kaleido: {
      provider: new HttpProvider(process.env.ETH_URL),
      gasPrice: 0,
      networkId: '*'
    }
  }
};

The environment variable ETH_URL must be set to the full URL pointing to a Kaleido node, in the format https://username:password@hostname, that can be obtained from the Connect menu of the target Kaleido node.

To try this out in a sample project, checkout this sample repository.