【发布时间】:2020-07-16 21:36:07
【问题描述】:
我正在尝试按照教程 here 学习如何编写 dapp。我把这个 .sol 代码放在一起(好吧,复制/粘贴...):
pragma solidity ^0.5.0;
contract Adoption {
address[16] public adopters;
}
// Adopting a pet
function adopt(uint petId) public returns (uint) {
require(petId >= 0 && petId <= 15);
adopters[petId] = msg.sender;
return petId;
}
// Retrieving the adopters
function getAdopters() public view returns (address[16] memory) {
return adopters;
}
并且已经存在另一个文件。当我运行 truffle compile 命令时,我看到以下内容:
ParserError: Expected pragma, import directive or contract/interface/library definition.
function adopt(uint petId) public returns (uint) {
^------^
Compilation failed. See above.
Truffle v5.1.34 (core: 5.1.34)
Node v12.18.2
知道我可能缺少什么吗?
【问题讨论】: