Skip to content

Instantly share code, notes, and snippets.

@dvf
Created September 23, 2017 19:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvf/5c20df453fd4e4fd8fadc7522483efdc to your computer and use it in GitHub Desktop.
Save dvf/5c20df453fd4e4fd8fadc7522483efdc to your computer and use it in GitHub Desktop.
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
:return: <int> The index of the Block that will hold this transaction
"""
self.current_transactions.append({
'sender': sender,
'recipient': recipient,
'amount': amount,
})
return self.last_block['index'] + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment