简体   繁体   English

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

[英]How to solve [web3.eth.Contract is not a constructor]

I`m geting this error. 我收到此错误。

truffle(development)> const mycontract = new web3.eth.Contract(abi, contractAddress)
Thrown:
TypeError: web3.eth.Contract is not a constructor

This happens when I set mycontract on console. 当我在控制台上设置mycontract ,会发生这种情况。 Web3 version is `1.0.0 Web3版本为1.0.0

Could you give me any advise, please? 请给我任何建议吗?

Assuming you are on Truffle 5 and you already run truffle deploy command, you can simply run the following in your truffle console terminal: 假设您使用的是Truffle 5,并且已经运行了truffle deploy命令,则可以在truffle console终端中简单地运行以下命令:

const mycontract = await YourContract.deployed()

// or

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在智能合约中接收 ETH - How to receive ETH in a smart contract web3上调用solidity合约function时如何添加ETH作为参数 - How to add ETH as parameter when calling solidity contract function on web3 如何发送wei/eth到合约地址? (使用松露 javascript 测试) - How to send wei/eth to contract address? (using truffle javascript test) 如何在合约中设置 ETH 的接收者,以在 remix IDE 中使用solidity usign call() 从一个地址向另一个地址发送ETH - How to set the receiver of ETH in a contract to send ETH from one address to another with solidity usign call() in remix IDE Web3 1.0:创建合同后,`web3.eth.call(tx)`返回什么? - Web3 1.0: What does `web3.eth.call(tx)` return for a contract creation? 每次我的智能合约收到 ETH 时,如何更新变量? - How can i update a variable everytime my smart contract receives ETH? 如何在web3.eth.sendTransaction中动态设置属性 - How to dynamically set attribute in web3.eth.sendTransaction 我如何为 Nethereum 做相当于 web3.eth.getAccounts() 的操作? - How do I do the equivalent of web3.eth.getAccounts() for Nethereum? 智能合约将 eth 转移到地址失败 - Smart contract transfer eth to address failed 如何使用 web3gl 将合约发送到智能合约 - How to send contract using web3gl to smart contract
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM