Skip to content

Commit

Permalink
Create transaction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 10, 2024
1 parent 5a72c3c commit 68f6fcb
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import hashlib

class Transaction:
def __init__(self, sender, recipient, amount):
self.sender = sender
self.recipient = recipient
self.amount = amount
self.hash = self.calculate_hash()

def calculate_hash(self):
data_string = str(self.sender) + str(self.recipient) + str(self.amount)
return hashlib.sha256(data_string.encode()).hexdigest()

0 comments on commit 68f6fcb

Please sign in to comment.