如何正确调用 truffle 控制台中的合约函数?
使用 petshop 示例项目,我成功地将合约迁移到网络上。
在我执行的松露控制台中:
var ad = Adoption.deployed()
这产生了答复:
undefined
当我执行ad.adopt(23)
;采用为函数名,23为单位参数;我得到了例外TypeError: ad.getAdopters is not a function
我在调用该函数时犯了什么错误?
谢谢!
松露控制台内部
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);
})