Ethereum 未处理的拒绝错误:此合同对象没有';尚未设置地址,请先设置地址

Ethereum 未处理的拒绝错误:此合同对象没有';尚未设置地址,请先设置地址,ethereum,web3js,Ethereum,Web3js,我目前正试图使用Infura通过Web3在我的机器上运行。当我设置运行我的节点index.js文件时,我得到以下错误: Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first. at Object._processExecuteArguments (/Users/Oso.Lu/cryptokitty-miner/node_module

我目前正试图使用Infura通过Web3在我的机器上运行。当我设置运行我的
节点index.js
文件时,我得到以下错误:

Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first.
    at Object._processExecuteArguments (/Users/Oso.Lu/cryptokitty-miner/node_modules/web3-eth-contract/src/index.js:739:15)
    at Object._executeMethod (/Users/Oso.Lu/cryptokitty-miner/node_modules/web3-eth-contract/src/index.js:760:54


var helpers = require("./helpers.js")

var Web3 = require('web3');
var Tx = require('ethereumjs-tx');

// You should be running a local Eth node or use Infura.
var web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io:443"));
var prompt = require('prompt');


var sendingAddress = "********************"  // with your sending ETH address
var pKey = "******************************"; // This will store the corresponding private key.  we'll be getting the private key for this Eth address from a command prompt


// Keep track of kitties we'll mine to avoid double-mining
var kittyArray = []

var theNonce = "";
// Gas price.   Todo: Use Eth gas station Oracle to predict gas prices
var gwei = '26'

// Track # of received
var num_requested = 0
var num_received = 0
我想可能是Infura端口443出现了问题

简单解

其中,投票是我的智能合约实例名称

0x6EE9957AEF5073C6AF71441EC7962527C37671”是部署的智能联系人地址

我的web3.js版本 “web3”:“^1.0.0-beta.31”,


这是为合同设置地址的正确方法。您可以通过networkData.address设置地址。这通常意味着您没有将MyContract.options.address设置为部署后从合同实例返回的地址。您需要发布完整的代码以进行确认。我们必须在哪里写入“Voting.options.address=”0x6EE9957AEF5073C6AF71441EC7962527C37671“?我有与您相同的错误。您是否已找到@ngCourse建议添加的代码的添加位置?
Voting.options.address = "0x6ee9957aef5f4073c6af71441ec7962527c37671"
const accounts = await web3.eth.getAccounts()
this.setState({ 'account': accounts[0] });
const networkId = await web3.eth.net.getId()
const networkData = SocialNetwork.networks[networkId]
if (networkData) {
    const socialNetwork = web3.eth.Contract(SocialNetwork.abi, networkData.address)

} else {
    window.alert('oops')
}