【发布时间】:2021-07-28 11:34:01
【问题描述】:
我正在深入探索以太坊和智能合约的开发。在一个简单的 todo 应用程序智能合约中,我收到以下错误:
我的代码:
pragma solidity ^0.4.4;
contract ToDo {
struct Task{
uint id;
uint date;
string content;
string author;
bool completed;
}
Task[] tasks;
function createTask(string memory _content, string memory _author) public {
tasks.push(Task(tasks.length, block.timestamp, _content, _author, false));
}
function getTask(uint id) public view
returns(
uint,
uint,
string memory,
string memory,
bool
) {
return(
id,
tasks[id].date,
tasks[id].content,
tasks[id].author,
tasks[id].completed
);
}
function getAllTasks() external view returns(Task[]){
return tasks;
}
}
错误行是 20 和 21 在尝试返回字符串的 getTask() 函数中。
【问题讨论】:
标签: blockchain ethereum solidity smartcontracts