【问题标题】:Calling function in truffle console error在松露控制台错误中调用函数
【发布时间】:2017-09-14 15:19:45
【问题描述】:

如何正确调用 truffle 控制台中的合约函数?

使用 petshop 示例项目,我成功地将合约迁移到网络上。

在我执行的松露控制台中:

var ad = Adoption.deployed()

这会产生回复:

undefined

当我执行ad.adopt(23);采用为函数名,23为单位参数;我得到了异常TypeError: ad.getAdopters is not a function

我在调用函数时犯了什么错误?

谢谢!

【问题讨论】:

    标签: ethereum truffle


    【解决方案1】:

    Truffle 控制台内部

    ContractName.deployed().then(function(instance){app = instance})
    app.adopt(23)//call method on contract class
    

    在你的应用中试试这个。

    //from App.js
    App.contracts.SmartContractName.deployed().then(function(instance){
       return instance.adopt(23)//call method on contract class
    }).then(function(){
    
    }).catch(function(err){
       console.log(err);
    })
    

    【讨论】:

      猜你喜欢
      • 2018-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      • 2018-03-17
      • 2019-09-22
      • 1970-01-01
      • 2019-09-18
      相关资源
      最近更新 更多