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
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;
}
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.
-
yes student will call a function to update transaction. Can you please write its code with two attributes name and id Jan 11 at 17:19
-
No, i can't do your assignment for you, and you shouldn't really ask for that, actually.– FoxxxeyJan 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.– FoxxxeyJan 11 at 18:38