0

I have the function:

    contract TaskContract {

      function deleteTask(uint256 taskId, bool isDeleted) external {
            if (taskToOwner[taskId] == msg.sender) {
                tasks[taskId].isDeleted = isDeleted;
                emit DeleteTask(taskId, isDeleted);
          }
    }

My question:

Is it possible to add a contract owner here so that he can also delete tasks along with mapped users.

1 Answer 1

0

You can try:

contract TestContract {

     address owner;

     constructor() {
         owner = msg.sender;
     }

     function deleteTask(uint256 taskId, bool isDeleted) external {
          if (taskToOwner[taskId] == msg.sender || msg.sender == owner) {
              tasks[taskId].isDeleted = isDeleted;
              emit DeleteTask(taskId, isDeleted);
          }
     }
 }

This also checks if the msg.sender is also the owner of the contract, if so, he can also delete tasks along with mapped users.

2
  • Checked. Still nothing..
    – kapitankot
    Commented Nov 28, 2022 at 8:32
  • What i want to achieve here is to call that function from another smart contract that mapped user created. Any ideas ?
    – kapitankot
    Commented Dec 2, 2022 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.