2017-09-14 9 views
0

트러 플 콘솔에서 계약 함수를 올바르게 호출하려면 어떻게해야합니까?트러 플 콘솔에서 함수 호출하기

petshop 예제 프로젝트를 사용하여 계약서를 네트워크로 성공적으로 마이그레이션했습니다. 송로 버섯 콘솔에서

는 I 실행 :이 응답 산출

var ad = Adoption.deployed() 

:

undefined 

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