Search code examples
javascriptethereumweb3jstruffle

Deploy Etherum contract to Rinkeby under proxy


I am trying to deploy a contract to Rinkeby using Infura. But since I'm under a corporate proxy I'm not able to deploy it.

I'm using a standard code.

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile');

const provider = new HDWalletProvider(
    '<Text to be Inserted from metamask>',
    'https://rinkeby.infura.io/v3/<id>'
);

const web3 = new Web3(provider);

const deploy = async () => {
    console.log("Starting to deploy");
    const accounts = await web3.eth.getAccounts();

    console.log('Attempting to deploy from account', accounts[0]);

    const result = await new web3.eth.Contract(JSON.parse(interface))
     .deploy({data: bytecode })
     .send({ gas: '1000000', from: accounts[0]})

    console.log('Contract deployed to', result.options.address);
};
deploy();

Solution

  • Your corporate proxy needs to whitelist https://rinkeby.infura.io for getting it connected to the infura.

    Otherwise you have to run a parity node on your own premises, but being in a corporate environment, i think the above will have more chance to work out.

    Or you can use Metamask or Etherscan to have the transactions signed from your browser itself.