-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass 10.txt
321 lines (199 loc) · 6.89 KB
/
class 10.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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
Reference links:
----------------
https://github.com/blockchaintraining90/batch4
https://bitcoinsv.com/scrypt/
https://bitcoin.org/bitcoin.pdf
https://ethereum.org/en/
https://www.openzeppelin.com/
https://ethereum.github.io/yellowpaper/paper.pdf
https://www.tutorialspoint.com/solidity/index.htm
https://docs.ethers.org/v5/
https://web3js.readthedocs.io/en/v1.8.1/
https://hyperledger-fabric.readthedocs.io/en/release-2.5/
https://www.youtube.com/c/Hyperledger
https://github.com/hyperledger/fabric-samples
https://docs.r3.com/
https://www.tutorialspoint.com/nodejs/index.htm
makes use of promises to handle async calls
1. getUsername
2. CreateTxn
3. Read from DB
req --> 1
createTxn --> 2
Read from DB --> 3
1....> done...> promose is resolved
..2...(txn and not submited)...> start
....1....> compltes
....2.... --> create txn...> ...promise is rejected
....3....> read DB (http, usern pwd) ... completed/failed
...3....> done
Chaincodes ----> shoudnt be too complex and holds only business logic
servers / handling multiple req ---> client/server applications (restful services)
clinets ---> restful servcies ---> fabric-network --> chaincodes/smartcontracts
write a program to create file and store identity details:
---------------------------------------------------------
var fs = require('fs')
fs.createfile(home/ubuntu/simplielear/hyperledger/fabric/identity/cert)
fs.wrirefile(__dirname + "jkjhfkj")
delete file
apped file
REST APIs:
---------
1. GET -- read from server
2. PUT -- write data into server
3. DELETE -- wipe data from server
4. POST -- write/override existing data on server
express framework it proves easy way of managaing these methods
var express = require('express')
var app = express();
var port = 5000;
app.get('/',function (request, response) {
response.send('Hello World')
})
var server = app.listen(port, function() {
var host = server.address().address
var port = server.addresss().port
console.log("server running on port")
});
Corda:
-------
Flows: Represent entire work flow for a transaction to complete
usra - usrb ---> 100 USD
1. Initiate a txn from usra
2. Debit funds from usra (smart contract)
3. transfer funds from usra to usrb (smart contract)
4. credit funds to usrb (smart contract)
5. terminate the txn
Validity consensus:
-------------------
usera - current balance --> 100
usera --> 100 ---> userb
txn --- { txnid, digcert, pubK, hash)
smartc func validate txn (txnid, digcert, publickey, hash)
it validates the digital sign/certificates
usera ---> 100 ---> userc
Uniqueness consensus:
---------------------
1) notary -----> which has visibilty on all ledgers of the network
notary: (1,2,3,4,5,6,7,8,9) ---- central componentin corda
------
2 txn from same user with diff ledger ---> invalid 1 txn
ledger1 ---(a,b) ---(1,2,3)
ledger2 ---(a,c) ---(4,5,6)
ledger3 ----(b,c) --- (7,8,9)
type BlockStruct{
Header: string[]
Body:
txn string []
hash string []
}
type TxnStruct {
TxnPrevHash []
TxnCurrHash []
}
txn1 ----- node1 to node2
[ node1 --- 100.201.161.141
node2 --- 100.201.161.151
node --- 100.202.143.123
]
Reference links:
----------------
https://github.com/blockchaintraining90/batch4
Blockchain Use cases:
---------------------
1. Finance --- Initial Public Offering
2. Insurance --- Insurance (claim/reinsurance/reinstatement)
3. Loyalty --- Loyalty rewards
IPO:
----
Company ABC wants to raise funds and goes to public
1. Due dilegence and auditing from Big4 audit firms to ABC --> DB
2. ABC will issue X crore amount (100 Crore), share value of 100/unit --> DB
3. ABC will approach Security Boards (governing authorities) -- (logic of allotment)
4. Log this entru details as valid in their DB
5. ABC company can contact channels/brokers (zerodha/groww/upi) etc
6. channels/brokers can enroll/opt/bid for the shares
7. Mandate wil be created per customer and amount gets locked/debited from account
8. Based on the subsrciption the share are distributed to all customers (oversubscribed/under subscribed)
9. Refund/partial refund
10. share allocation/allotment
100 units of ABC, 100 * 100 = 10000 INR
oversubscribed
100 units ---> 75 units are allocated and rest 25 units will be refunded
painful process --> Long and time taking, reconcilation of data at every step
Blockchain platform:
--------------------
PCI/DSS standards ---> advicable
Gas fee/txn fee ---> eth/polygon
Hyperledger Fabric --->
Configtx.yaml:
--------------
Orgs:
----
1. ABC - Peer0.org1
2. Audit Firm - Pee0.org2
3. Broker app - Peer0.org3
4. Security - peer0.org4
smartcontract:
-------------
1. creation of request
2. allocation of shares ---> outside blockchain (SEBI)
3. refund details
4. txn status
allocation smartcontract -- blockchain
Ordering service:
-----------------
1. Security Board -- order0.order
Consensus: etcdraft
ledger: /var/production/hyperledger/fabric/ledger/IPO/details
txn1 {user1,userid,shares req:100,amt blocked: 10000, date of req: 12 dec 22} ----> Invoke chaincode function - creation of request --org4 -- 12th dec
txn1 {user1,userid,shares req:100,shares allocated 75,refund sahres:25} ---> allocation 19th dec
txn1 {user1,userid,shares req:100,shares allocated 75,refund sahres:25,ref amt 2500,refund date: 19 dec 22} --- refund function
txn1 --valid and refund completed
MSP:
----
org1MSP
cert
pubK
priK
channel: IPOChannel
Endorsement POlicy:
-------------------
(('ORG1MSP' OR 'ORG3MSP') AND ('ORG4MSP'))
Chaincode: ipoallocation_chaincode
location: /var/production/chaincode/ipo/ipoallocation.tar.gz
Benefits:
---------
1. near realtime refunds
2. reconcilation process reduced
3. better turn around times
If we implement ERC20 for this use case: Tokenization
----------------------------------------
1. ABC -- 100 CRORE
100 CRORE - ERC20 -- 100 CRORE ERC20 TOKENS
ERC20
{
token name -- ABC Token
supply --- 100 crore
ownership --- ABC
date of cretion -- 12 dec
}
75 units ---> diff serial numbers ---> (user1+custid+1
jagdish12345001 to jagdish12345075 )
proof of ownership:
jagdush12345050 ---> call smart contract function ---> track ownership --- func (tokenserial, name)
owner --- jagdish)
Lolayty rewards:
----------------
jetairways ---> 15000 milepoints
airindia ---> 20000
indigo
xyz
DGCA ---> Civil aviation: jet,air,indigo xyz
-------------------------
airindia ----> 30000 , 35000 -----> 5000 mile balance
bank of india, bank of singapore, bank of taiwan, JPMC, ABC corp Ltd ---> Corda
Corda -- java/kotlin
Fabric -- java/javascript/go
ETH/POLYGON -- solidity
Solana -- rust