xxxxxxxxxx
//This is real life smart contract function which contains tasks array of struct
//taskToOwner container to map taskId with msg.sender.and AddTask event.
//We all use function in addTask function
contract TaskContract{
//COMMENT EVENTS
event AddTask(address recipient,uint taskId);
//COMMENT Task structure
struct Task{
uint id;
string taskText;
bool isDeleted;
}
//COMMENT create array name tasks with struct Task
Task[] private tasks;
//COMMENT mapping in taskToOwner with key value pair of taskid with owner address
mapping(uint256 => address) taskToOwner;
//COMMENT Contract function
function addTask(string memory taskText, bool isDeleted) external {
uint taskId = tasks.length;
tasks.push(Task(taskId,taskText,isDeleted));
taskToOwner[taskId]=msg.sender;
emit AddTask(msg.sender,taskId);
}
}
xxxxxxxxxx
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.0 <0.7.0;
contract SimpleStorage {
uint storedData;
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint) {
return storedData;
}
}