【问题标题】:Deploy Etherum contract to Rinkbey under proxy在代理下将以太坊合约部署到 Rinkeby
【发布时间】:2018-10-06 20:35:56
【问题描述】:

我正在尝试使用 Infura 将合同部署到 rinkbey。但由于我在合作代理下,我无法部署它。

我使用的是标准代码。

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();

【问题讨论】:

  • 你得到什么错误?如果您的网络阻止访问 infura,您可以运行自己的节点,或通过 etherscan 推送已签名的交易。
  • 没有错误出现,部署脚本不起作用(卡住了)。我检查了没有代理的代码,它可以工作。

标签: proxy blockchain ethereum web3 truffle


【解决方案1】:

您的公司代理需要将 https://rinkeby.infura.io 列入白名单,才能将其连接到 infura。

否则,您必须在自己的场所运行奇偶校验节点,但在公司环境中,我认为上述内容将有更多机会解决。

或者您可以使用 Metamask 或 Etherscan 从您的浏览器本身对交易进行签名。

【讨论】:

  • 发生这种情况的机会非常渺茫。没有其他解决方法吗?是的,我可以使用元掩码进行交易,有没有办法使用元掩码进行部署?
  • 或许您可以使用 Metamask + Remix ide 将智能合约部署到 Rinkeby,然后使用 Metamask 从 truffle DAPP 连接到它进行交易。
  • 是的,这就是我现在正在做的事情。谢谢。
猜你喜欢
  • 2023-03-14
  • 2020-03-09
  • 2016-02-28
  • 1970-01-01
  • 2018-08-09
  • 1970-01-01
  • 1970-01-01
  • 2021-10-22
  • 2018-03-15
相关资源
最近更新 更多