【发布时间】: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