0

i want to develop a contract student in which student sign a transaction to update its record and owner would be able to approve or disapprove this transaction how would I able to do this.

2 Answers 2

0

A sketch:

mapping(address=> bool) students;
mapping(uint256 => bool) isTransactionApproved;

modifier onlyStudent {
 require(students[msg.sender] === true, 'Only students');
_;
}

function approveTransaction(uint256 id) external onlyStudent {
 isTransactionApproved[id] = true;
}
0

Have the student submit all the modifications they want to do in a transaction, store them somewhere in a pendingModifications array or something like that, idk. And have a function for the owner so they can approve/reject the changes, clearing the pending array and potentially modifiying the data.

3
  • yes student will call a function to update transaction. Can you please write its code with two attributes name and id
    – Saira Rao
    Jan 11 at 17:19
  • No, i can't do your assignment for you, and you shouldn't really ask for that, actually.
    – Foxxxey
    Jan 11 at 18:21
  • @SairaRao Note that this queue/approve pattern is used in other smart contracts, like timelocks or multisigs. You can take a look in that direction if you want.
    – Foxxxey
    Jan 11 at 18:38

Your Answer

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

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