-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sol
57 lines (46 loc) · 1.48 KB
/
test.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
pragma solidity ^0.4.19;
import "./ownable.sol";
contract test is Ownable{
uint index=1;
struct User{
uint ID;
string publickey;
string functiontoencode;
bool invaild;
}
mapping(uint => User) users;
mapping(uint => address) idtoaddress;
mapping(address =>uint) addresstoid;
function showuser(uint _id)public view returns(string c,string d){
User memory user = users[_id];
require (user.invaild);
return (user.publickey,user.functiontoencode);
}
function createuser(string _key,string encode) public {
users[index]=(User(index,_key,encode,false));
idtoaddress[index]=msg.sender;
addresstoid[msg.sender]=index++;
}
function confirm(uint _id) public onlyOwner{
User storage user=users[_id];
user.invaild=true;
}
function changepublickey(uint _id,string _key) public{
require(msg.sender==idtoaddress[_id]);
User storage user = users[_id];
user.publickey=_key;
}
function deleteuser(uint _id) public{
require(msg.sender==idtoaddress[_id]);
User storage user=users[_id];
user.ID=0;
user.publickey="";
user.functiontoencode="";
user.invaild=false;
idtoaddress[_id]=address(0);
addresstoid[msg.sender]=0;
}
function kill() public onlyOwner(){
selfdestruct(owner);
}
}