Build a blockchain-based ledger system, complete with a user-friendly web interface
Update the provided Python file, which already contains the basic PyChain
:
-
Create a new data class named
Record
. It a blueprint for the financial transaction records that the ledger blocks will store. -
Modify the existing
Block
data class to storeRecord
data. -
Add Relevant User Inputs to the Streamlit interface.
-
Test the PyChain Ledger by Storing Records.
@dataclass
class Record:
sender: str
receiver: str
amount: float
class: Block
record: Record
sender = st.text_input("Sender")
receiver = st.text_input("Receiver")
amount = st.text_input("Amount")
new_block = Block(
record=Record(sender, receiver, amount),
# data=input_data,
creator_id=42,
prev_hash=prev_block_hash
)
pychain.add_block(new_block)
st.balloons()
There are three user imputs:
- Sender
- Receiver
- Amount
This information is store in a dictionary and is stored as a Record in the Blockchain. Each block contains intormation about the transaction along with the time of the tranaction, id of the person minting the transaction, the hash of the previous tranaction and the nonce. These transactions are then validated to confirm that it is legitimate.