Blockchain 如何解决[web3.eth.Contract不是构造函数]

Blockchain 如何解决[web3.eth.Contract不是构造函数],blockchain,ethereum,web3,truffle,Blockchain,Ethereum,Web3,Truffle,我犯了这个错误 truffle(development)> const mycontract = new web3.eth.Contract(abi, contractAddress) Thrown: TypeError: web3.eth.Contract is not a constructor 在控制台上设置mycontract时会发生这种情况。 Web3版本是'1.0.0' 您能给我一些建议吗?假设您使用的是Truffle 5,并且您已经运行了Truffle deploy命令,您

我犯了这个错误

truffle(development)> const mycontract = new web3.eth.Contract(abi, contractAddress)
Thrown:
TypeError: web3.eth.Contract is not a constructor
在控制台上设置mycontract时会发生这种情况。 Web3版本是'1.0.0'


您能给我一些建议吗?

假设您使用的是Truffle 5,并且您已经运行了Truffle deploy命令,您只需在您的Truffle控制台终端中运行以下命令即可:

const mycontract = await YourContract.deployed()

// or

const mycontract = await YourContract.at("0x_your_contract_address")