-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass 1.txt
403 lines (199 loc) · 7.59 KB
/
class 1.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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
Immutable --> Once data is inserted into the ledger, it cant be modified
normal --> insert username, age, department into employee table (Create, Read, Update, Delete)
blockchain --> we can only insert data. update and delete is not possble.
Consensus --> Establishment of agreement among multiple nodes in the system
crypto exchange --> similar to normal exchnages, we trade digital coins (eth, sol, pol)
IOTA --> Framework for IOT use case implementation (device - device communication secured on the ledger)
public vs private blockchains:
-------------------------------
public --> involves crypto, high txn fees, data is visible to everyone
private --> hyperledger (elimintaes crypto tokens, high tx fee)
(bank of 6 in a single network) ---> private blockchain ---> decentalized
Banks want to form a Credit history of account holders (Credit Ledger) --->
Use case: Credit ledger
Problem statement: Banks takes long turn around time to sanction loans and also depend on third party aganecies for cibil score (3-5 business days)
Solution approach:
Banks will coordinate among them self to ditribute each others data on the status of active loans/inactive/high credit users
write a smart contract by building these logics
customer id, crdit score indicator, eligible
Smart contract:
----------------
variables/identifiers to be shared/stored on the ledger
private data collections (current loan amount, no of emi due)
public
var
( username
customer id
credit indicator
eligible status )
methods
queryCreditdata()
eligiCriteria()
Loanstatus()
tranactions between two different blockchain networks ----> Interoperability
public blockchains ---> Oracles and Bridges
private blockchains ---> solution (bridges that enable data transfer b/w multiple networks)
network 1 ----- 6 banks
Intermediate network (even the bridges are to be truly distributed) --- ??
network 2 ----- 4 Insurance firms (claim verification)
Node is nothing but a server/machine/system --> which validtaes and records the data
HYperledger Cactus ---> Interoperability issues
Node ---- Machine
Ledger --- File system in the machine
Block --- part of this file system in the machine
multiple blocks will form the ledger
https://lms.simplilearn.com/
Money transfer b/w Banks:
--------------------------
1. Bank1 -- sender bank
2. Bank2 -- receiver bank
Banks employ a regulator/intermediatary which establishes the trust among them
bank1 --> 1000 CR
Intermediatary ----> which have some funds as collateral stored for all banks (bank have to deploy a minimum guarantee fee of 5000 CR)
(1000 cr, bank1, bank2)
(5000 cr)
bank2 --> 1000 CR (bankruptcy)
Data structure of a block:
--------------------------
type Block
{
Header
var current hash string
var previous hash string
var timestamp timestamp
var block number int
Body
transactions [] string
chain *Block
}
Sequence of such blocks linked by previous hash forms blockchain
Linked List of blocks appended to each other by Hashes
Public Blockchain:
Bitcoin ---> used as only crypto token, no entreprises can build appications on top of bitcoin(lacks the feature of smart contracts)
Ethereum --> which is an alternative for bitcoin, which also supports the business logic to embed into the network(smart contract) and they can create, control and manage the entire asset lifcycles
(users have to pay txn fee in form of crypto token (ETH))
Private Blockchain:
HYperledger ---> Linux and IBM initiative
(eliminates the need for crypto tokens, txn fee)
(code is open source, smart contract)
R3 Corda
IOTA
Multichain
Merkle Hash:
Block can either have 1 transaction or multiple transactions
blocks are created ----> either for specific period or specific size
(100 txn) or 1 MB size (25 txn)
block1 ---> 100
block2 ---> 50
block3 ----> 75
Banks 5
-------------
Bank1 ---> [b1 b2 b3 b4 b5]
Bank2 ---> [b1 b2 b3 b4 b5] ---> goes down
smart contract will produce same result for a transaction for all the nodes in the network
100 tnx ----> 50 txn ----> 5-10 min ---> staled network
txn size (or) no of txn (or) time period
block1 ---> 10 txn {t1 t2 t3 t4 ---- t10}
---> creates a merkle hash/root hash ---> ABC12345678910
any node in the network wishes to validate if a block is created correctly
input -- {t1 t2 t3 t4 ---- t10}
CreateBlock(input) (output)
{
createhash = logic ({t1 t2 t3 t4 ---- t10})
storehash = ABC12345678910
}
user1 ----> user2 (balance transfer of 100 USD)
node has a smart contract ---> validates balance of user1 (>100 usd)
t1--> b1 ---> Chain
Enterprise use cases:
----------------------
Onboarding process will happen. Banks will give out their certifictaes, ip adrress, port, dns names
banks which are part of this onboarding process will only accept the traffic
network {
cert, ip, port, dns
}
Token is a digital asset created and managed on the blockchain by emebding functions in a smart contract
Babks wish to create a digital token (CBDC)
type Token struct {
Token name string
Token supply int
owner string
expiry date date
walletid string
bankname string
}
type Itoken Interface {
create()
transfer()
checkbalance()
burn()
}
ERC20 ---> Fungible Tokens (digital currency)
CBDC ---> INR
(token serialnumber 123 = token serialnumber 456)
ERC721 ---> Non Fungible tokens (digital assets)
token for land registry
type Land struct {
Land token id
Land cordinates
Locality
Area
sqft
price
purchased date
owner
Status
}
type Iland interface {
create()
transfer()
checkownership()
}
land1 ---> serail number 111 ---> 3 CR
land2 ---> serial number 222 ---> 5 CR
Database:
------------
1 usera - balance - 100 USD
txn (usera, 100)
Update operation is performed on the existing data record in the database
1 useraa - balance - 150 USD
Blockchain:
-------------
1 usera - balance - 100 USD
txn (usera, 100) -- credit txn
-- debit txn (50)
insert operation is performed on the existing data record in the database
1 usera - balance - 100 USD cr
1 usera - balance - 100 USD cr
1 usera - balance - 50 USD db
Token is an object
Transaction is an action on tht object (credit, debit, getbalance)
ledger -----> log files/encrypted ---> hashes
token:
land id 123
cord 24 26
ownnership user A ---> old record
usera--->userb
land id 123
cord 24 26
ownsehrip user b ---> new entry record
smartcontract ----> getallhistiry(123)
---->it gives 2 reords as output
userA --- old
userB --- new
blocks ---> txn details --->
Use Case discussion:
-------------------------
Big Bazar and Reliance merger
a. convert credit card reward points to Big bazar coupons
b. users were also purchasing coupons from retail stores
c. other ways
all of these coupons were invalidated/went in vain
on an avg 100 users ----> 2000 INR ---> 2 Lacs on coupons which went wasted
Reliance ----> reward scheme went in vain
blockchian based reward base system:
-------------------------------------
query the token id from ledger and validated it status
Reward based systems
Online aucion systems
NFT market places