-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.txt
94 lines (76 loc) · 7.05 KB
/
test.txt
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
Accounts:
/* Be sure to copy the addresses for A‐G from your own Ganache addresses at the beginning and throughout this file.
If you use a text editor, you can do a Find and Replace to speed up this step.
*/
A‐0: 0xb255163f45487210032CD425D0566442e9a4BFF7
B‐1: 0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1
C‐2: 0xb4a55D26248BA0CDfCf11Df35db32E8f59168101
D‐3: 0x9913ce5427c0e25458f4F314D1B75cE1F2159599
E‐4: 0x3ef364ad9cB407994324bc805eca033F9544beD7
F‐5: 0xCD7a183f60831eaCfe2A1166Fc660B35bd261ae0
G‐6: 0x95FA04553Bb925130A570e90A5aD8414E5B0c2D6
supplyChain.deployed().then(function(instance) {return instance });
// Create 3 manufacturer participants (A, B, C)
supplyChain.deployed().then(function(instance) {return instance.addParticipant("A","passA","0xb255163f45487210032CD425D0566442e9a4BFF7","Manufacturer") });
supplyChain.deployed().then(function(instance) {return instance.addParticipant("B","passB","0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1","Manufacturer") });
supplyChain.deployed().then(function(instance) {return instance.addParticipant("C","passC","0xb4a55D26248BA0CDfCf11Df35db32E8f59168101","Manufacturer") });
// Create 2 supplier participants (D, E)
supplyChain.deployed().then(function(instance) {return instance.addParticipant("D","passD","0x9913ce5427c0e25458f4F314D1B75cE1F2159599","Supplier") });
supplyChain.deployed().then(function(instance) {return instance.addParticipant("E","passE","0x3ef364ad9cB407994324bc805eca033F9544beD7","Supplier") });
// Create 2 consumer participants (F, G)
supplyChain.deployed().then(function(instance) {return instance.addParticipant("F","passF","0xCD7a183f60831eaCfe2A1166Fc660B35bd261ae0","Consumer") });
supplyChain.deployed().then(function(instance) {return instance.addParticipant("G","passG","0x95FA04553Bb925130A570e90A5aD8414E5B0c2D6","Consumer") });
// Get participant details
supplyChain.deployed().then(function(instance) {return instance.getParticipant(0)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(1)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(2)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(3)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(4)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(5)});
supplyChain.deployed().then(function(instance) {return instance.getParticipant(6)});
// Create 6 products 100, 101 (owned by A), 200, 201 (owned by B), 300, 301 (owned C)
supplyChain.deployed().then(function(instance) {return instance.addProduct(0, "ABC", "100", "123", 11) });
supplyChain.deployed().then(function(instance) {return instance.addProduct(0, "DEF", "101", "456", 12) });
supplyChain.deployed().then(function(instance) {return instance.addProduct(1, "GHI", "200", "789", 13, {from: "0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1"}) });
supplyChain.deployed().then(function(instance) {return instance.addProduct(1, "JKL", "201", "135", 14, {from: "0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1"}) });
supplyChain.deployed().then(function(instance) {return instance.addProduct(2, "MNO", "300", "357", 15, {from: "0xb4a55D26248BA0CDfCf11Df35db32E8f59168101"}) });
supplyChain.deployed().then(function(instance) {return instance.addProduct(2, "PQR", "301", "759", 16, {from: "0xb4a55D26248BA0CDfCf11Df35db32E8f59168101"}) });
// Get product details
supplyChain.deployed().then(function(instance) {return instance.getProduct(0) });
supplyChain.deployed().then(function(instance) {return instance.getProduct(1) });
supplyChain.deployed().then(function(instance) {return instance.getProduct(2) });
supplyChain.deployed().then(function(instance) {return instance.getProduct(3) });
supplyChain.deployed().then(function(instance) {return instance.getProduct(4) });
supplyChain.deployed().then(function(instance) {return instance.getProduct(5) });
// Move products along supply chain: Manufacturer=> Supplier=> Supplier=> Consumer
supplyChain.deployed().then(function(instance) {return instance.newOwner(0, 3, 0, {from: "0xb255163f45487210032CD425D0566442e9a4BFF7"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(1, 3, 3, {from: "0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(2, 3, 4, {from: "0xb4a55D26248BA0CDfCf11Df35db32E8f59168101"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(0, 3, 1, {from: "0xb255163f45487210032CD425D0566442e9a4BFF7"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(2, 4, 5, {from: "0xb4a55D26248BA0CDfCf11Df35db32E8f59168101"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(1, 4, 2, {from: "0xa5426330db21Adb88A037c3B6B9A4ed2c7d4a2F1"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(3, 6, 4, {from: "0x9913ce5427c0e25458f4F314D1B75cE1F2159599"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(3, 4, 1, {from: "0x9913ce5427c0e25458f4F314D1B75cE1F2159599"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(3, 4, 3, {from: "0x9913ce5427c0e25458f4F314D1B75cE1F2159599"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(4, 5, 2, {from: "0x3ef364ad9cB407994324bc805eca033F9544beD7"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(3, 4, 0, {from: "0x9913ce5427c0e25458f4F314D1B75cE1F2159599"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(4, 6, 0, {from: "0x3ef364ad9cB407994324bc805eca033F9544beD7"}) });
supplyChain.deployed().then(function(instance) {return instance.newOwner(4, 5, 3, {from: "0x3ef364ad9cB407994324bc805eca033F9544beD7"}) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(0) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(1) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(2) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(3) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(4) });
supplyChain.deployed().then(function(instance) {return instance.getProvenance(5) });
//
//
//
function addParticipant(string name, string pass, address pAdd, string pType) public returns (uint)
function getParticipant(uint p_id) public view returns (string,address,string)
function addProduct(uint own_id, string modelNumber, string partNumber, string serialNumber, uint productCost) public returns (uint)
function getProduct(uint prod_id) public view returns (string,string,string,uint,address,uint)
function newOwner(uint user1_id ,uint user2_id, uint prod_id) onlyOwner(prod_id) public returns(bool)
/* function getProductRegistrationHistory(uint prod_id) public returns (registration[]) */
function getOwnership(uint reg_id) public view returns (uint,uint,address,uint)
/* function getRegistraionList(uint prod_id) public returns (uint) */
function authenticateParticipant(uint uid ,string uname ,string pass ,string utype) public view returns (bool)