Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
solidterms/contracts/Acceptable.sol
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (19 sloc)
1.05 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |