【问题标题】:How to solve [web3.eth.Contract is not a constructor]如何解决【web3.eth.Contract 不是构造函数】
【发布时间】:2019-04-10 04:03:07
【问题描述】:

我收到此错误。

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

当我在控制台上设置 mycontract 时会发生这种情况。 Web3 版本是`1.0.0

请给我一些建议好吗?

【问题讨论】:

    标签: blockchain ethereum web3 truffle


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多