-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArtCertificatel.sol
199 lines (177 loc) · 6.17 KB
/
ArtCertificatel.sol
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
pragma solidity ^0.4.10;
/*
* Artgallery
/\__/\
/` '\
=== 0 0 ===
\ -- /
/ \
/ \
| |
\ || || /
\_oo__oo_/#######o
*/
contract ArtGallery{
/*ownable : begin contract */
/*Public variables*/
address public owner;
uint public LastChangeOfOwnership;
/*events for log*/
event ChangeOfOwnership(address newOwner);
/*construtor*/
function ArtGallery() {
owner = msg.sender;
}
/* modifiers*/
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
/*methods*/
function transferOwnership(address _newOwner) onlyOwner {
if (_newOwner != address(0)) {
owner = _newOwner;
ChangeOfOwnership(owner);
LastChangeOfOwnership = block.timestamp;
}
}
/*ownable : end contract */
/*Public variables*/
address public Gallery = this;
mapping ( bytes32 => address) public ArtList;
/* the mapping maps an identifier (bytes32) to an address.
Use sha3 for identifier ex:
"numéro de série: 0001; date de fabrication: 09082016;Lieu de fabrication: 75017PARIS"
sha3(00010908201675017PARIS)=
15905d14d04be568d5e263a664721065a484ffe9c94b474947d601468b2ea744
We then deploy a contract ArtCertificate for that identifier and log the address*/
/*events for log*/
event ArtAdded(bytes32 identifier, address ArtCertificateAddress, string description);
event ArtChanged(bytes32 identifier, address ArtCertificateAddress, string description);
/*methods*/
function addArt(
bytes32 _identifier,
string _ArtistName,
string _ArtWorkTitle,
string _Description,
string _ArtWorkDate,
string _IPFSmetadata, //need checksum for IPFS hash
address _newOwner
)
onlyOwner() {
/* verify if the identifier is not already mapped */
if (ArtList[_identifier] != 0x0){throw;}
address _newArtCertificate = new ArtCertificate(
Gallery,
_identifier,
_ArtistName,
_ArtWorkTitle,
_Description,
_ArtWorkDate,
_IPFSmetadata,
_newOwner
);
ArtList[_identifier] = _newArtCertificate;
ArtAdded(_identifier, _newArtCertificate, _Description);
}
function changeArt(
bytes32 _identifier,
string _ArtistName,
string _ArtWorkTitle,
string _Description,
string _ArtWorkDate,
string _IPFSmetadata,
address _newOwner
)
onlyOwner() {
/* verify if the identifier is not already mapped */
if (ArtList[_identifier] == 0x0){throw;}
address _newArtCertificate = new ArtCertificate(
Gallery,
_identifier,
_ArtistName,
_ArtWorkTitle,
_Description,
_ArtWorkDate,
_IPFSmetadata,
_newOwner
);
ArtList[_identifier] = _newArtCertificate;
ArtChanged(_identifier, _newArtCertificate, _Description);
}
}
/*
* ArtCertificate
/\__/\
/` '\
=== 0 0 ===
\ -- /
/ \
/ \
| |
\ || || /
\_oo__oo_/#######o
*/
contract ArtCertificate {
/*ownable : begin contract */
/*Public variables*/
address public owner;
uint public LastChangeOfOwnership;
/*events for log*/
event ChangeOfOwnership(address newOwner);
/* modifiers*/
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
/*methods*/
function transferOwnership(address _newOwner) onlyOwner {
if (_newOwner != address(0)) {
owner = _newOwner;
ChangeOfOwnership(owner);
LastChangeOfOwnership = block.timestamp;
}
}
/*ownable : end contract */
/*Public variables*/
address public CertificateOrigin;
bytes32 public identifier;
string public ArtistName;
string public ArtWorkTitle;
string public Description;
string public ArtWorkDate;
string public IPFSmetadata;
// string public number of copy;
// string public serial number;
/*events for log*/
event ChangeOfIPFSmetadata(string newIPFSmetadata);
/*construtor*/
function ArtCertificate(
address _ArtGallery,
bytes32 _identifier,
string _ArtistName,
string _ArtWorkTitle,
string _Description,
string _ArtWorkDate,
string _IPFSmetadata,
address _newOwner
){
CertificateOrigin = _ArtGallery;
identifier=_identifier;
ArtistName=_ArtistName;
ArtWorkTitle=_ArtWorkTitle;
Description=_Description;
ArtWorkDate=_ArtWorkDate;
IPFSmetadata=_IPFSmetadata;
owner = _newOwner;
}
/*methods*/
function changeIPFS(string _newIPFSmetadata) onlyOwner {
IPFSmetadata = _newIPFSmetadata;
ChangeOfIPFSmetadata(IPFSmetadata);
}
}