-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainfile.sol
160 lines (139 loc) · 4.79 KB
/
mainfile.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
pragma solidity 0.5.1;
import "./projecttest.sol";
contract Mycont{
person[] public people;
parties_record[] public information;
//afterpurchace_record[] public human_1;
uint public peoplecount;
//uint public selltoken;
uint public buytoken;
//uint256 public number_of_item;
mapping(address=>uint) public number_of_item;
mapping(address=>uint) public bought_item;
mapping(address=>string) public name_of_item;
address bazzarmaintainer;
address InpartyA;
address InpartyB;
address InpartyC;
address CpartyA;
address CpartyB;
address CpartyC;
address Currentcontractaddress;
//address payable wallet;
address public lastbuyer;
//uint selltoken;
constructor(address partyA,address partyB,address partyC) public {
bazzarmaintainer=msg.sender;
InpartyA=partyA;
InpartyB=partyB;
InpartyC=partyC;
Currentcontractaddress=address(this);
}
struct person{
string first_name;
string last_name;
uint256 id;
}
struct parties_record {
uint number_of_item_party_having;
string name_of_item_party_having;
}
struct transaction_record {
uint numbers_of_items_exchange;
string name_of_item_exchange;
}
mapping(uint => transaction_record[]) public transpartyA;
mapping(uint => transaction_record[]) public transpartyB;
mapping(uint => transaction_record[]) public transpartyC;
/*
struct afterpurchace_record{
uint valu1;
string valu2;
}
*/
function addperson(string memory _firstname,string memory _lastname,uint256 val,uint val1,string memory itemname) public {
if (msg.sender == InpartyA) {
people.push(person(_firstname,_lastname,val));
/* struct data{
uint value1;
string value2;
}*/
number_of_item[InpartyA]=items.itemA(val1);
//number2_of_item[InpartyA]=items.itemA(val1);
name_of_item[InpartyA]=items.itemB(itemname);
information.push(parties_record(number_of_item[InpartyA],name_of_item[InpartyA]));
peoplecount++;
}
if(msg.sender==InpartyB){
people.push(person(_firstname,_lastname,val));
/* struct data{
uint value1;
string value2;
}*/
number_of_item[InpartyB]=items.itemA(val1);
//number2_of_item[InpartyB]=items.itemA(val1);
name_of_item[InpartyB]=items.itemB(itemname);
information.push(parties_record(number_of_item[InpartyB],name_of_item[InpartyB]));
peoplecount++;
}
if(msg.sender==InpartyC){
people.push(person(_firstname,_lastname,val));
number_of_item[InpartyC]=items.itemA(val1);
//number2_of_item[InpartyC]=items.itemA(val1);
name_of_item[InpartyC]=items.itemB(itemname);
information.push(parties_record(number_of_item[InpartyC],name_of_item[InpartyC]));
peoplecount++;}
return;
}
function buynsell(address payable _To,uint _transid,uint _ibuy,string memory _name) payable public {
require(peoplecount>=2);
if(msg.sender == InpartyA){
if(_To==InpartyC && number_of_item[InpartyC] >= _ibuy){
transpartyA[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
if(_To==InpartyB && number_of_item[InpartyB] > _ibuy){
transpartyA[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
}
if(msg.sender == InpartyB){
if(_To==InpartyC && number_of_item[InpartyC] > _ibuy){
transpartyB[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
if(_To==InpartyA && number_of_item[InpartyA] > _ibuy){
transpartyB[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
}
if(msg.sender == InpartyC){
if(_To == InpartyB && number_of_item[InpartyB]>_ibuy){
transpartyC[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
if(_To==InpartyA && number_of_item[InpartyA] > _ibuy){
transpartyC[_transid].push(transaction_record(_ibuy,_name));
_To.transfer(msg.value);
number_of_item[_To] = number_of_item[_To] - _ibuy;
bought_item[msg.sender]=bought_item[msg.sender] +_ibuy;
buytoken+=_ibuy;
}
}
}
}