2.28.2021

Blockchain the expensive word — and with my implemented with Python...

Simple and for some the remote Blockchain and for some an encrypted APP or Information block system..

We’ve all heard the stories of overnight crypto riches. But will cryptocurrencies (or blockchain, their underlying data structure) revolutionize the world? Or will they remain a fascinating experiment in open-source? Nobody can say for sure.

Either way, they’re a lot of fun to write!

What is a BLOCKCHAIN ? 

Skip ahead if you’re already familiar, but basically, a blockchain is open-source software that is shared between thousands ...thousands of computers. These computers all follow a set of rules to track money that’s been sent from accounts tied to the blockchain software.

Each “block” is a group of data that says, for example, “Alice paid Bob $100 on Monday, February 15th.” On the blockchain, I can send you money without using a bank!

WITHOUT BANK ! 

WITHOUT CENTRAL COMMANDER... 

For part this project you’ll only need Python.  Ya Python language and run ...

Keep in mind, our blockchain will be a simplified, high-level introduction…we won’t build the full-blown Bitcoin blockchain. Instead we’ll create functions to add blocks, transactions, and encryption so that our data’s tamper-proof. 

One taste ...little taste implementation ... 

א – Defining our blockchain class and variables  (oop implementation)












First step: imports :  "hashlib"

Need hashlib for the encryption, JSON to format our blocks, and timefor each block’s timestamp.  

Since we’ll be writing this with object-oriented programming in mind, let’s create a Blockchain class and initialize the following variables:

chain:anempty list that we’ll add blocks to. Quite literally our ‘block-chain’.

pending_transactions: when users send our coins to each other, their transactions will sit in this array until we approve & add them to a new block.

new_block: this is a method that we’ll define soon, and we’ll use it to add each block to the chain.

Let’s borrow Satoshi’s message from the Bitcoin genesis block (the very first block ever mined) for inspiration ...as example concrete.


22 old years in software dev ...language programming ...

Soon I will publish other parts of this taste ...










2.18.2021

Implement with Python serialize objects with JSON

 The json module exposes two methods for serializing Python objects into JSON format.

dump() will write Python data to a file-like object. We use this when we want to serialize our Python data to an external JSON file.

dumps() will write Python data to a string in JSON format. This is useful if we want to use the JSON elsewhere in our program, or if we just want to print it to the console to check that it’s correct.

Python and JSON do not share all the same types. Serialization will convert your Python objects into JSON format according to this table

PythonJSON
dictobject
list, tuplearray
strstring
int, long, floatnumber
Truetrue
Falsefalse
Nonenull

Both the dump() and dumps() methods allow us to specify an optional indent argument. This will change how many spaces is used for indentation, which can make our JSON easier to read.

json_str = json.dumps(data, indent=4)

Node.js?

  Node.js? It is JS or Javascript yes, it is the basis.  Yes the old Javascript that today has a strong front and back end stack, the same s...