-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAcceptable.sol
23 lines (19 loc) · 1.05 KB
/
Acceptable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import "HasTerms.sol";
// A simple abstract way of handling acceptance for a Ricardian contract
//
// - Parties accept the contract by calling the `accept()` function providing the same ipfs hash
// - This is recorded as an acceptance of the contract by the msg.sender
// - The contract author can mark functions as hasAccepted, which means that they are only allowed to be used by parties who have accepted the agreement
// - An event `TermsAccepted` is emitted with the party's address and the current ipfs hash
// To force parties to accept the new agreement, a modifier `hasAcceptedLatest` can be used on functions
contract Acceptable is HasTerms {
mapping(address => uint) public accepted;
modifier hasAccepted() { if (accepted[msg.sender] > 0) _ }
modifier hasAcceptedLatest() { if (accepted[msg.sender] >= lastChange) _ }
// Party accepts contract by presenting the hash that they are accepting
function accept(bytes32 _terms)
matchesTerms(_terms) {
accepted[msg.sender] = block.timestamp;
TermsAccepted(msg.sender, terms);
}
}