diff --git a/notebooks/II. Building a General Purpose Cryptocurrency.ipynb b/notebooks/II. Building a General Purpose Cryptocurrency.ipynb
index 982c885..9e3354c 100644
--- a/notebooks/II. Building a General Purpose Cryptocurrency.ipynb
+++ b/notebooks/II. Building a General Purpose Cryptocurrency.ipynb
@@ -20,7 +20,7 @@
},
"source": [
"
Table of Contents
\n",
- ""
+ ""
]
},
{
@@ -125,15 +125,144 @@
"Whenever there are competing claims for the next block added to the chain, the one mined later usually gets orphaned. Or to be more precise, the block resulting in longer chains wins and the smaller chain gets orphaned. The transactions in the oprhaned block are not however lost, but returned the mempool. A rule of thumb is to wait for six confirmed blocks to be sure that the transaction within a mined block has been accepted and solidified into the chain."
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## 2. Building the Cryptocurrency\n",
+ "\n",
+ "Next we will create an implementation of out Cryptocurrency named GeneralCoin. We will use the implementation of the blockchain present in the first notebook called \"I. Building a General Purpose Blockchain\". The implementation has been moved to an importable package for saving space from unnecessary repetition of code. We will implement necessary modifications step-by-step to the imported General Purpose Blockchain to transform it to a General Purpose Decentralized Cryptocurrency."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We first import the Blockchain and try running the App to see that it functions as intended."
+ ]
+ },
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ " * Running on http://localhost:5000/ (Press CTRL+C to quit)\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "BlockchainApp\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "127.0.0.1 - - [15/May/2018 09:43:09] \"POST /blocks HTTP/1.1\" 200 -\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{\n",
+ " \"block\": {\n",
+ " \"index\": 1,\n",
+ " \"previous_hash\": \"16672a224c72860895bff19dc3b09c1ef0514e15a0f8e0d6b8082375781ade10\",\n",
+ " \"proof\": 533,\n",
+ " \"timestamp\": \"2018-05-15 09:43:09.656716\"\n",
+ " },\n",
+ " \"message\": \"Congratulations, you just mined a Block!\"\n",
+ "}\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "127.0.0.1 - - [15/May/2018 09:43:10] \"GET /blocks HTTP/1.1\" 200 -\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{\n",
+ " \"blockchain\": [\n",
+ " {\n",
+ " \"index\": 0,\n",
+ " \"previous_hash\": \"0\",\n",
+ " \"proof\": 1,\n",
+ " \"timestamp\": \"2018-05-15 09:42:09.984854\"\n",
+ " },\n",
+ " {\n",
+ " \"index\": 1,\n",
+ " \"previous_hash\": \"16672a224c72860895bff19dc3b09c1ef0514e15a0f8e0d6b8082375781ade10\",\n",
+ " \"proof\": 533,\n",
+ " \"timestamp\": \"2018-05-15 09:43:09.656716\"\n",
+ " }\n",
+ " ],\n",
+ " \"length\": 2\n",
+ "}\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "127.0.0.1 - - [15/May/2018 09:43:11] \"GET /blocks/validate HTTP/1.1\" 200 -\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{\n",
+ " \"message\": \"Chain is valid.\",\n",
+ " \"valid\": true\n",
+ "}\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "127.0.0.1 - - [15/May/2018 09:43:12] \"GET /shutdown HTTP/1.1\" 200 -\n"
+ ]
+ }
+ ],
+ "source": [
+ "import json\n",
+ "from blockchain.apps import BlockchainApp\n",
+ "\n",
+ "with BlockchainApp() as blockchain_app:\n",
+ "\n",
+ " print(blockchain_app.__class__.__name__)\n",
+ "\n",
+ " response = blockchain_app.mine_block()\n",
+ " print(json.dumps(response.json(), indent=2))\n",
+ "\n",
+ " response = blockchain_app.get_blockchain()\n",
+ " print(json.dumps(response.json(), indent=2))\n",
+ " \n",
+ " response = blockchain_app.validate_blockchain()\n",
+ " print(json.dumps(response.json(), indent=2))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": []
}
],
"metadata": {
+ "hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
@@ -149,7 +278,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.4"
+ "version": "3.6.3"
},
"toc": {
"nav_menu": {},