-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathopensign.sol
More file actions
27 lines (23 loc) · 919 Bytes
/
opensign.sol
File metadata and controls
27 lines (23 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pragma solidity ^0.4.17;
contract OpenSign{
struct Document {
uint timestamp;
bytes ipfs_hash;
address[] signatures;
}
mapping(address => bytes[]) public users; //maps addresses to agreement id
mapping(bytes32 => Document) public documents; //maps keccak256(agreement_id) hashes to documents
function addDocument(bytes id, bytes ipfs) public {
users[msg.sender].push(ipfs); //Add document to users's "signed" list
address[] memory sender = new address[](1);
sender[0] = msg.sender;
documents[keccak256(id)] = Document(block.timestamp, ipfs, sender);
}
function signDocument(bytes id) public {
users[msg.sender].push(id);
documents[keccak256(id)].signatures.push(msg.sender);
}
function getSignatures(bytes id) public view returns (address[]) {
return documents[keccak256(id)].signatures;
}
}