Тёмный

Blockchain Explained: Supply Chain Example with Python Tutorial 

SATSifaction
Подписаться 19 тыс.
Просмотров 11 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 25   
@theduck7356
@theduck7356 3 года назад
You are amazing man, I was looking for this for so many days.... thank you so much.
@Akashraviable
@Akashraviable 3 года назад
can you please share your github or code for the same video
@mcan543
@mcan543 4 года назад
Hello from a new subscriber. Most clear explenation of blockchain.
@tawanike
@tawanike 3 года назад
Thank you so much for this video. Well explained. Given the example you created, how can one add the Smart Contract execution to it using python. I have been looking for content on how to add Smart Contracts to a custom python based blockchain.
@1UniverseGames
@1UniverseGames 3 года назад
Sir is it possible to make a video about ways of making Privacy-enhancing of blockchain data implementation and design, or its proof of stake? it would be great to know this part of blockchain from your generous explanation.
@SATSifaction
@SATSifaction 3 года назад
Can you explain this in more detail when you mean privacy enhancing block chains? Block chains aren’t meant to be private persay, only secure and immutable. Blockchain like ETH and BTC have transactions available on the open web by design.
@justinfleagle
@justinfleagle 3 года назад
Thank you for this video. Very well done 👏
@alanmorante
@alanmorante 3 года назад
Great explanation!.. you should do a second part with smart contracts
@SATSifaction
@SATSifaction 3 года назад
Great suggestion
@codehart
@codehart 3 года назад
@@SATSifaction That would be awesome. Do you have the code btw? If not I might be able to type it out for others too. Thank you.
@Akashraviable
@Akashraviable 3 года назад
please can anyone share the github for the same code
@imranrajjad7028
@imranrajjad7028 3 года назад
from hashlib import sha256 import json from datetime import datetime class Block: def __init__(self, index, previous_hash, current_transactions, timestamp, nonce): self.index = index self.previous_hash = previous_hash self.current_transactions = current_transactions self.timestamp = timestamp self.nonce = nonce self.hash = self.compute_hash() def compute_hash(self): block_string = json.dumps(self.__dict__, sort_keys=True) first_hash = sha256(block_string.encode()).hexdigest() second_hash = sha256(first_hash.encode()).hexdigest() return second_hash def __str__(self): return str(self.__dict__) class BlockChain: def __init__(self): self.chain = [] self.transactions = [] self.genesis_block() def __str__(self): return str(self.__dict__) def genesis_block(self): genesis_block = Block('Genesis', 0x0, [3, 4, 5, 6, 7], 'datetime.now().timestamp()', 0) genesis_block.hash = genesis_block.compute_hash() self.chain.append(genesis_block.hash) self.transactions.append(str(genesis_block.__dict__)) def getLastBlock(self): return self.chain[-1] def proof_of_work(self, block: Block): difficulty = 1 block.nonce = 0 computed_hash = block.compute_hash() while not (computed_hash.endswith('0'*difficulty) and ('55'*difficulty) in computed_hash): block.nonce += 1 computed_hash = block.compute_hash() return computed_hash def add(self, data): block = Block(len(self.chain), self.chain[-1], data, 'datetime.now().timestamp()', 0) block.hash = self.proof_of_work(block) self.chain.append(block.hash) self.transactions.append(block.__dict__) return json.loads(str(block.__dict__).replace('\'', '\"')) def getTransactions(self, id): labels = ['Manufacturer', 'Transportation', 'Retailer'] while True: try: if id == 'all': for i in range(len(self.transactions)-1): print('{}: {} '.format(labels[i], self.transactions[i+1])) break elif type(id) == int: print(self.transactions[id]) break except Exception as e: print(e) def main(): manufacturer = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' } ] } transportation = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 100, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 101, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 102, 'message': 'Product damaged', 'digital signiture': 'retailer review', 'flagged': 'Y' } ] } retailer = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Retailer X', 'to': 'Retail Shelf', 'receiving_id': 400, 'message': 'This product is in good order, Received', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Retailer X', 'to': 'Retail Shelf', 'receiving_id': 400, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Retailer X', 'to': 'RTV', # Return to Vendor 'receiving_id': 401, 'message': 'Box Damaged', 'digital signiture': 'rejected', 'flagged': 'Y' } ] } B = BlockChain() a = B.add(manufacturer) b = B.add(transportation) c = B.add(retailer) B.getTransactions('all') if __name__ == '__main__': main()
@nitinkaushikofficial
@nitinkaushikofficial 2 года назад
Very well explained mate. This is one of the best videos I've come across. Is there any video on same implementation through smart contract i.e. transaction getting initiated through metamask or something or it's implementation of public/private/hybrid blockchain.
@maitreemeher2203
@maitreemeher2203 3 года назад
hey, this video was really helpful, thanks a lot. Could you also please link your code in the description?
@SATSifaction
@SATSifaction 3 года назад
hi its in the following article i wrote for the startup --> medium.com/swlh/blockchain-simplified-and-explained-79c5844e318f
@imranrajjad7028
@imranrajjad7028 3 года назад
@@SATSifaction is not
@lydiakipkorir4065
@lydiakipkorir4065 3 года назад
Thanks so much for making this.
@SATSifaction
@SATSifaction 2 года назад
You’re welcome. Thanks for watching. Please consider subscribing if you haven’t already
@iebstudent
@iebstudent 4 года назад
The while True: in getTransactions is absolutely unnecessary
@agnivdebsikdar8726
@agnivdebsikdar8726 2 года назад
From Line 205 what is written?
@sarankumars8309
@sarankumars8309 3 года назад
Any link for application?
@annisyanisa8088
@annisyanisa8088 4 года назад
How i can get the python code? you tell too fast
@imranrajjad7028
@imranrajjad7028 3 года назад
from hashlib import sha256 import json from datetime import datetime class Block: def __init__(self, index, previous_hash, current_transactions, timestamp, nonce): self.index = index self.previous_hash = previous_hash self.current_transactions = current_transactions self.timestamp = timestamp self.nonce = nonce self.hash = self.compute_hash() def compute_hash(self): block_string = json.dumps(self.__dict__, sort_keys=True) first_hash = sha256(block_string.encode()).hexdigest() second_hash = sha256(first_hash.encode()).hexdigest() return second_hash def __str__(self): return str(self.__dict__) class BlockChain: def __init__(self): self.chain = [] self.transactions = [] self.genesis_block() def __str__(self): return str(self.__dict__) def genesis_block(self): genesis_block = Block('Genesis', 0x0, [3, 4, 5, 6, 7], 'datetime.now().timestamp()', 0) genesis_block.hash = genesis_block.compute_hash() self.chain.append(genesis_block.hash) self.transactions.append(str(genesis_block.__dict__)) def getLastBlock(self): return self.chain[-1] def proof_of_work(self, block: Block): difficulty = 1 block.nonce = 0 computed_hash = block.compute_hash() while not (computed_hash.endswith('0'*difficulty) and ('55'*difficulty) in computed_hash): block.nonce += 1 computed_hash = block.compute_hash() return computed_hash def add(self, data): block = Block(len(self.chain), self.chain[-1], data, 'datetime.now().timestamp()', 0) block.hash = self.proof_of_work(block) self.chain.append(block.hash) self.transactions.append(block.__dict__) return json.loads(str(block.__dict__).replace('\'', '\"')) def getTransactions(self, id): labels = ['Manufacturer', 'Transportation', 'Retailer'] while True: try: if id == 'all': for i in range(len(self.transactions)-1): print('{}: {} '.format(labels[i], self.transactions[i+1])) break elif type(id) == int: print(self.transactions[id]) break except Exception as e: print(e) def main(): manufacturer = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Manufacturer X', 'to': 'Transportation X', 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' } ] } transportation = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 100, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 101, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Transportation X', 'to': 'Retailer X', 'shipping_id': 102, 'message': 'Product damaged', 'digital signiture': 'retailer review', 'flagged': 'Y' } ] } retailer = { 'transactions': [ { 'timestamp': datetime.now().timestamp(), 'product_id': 1, 'product_serial': 50001000, 'name': 'cotton pants', 'from': 'Retailer X', 'to': 'Retail Shelf', 'receiving_id': 400, 'message': 'This product is in good order, Received', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002000, 'name': 'cotton shirt', 'from': 'Retailer X', 'to': 'Retail Shelf', 'receiving_id': 400, 'message': 'This product is in good order', 'digital signiture': 'approved', 'flagged': 'N' }, { 'timestamp': datetime.now().timestamp(), 'product_id': 2, 'product_serial': 50002001, 'name': 'cotton shirt', 'from': 'Retailer X', 'to': 'RTV', # Return to Vendor 'receiving_id': 401, 'message': 'Box Damaged', 'digital signiture': 'rejected', 'flagged': 'Y' } ] } B = BlockChain() a = B.add(manufacturer) b = B.add(transportation) c = B.add(retailer) B.getTransactions('all') if __name__ == '__main__': main()
@kikuleshawn2713
@kikuleshawn2713 3 года назад
@@imranrajjad7028 it still doesn't run please help
@niooni7946
@niooni7946 4 года назад
I hope blockchain evolves in the direction of benevolence. Since it has a really good shot at screwing humanity. I can already tell you if im the guy accepting or rejecting products or any high value good or service integrated with future block chain - ill be a rich man. Many Crypto. Just for me :) Even if i need to turn a blind eye once.
Далее
Applying BlockChain to Supply Chain Management
1:01:56
Просмотров 38 тыс.
Редакция. News: 136-я неделя
45:09
Просмотров 1,4 млн
Blockchain Supply Chain Project - Solidity Tutorial
1:06:59
This is why Deep Learning is really weird.
2:06:38
Просмотров 389 тыс.
What is VeChain? VET Supply Chain Solution Explained!
9:12
Blockchain for Supply Chains
1:14:51
Просмотров 10 тыс.
Coding A Blockchain in Python
17:15
Просмотров 171 тыс.
Next Generation Supply Chain Driven by Blockchain
40:37
Build a Blockchain with Python & FastAPI
52:41
Просмотров 32 тыс.
Digital Twins of real-world Supply Chains - Ep 131
41:14
Blockchain & IoT for Supply Chain
52:32
Просмотров 7 тыс.