-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContract.sol
67 lines (53 loc) · 1.43 KB
/
Contract.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
pragma solidity ^0.8.7;
import "hardhat/console.sol";
contract Contract {
// address owner;
struct manufactureObj {
uint prod_id;
string prod_name;
uint quantity;
}
struct transportObj {
uint transport_id;
string name;
bool verify;
}
struct retailerObj {
uint retail_id;
string name;
bool verify;
}
mapping (string => manufactureObj) manufactureArr;
mapping (string => transportObj) customerArr;
mapping (string => retailerObj) retailerArr;
function createProd(uint _prod_id, string memory _prod_name, uint _quantity) public payable returns (uint) {
manufactureObj memory newProd;
newProd.prod_id = _prod_id;
newProd.prod_name = _prod_name;
newProd.quantity = _quantity;
return 1;
}
function verifyRetail(bool _verify) public pure returns (bool) {
if(_verify = true) {
return true;
} else {
return false;
}
}
function verifyTransport(bool _verify) public pure returns (bool) {
if(_verify = true) {
return true;
} else {
return false;
}
}
function stringToBytes32(string memory source) internal pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
}