transactions – Learn how to create a easy P2PK blockchain on Python?

on

|

views

and

comments


I’m an entire newbie within the Blockchain Growth world.

I’m making an attempt to create a really simplified P2PK (I do know it isn’t used anymore but it surely’s the place I would like to start out) blockchain system on Python.

For this, I created a private and non-private key for 2 customers that will probably be sending bitcoins to one another. Now, I’m making an attempt to create the blockchain system however regardless of how a lot I analysis, there aren’t a variety of assets for Python Code, and those I did see are too difficult for my stage of data in the intervening time. I’ve the genesis block and different blocks in txt recordsdata.

I would like some assistance on the best way to proceed subsequent. That is what I’ve:

class Blockchain:

def __init__(self):
    self.chain = []
    self.create_block(proof=1, previous_hash="0")

def create_block(self, proof, previous_hash):
    block = {
                "TxID": 0,
                "Hash": "genesis block", 
                "Nonce": 0,
                "Output": {
                    "Worth": 1,
                    "ScriptPubKey": "Person A's Pub Key OP_CHECKSIG"
                } 
            }
    self.chain.append(block)
    return block
   
def print_previous_block(self):
    return self.chain[-1]

I took https://www.geeksforgeeks.org/create-simple-blockchain-using-python/ instance and wish to implement my transaction (knowledge saved in “block” variable above) on it, however I actually am unsure the best way to.

Share this
Tags

Must-read

Self-driving taxis are coming to London – ought to we be anxious? | Jack Stilgoe

At the top of the nineteenth century, the world’s main cities had an issue. The streets had been flooded with manure, the unintended...

US regulators open inquiry into Waymo self-driving automobile that struck youngster in California | Expertise

The US’s federal transportation regulator stated Thursday it had opened an investigation after a Waymo self-driving car struck a toddler close to an...

US robotaxis bear coaching for London’s quirks earlier than deliberate rollout this yr | London

American robotaxis as a consequence of be unleashed on London’s streets earlier than the tip of the yr have been quietly present process...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here