2017-09-14 59 views
0

如何正确调用松露控制台中的合同功能?松露控制台调用函数错误

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

在松露控制台I执行:

var ad = Adoption.deployed() 

这产生的答复:

undefined 

当我执行ad.adopt(23);采用为函数名和23为单位参数;我得到的例外TypeError: ad.getAdopters is not a function

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

谢谢!

回答

1

里面松露控制台

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); 
})