// import hashlib
# first
class Block:
def __init__(self, previous_block_hash, data):
self.previous_block_hash = previous_block_hash
self.data = data
self.hash = hashlib.sha256((str(previous_block_hash) + str(data)).encode()).hexdigest()
# Blockchain
class Blockchain:
def __init__(self):
self.chain = [self.create_genesis_block()]
def create_genesis_block(self):
return Block("0", "Genesis Block")
def add_block(self, data):
previous_block_hash = self.chain[-1].hash
new_block = Block(previous_block_hash, data)
self.chain.append(new_block)
def print_blocks(self):
for i, block in enumerate(self.chain):
print("Block {} - Hash: {}, Previous Hash: {}, Data: {}".format(
i, block.hash, block.previous_block_hash, block.data
))
# Go Chain in
my_blockchain = Blockchain()
my_blockchain.add_block("Block 1 Data")
my_blockchain.add_block("Block 2 Data")
my_blockchain.print_blocks()
Go Chain is your product of decentralized blockchain and storage technology. Go Chain supports both a blockchain and decentralized fund (DeFi) management. As part of the Web3 foundation, it is aimed to provide solutions to dApp models within the field of data economy.Go Chain is fully compatible with Ethereum and Binance Smart Chain, and all infrastructure integration can be used without any problems.