1
我编译和部署下列合同,合同testrpc功能:不能调用松露控制台
pragma solidity ^0.4.4;
contract Adoption {
address[] public adopters;
function adopt(uint petId) public returns (uint) {
require(petId >= 0 && petId <= 15);
adopters[petId] = msg.sender;
return petId;
}
}
那我先去终端:
truffle compile
truffle migrate --reset
一切正常。然后,我打电话采用()的松露控制台:
truffle(development)> const adoption = Adoption.deployed()
// undefined
truffle(development)> adoption.adopt(1).then(console.log)
// TypeError: adoption.adopt is not a function
如果我尝试:
truffle(development)> Adoption.deployed()
.then((instance) => {instance.adopt(1)})
.then(console.log)
// Error: VM Exception while processing transaction: invalid opcode
什么是错我的做法?我怎样才能打电话给采用()?