【问题标题】:Ethereum deployed contract not defined in Geth Javascript console以太坊部署的合约未在 Geth Javascript 控制台中定义
【发布时间】:2018-01-24 16:12:08
【问题描述】:

我无法从 Geth Javascript 控制台访问私有网络上部署和挖掘的以太坊合约。不知道问题出在哪里,感谢任何帮助。

提前感谢您的宝贵时间。

场景

我启动了我的 Geth,如下所示

geth --datadir ~/.ethereum/myProject --networkid 1234 --rpc --rpcport 8546 --rpcapi "eth,net,web3" --unlock 0 console

我已经部署和挖掘了一个以太坊合约(为了简化事情,我使用了 Truffle 提供的默认 MetaCoin 合约),我得到了 trx 和合约地址。 我可以从 Truffle 控制台访问它,但如果我从 Geth Javascript 控制台尝试,我会收到错误。

请参考以下图片:

Truffle console

Geth javascript console

使用的软件

  • Geth (v1.7.3-stable)
  • NodeJS (v6.12.3)
  • TestRPC (v6.0.3 (ganache-core:2.0.2))
  • 松露 (v4.0.5)

【问题讨论】:

    标签: ethereum truffle geth


    【解决方案1】:

    Geth 不知道MetaCoin。在 Geth 控制台中,您需要执行以下操作:

    var MetaCoin = web3.eth.Contract(metaCoinJsonAbi, itsAddress);
    // or web3.eth.contract depending on the version of Web3
    

    然后你就可以使用它了。 Refer to this.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 2019-04-07
      • 2018-03-15
      相关资源
      最近更新 更多