Deploy contract to private blockchain using JsonRpcProvider with OpenZeppelin CLI?

Hello to all,
I was wondering how I can deploy contract using the cli oz deploy in case I want to do it using ethers.js provider.
The reason for this is that my private blockchain uses basic auth and therefore I need my provider to be as the following:

const Provider = new ethers.providers.JsonRpcProvider(
    url: 'http://localhost:8545',
    user: 'user',
    password: 'password'
const ownerWallet = new ethers.Wallet('PRIVATEKEY').connect(Provider)

Where and how should I use this in the network.js file?
From what I see it is only possible to use HDWalletProvider and as far as I know I can’t put user and password for the basic auth when using the HDWalletProvider.

Any idea how to do this?


1 Like

Hi @jeeza1,

Sorry for the delay in getting back to you.

To connect using OpenZeppelin CLI we need a web3 Provider that supports basic auth. (I couldn’t see anywhere that Truffle HDWallet Provider would support basic auth).

A DuckDuckGo search found the following that you could potentially use (note I haven’t tried it out so can’t vouch for it):

Alternatively as you can use ethers provider that supports basic auth, instead of using OpenZeppelin CLI you could use Buidler. We announced today Upgrades Plugins for Buidler and Truffle.

Hi @jeeza1,

Checking to see if you were able to connect?