Skip to content

Instantly share code, notes, and snippets.

View dvf's full-sized avatar

Daniel van Flymen dvf

View GitHub Profile
@dvf
dvf / blockchain.py
Last active June 29, 2019 19:54
Step 8: The Mining Endpoint
import hashlib
import json
from time import time
from uuid import uuid4
from flask import Flask, jsonify, request
...
@dvf
dvf / blockchain.py
Created September 23, 2017 19:03
Step 2.1: Creating a Transaction
class Blockchain(object):
...
def new_transaction(self, sender, recipient, amount):
"""
Creates a new transaction to go into the next mined Block
:param sender: <str> Address of the Sender
:param recipient: <str> Address of the Recipient
:param amount: <int> Amount
@dvf
dvf / blockchain.py
Last active June 24, 2019 11:36
Step 7: Transaction Endpoint
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
from flask import Flask, jsonify, request
...
@dvf
dvf / blockchain.py
Last active November 10, 2022 20:12
Step 6: Setting up Flask
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
from flask import Flask
class Blockchain(object):
@dvf
dvf / blockchain.py
Created September 23, 2017 18:30
Step 5: Complete Class
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
class Blockchain(object):
def __init__(self):
self.current_transactions = []
@dvf
dvf / blockchain.py
Last active April 8, 2018 00:23
Step 4: Proof of Work
import hashlib
import json
from time import time
from uuid import uuid4
class Blockchain(object):
...
@dvf
dvf / blockchain.py
Last active April 1, 2024 01:49
Blockchain: Step 2
block = {
'index': 1,
'timestamp': 1506057125.900785,
'transactions': [
{
'sender': "8527147fe1f5426f9dd545de4b27ee00",
'recipient': "a77f5cdfa2934df3954a5c7c7da5df1f",
'amount': 5,
}
],
@dvf
dvf / blockchain.py
Last active January 28, 2021 15:29
Blockchain: Step 3
import hashlib
import json
from time import time
class Blockchain(object):
def __init__(self):
self.current_transactions = []
self.chain = []
@dvf
dvf / blockchain.py
Last active June 16, 2019 07:54
Blockchain: Step 1
class Blockchain(object):
def __init__(self):
self.chain = []
self.current_transactions = []
def new_block(self):
# Creates a new Block and adds it to the chain
pass
def new_transaction(self):

Keybase proof

I hereby claim:

  • I am dvf on github.
  • I am dvf (https://keybase.io/dvf) on keybase.
  • I have a public key ASDMxnfzs4Am9pp5c7i38JACvJCMGlWHABqecGuzoGqr3Qo

To claim this, I am signing this object: