├── README.md
├── Modulo 2 - Crear una Criptomoneda
├── transaction.json
├── nodes.json
├── jbcoin.py
├── jbcoin_node_5002.py
├── jbcoin_node_5003.py
└── jbcoin_node_5001.py
├── Modulo 3 - Crear un Contrato Inteligente
├── etherwallet-v3.11.2.4
│ ├── fonts
│ │ ├── Lato-Bold.woff
│ │ ├── Lato-Light.woff
│ │ └── Lato-Regular.woff
│ ├── images
│ │ ├── notes-bg.png
│ │ ├── fav
│ │ │ ├── favicon.ico
│ │ │ ├── favicon-16x16.png
│ │ │ ├── favicon-32x32.png
│ │ │ ├── mstile-150x150.png
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── android-chrome-192x192.png
│ │ │ ├── android-chrome-512x512.png
│ │ │ ├── browserconfig.xml
│ │ │ ├── manifest.json
│ │ │ └── safari-pinned-tab.svg
│ │ ├── icons
│ │ │ ├── icon128.png
│ │ │ ├── icon16.png
│ │ │ ├── icon192.png
│ │ │ └── icon32.png
│ │ ├── print-sidebar.png
│ │ ├── logo-ethereum-1.png
│ │ ├── logo-ethereum-2.png
│ │ ├── myetherwallet-logo.png
│ │ ├── myetherwallet-banner-fun.jpg
│ │ ├── myetherwallet-logo-banner.png
│ │ ├── myetherwallet-logo-square.png
│ │ ├── icon-check.svg
│ │ ├── icon-check-green.svg
│ │ ├── icon-edit.svg
│ │ ├── icon-remove.svg
│ │ ├── icon-x.svg
│ │ ├── icon-x-orange.svg
│ │ ├── icon-remove-red.svg
│ │ ├── icon-load-tokens.svg
│ │ ├── icon-help.svg
│ │ ├── icon-help-2.svg
│ │ ├── icon-help-3.svg
│ │ ├── icon-external-link.svg
│ │ ├── icon-view.svg
│ │ ├── icon-eye-closed.svg
│ │ ├── onboarding_icon-04.svg
│ │ ├── logo-trezor.svg
│ │ ├── logo-bity-white.svg
│ │ ├── logo-bity.svg
│ │ ├── icon-eye.svg
│ │ ├── logo-coinbase.svg
│ │ ├── logo-ledger.svg
│ │ ├── icon-protip.svg
│ │ ├── onboarding_icon-06.svg
│ │ ├── onboarding_icon-09.svg
│ │ ├── onboarding_icon-10.svg
│ │ ├── onboarding_icon-07.svg
│ │ ├── logo-myetherwallet.svg
│ │ ├── logo-myetherwallet.min.svg
│ │ ├── onboarding_icon-05.svg
│ │ ├── onboarding_icon-02.svg
│ │ ├── onboarding_icon-03.svg
│ │ ├── logo-myetherwalletcx.svg
│ │ ├── shapeshift-dark.svg
│ │ ├── icon-arrow-left.svg
│ │ ├── icon-arrow-right.svg
│ │ ├── logo-shapeshift.svg
│ │ ├── onboarding_icon-08.svg
│ │ └── onboarding_icon-01.svg
│ ├── bin
│ │ └── startMEW.js
│ ├── package.json
│ ├── manifest.json
│ └── signmsg.html
└── jbcoin_ico.sol
├── .gitignore
└── Modulo 1 - Crear una Cadena de Bloques
└── blockchain.py
/README.md:
--------------------------------------------------------------------------------
1 | # blockchain-a-z
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/transaction.json:
--------------------------------------------------------------------------------
1 | {
2 | "sender" : "",
3 | "receiver" : "",
4 | "amount" :
5 | }
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/nodes.json:
--------------------------------------------------------------------------------
1 | {
2 | "nodes" : ["http://127.0.0.1:5001",
3 | "http://127.0.0.1:5002",
4 | "http://127.0.0.1:5003"]
5 | }
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Bold.woff
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/notes-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/notes-bg.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Light.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Light.woff
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon.ico
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/fonts/Lato-Regular.woff
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon128.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon16.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon192.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icons/icon32.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/print-sidebar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/print-sidebar.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-ethereum-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-ethereum-1.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-ethereum-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-ethereum-2.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon-16x16.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/favicon-32x32.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/mstile-150x150.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/apple-touch-icon.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-banner-fun.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-banner-fun.jpg
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/android-chrome-192x192.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/android-chrome-512x512.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo-banner.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo-square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joanby/blockchain-a-z/HEAD/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/myetherwallet-logo-square.png
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/bin/startMEW.js:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | var open = require("open");
4 | var seperator = process.platform=="win32" ? "\\" : "/";
5 | open(require('path').dirname(require.main.filename)+seperator+".."+seperator+"index.html");
6 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #1d6986
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-check.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-check-green.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MyEtherWallet",
3 | "version": "3.11.2.4",
4 | "description": "An NPM dist of MyEtherWallet. For easier downloading & updating via CLI.",
5 | "author": "MyEtherWallet",
6 | "license": "ISC",
7 | "devDependencies": {
8 | "open": "0.0.5"
9 | },
10 | "bin": {
11 | "mew": "bin/startMEW.js"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-edit.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-remove.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MyEtherWallet",
3 | "icons": [
4 | {
5 | "src": "/images/fav/android-chrome-192x192.png",
6 | "sizes": "192x192",
7 | "type": "image/png"
8 | },
9 | {
10 | "src": "/images/fav/android-chrome-512x512.png",
11 | "sizes": "512x512",
12 | "type": "image/png"
13 | }
14 | ],
15 | "theme_color": "#1d6986",
16 | "background_color": "#1d6986",
17 | "display": "standalone"
18 | }
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-x.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-x-orange.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-remove-red.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-load-tokens.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MyEtherWallet",
3 | "version": "3.11.2.4",
4 | "manifest_version": 2,
5 | "description": "MyEtherWallet Chrome Extension",
6 | "homepage_url": "https://www.myetherwallet.com/",
7 | "icons": {
8 | "16": "images/icons/icon16.png",
9 | "32": "images/icons/icon32.png",
10 | "192": "images/icons/icon192.png"
11 | },
12 | "options_page": "cx-wallet.html",
13 | "browser_action": {
14 | "default_icon": "images/icons/icon32.png",
15 | "default_title": "MyEtherWallet CX",
16 | "default_popup": "browser_action/browser_action.html"
17 | },
18 | "permissions": [
19 | "storage"
20 | ],
21 | "content_security_policy": "script-src 'self' 'unsafe-eval' 'sha256-uxI0oLy+6OpnvTApEkmCzuxkvu4J47b6yHCV93fjHN0=' 'sha256-0Gsidap6748RQlB69d8CLcBCD2A1kL9luXuhxAKpgXQ=' 'sha256-Z7zS8qcr4BZTeVyPP1sIfzQLoVSrzOW0qLHyZCds1WE='; object-src 'self'"
22 | }
23 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-help.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-help-2.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-help-3.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/fav/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-external-link.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-view.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-eye-closed.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-04.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-trezor.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-bity-white.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-bity.svg:
--------------------------------------------------------------------------------
1 | Bity Logo
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/jbcoin_ico.sol:
--------------------------------------------------------------------------------
1 | // Jbcoins ICO
2 |
3 | // Versión del Compilador
4 | pragma solidity ^0.4.26;
5 |
6 | contract jbcoin_ico {
7 |
8 | //Número máximo de JBcoins disponibles para venta
9 | uint public max_jbcoins = 1000000;
10 |
11 | //Conversion Rate entre USD y JBcoins
12 | uint public usd_to_jbcoins = 1000;
13 |
14 | //Número total de JBcoins compradas por inversores
15 | uint public total_jbcoins_bought = 0;
16 |
17 | //Mapping que dada la dirección del inversor, devuelve su equite tanto en JBcoins como en USD
18 | mapping(address => uint) equity_jbcoins;
19 | mapping(address => uint) equity_usd;
20 |
21 | //Comprobar si un Inversor puede comprar JBcoins
22 | modifier can_buy_jbcoins(uint usd_invested) {
23 | require (usd_invested * usd_to_jbcoins + total_jbcoins_bought <= max_jbcoins);
24 | _;
25 | }
26 |
27 | //Obtener el balance de JBcoins de un Inversor
28 | function equity_in_jbcoins(address investor) external constant returns (uint){
29 | return equity_jbcoins[investor];
30 | }
31 |
32 | //Obtener el balance de USD de un Inversor
33 | function equity_in_usd(address investor) external constant returns (uint){
34 | return equity_usd[investor];
35 | }
36 |
37 | //Comprar JBcoins
38 | function buy_jbcoins(address investor, uint usd_invested) external
39 | can_buy_jbcoins(usd_invested) {
40 | uint jbcoins_bought = usd_invested * usd_to_jbcoins;
41 | equity_jbcoins[investor] += jbcoins_bought;
42 | equity_usd[investor] = equity_jbcoins[investor] / usd_to_jbcoins;
43 | total_jbcoins_bought += jbcoins_bought;
44 | }
45 |
46 | //Vender JBcoins
47 | function sell_jbcoins(address investor, uint jbcoins_sold) external {
48 | equity_jbcoins[investor] -= jbcoins_sold;
49 | equity_usd[investor] = equity_jbcoins[investor] / usd_to_jbcoins;
50 | total_jbcoins_bought -= jbcoins_sold;
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-eye.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 | .DS_Store
131 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-coinbase.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-ledger.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-protip.svg:
--------------------------------------------------------------------------------
1 |
2 | idea
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-06.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-09.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 1 - Crear una Cadena de Bloques/blockchain.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Wed Aug 25 16:07:09 2021
5 |
6 | @author: juangabriel
7 | """
8 |
9 | # Módulo 1 - Crear una Cadena de Bloques
10 |
11 | # Para Instalar:
12 | # Flask==1.1.2: pip install Flask==1.1.2
13 | # Cliente HTTP Postman: https://www.getpostman.com/
14 |
15 | # Importar las librerías
16 | import datetime
17 | import hashlib
18 | import json
19 | from flask import Flask, jsonify
20 |
21 | # Parte 1 - Crear la Cadena de Bloques
22 | class Blockchain:
23 |
24 | def __init__(self):
25 | self.chain = []
26 | self.create_block(proof = 1, previous_hash = '0')
27 |
28 | def create_block(self, proof, previous_hash):
29 | block = {'index' : len(self.chain)+1,
30 | 'timestamp' : str(datetime.datetime.now()),
31 | 'proof' : proof,
32 | 'previous_hash': previous_hash}
33 | self.chain.append(block)
34 | return block
35 |
36 | def get_previous_block(self):
37 | return self.chain[-1]
38 |
39 | def proof_of_work(self, previous_proof):
40 | new_proof = 1
41 | check_proof = False
42 | while check_proof is False:
43 | hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
44 | if hash_operation[:4] == '0000':
45 | check_proof = True
46 | else:
47 | new_proof += 1
48 | return new_proof
49 |
50 | def hash(self, block):
51 | encoded_block = json.dumps(block, sort_keys = True).encode()
52 | return hashlib.sha256(encoded_block).hexdigest()
53 |
54 | def is_chain_valid(self, chain):
55 | previous_block = chain[0]
56 | block_index = 1
57 | while block_index < len(chain):
58 | block = chain[block_index]
59 | if block['previous_hash'] != self.hash(previous_block):
60 | return False
61 | previous_proof = previous_block['proof']
62 | proof = block['proof']
63 | hash_operation = hashlib.sha256(str(proof**2 - previous_proof**2).encode()).hexdigest()
64 | if hash_operation[:4] != '0000':
65 | return False
66 | previous_block = block
67 | block_index += 1
68 | return True
69 |
70 | # Parte 2 - Minado de un Bloque de la Cadena
71 |
72 | # Crear una aplicación web
73 | app = Flask(__name__)
74 | # Si se obtiene un error 500, actualizar flask, reiniciar spyder y ejecutar la siguiente línea
75 | app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
76 |
77 | # Crear una Blockchain
78 | blockchain = Blockchain()
79 |
80 | # Minar un nuevo bloque
81 | @app.route('/mine_block', methods=['GET'])
82 | def mine_block():
83 | previous_block = blockchain.get_previous_block()
84 | previous_proof = previous_block['proof']
85 | proof = blockchain.proof_of_work(previous_proof)
86 | previous_hash = blockchain.hash(previous_block)
87 | block = blockchain.create_block(proof, previous_hash)
88 | response = {'message' : '¡Enhorabuena, has minado un nuevo bloque!',
89 | 'index': block['index'],
90 | 'timestamp' : block['timestamp'],
91 | 'proof' : block['proof'],
92 | 'previous_hash' : block['previous_hash']}
93 | return jsonify(response), 200
94 |
95 | # Obtener la cadena de bloques al completo
96 | @app.route('/get_chain', methods=['GET'])
97 | def get_chain():
98 | response = {'chain' : blockchain.chain,
99 | 'length' : len(blockchain.chain)}
100 | return jsonify(response), 200
101 |
102 | # Comprobar si la cadena de bloques es válida
103 | @app.route('/is_valid', methods = ['GET'])
104 | def is_valid():
105 | is_valid = blockchain.is_chain_valid(blockchain.chain)
106 | if is_valid:
107 | response = {'message' : 'Todo correcto. La cadena de bloques es válida.'}
108 | else:
109 | response = {'message' : 'Houston, tenemos un problema. La cadena de bloques no es válida.'}
110 | return jsonify(response), 200
111 |
112 | # Ejecutar la app
113 | app.run(host = '0.0.0.0', port = 5000)
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-10.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-07.svg:
--------------------------------------------------------------------------------
1 | onboarding_icon-07
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-myetherwallet.svg:
--------------------------------------------------------------------------------
1 | MyEtherWalelt Logo
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-myetherwallet.min.svg:
--------------------------------------------------------------------------------
1 | MyEtherWallet Logo
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-05.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-02.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-03.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-myetherwalletcx.svg:
--------------------------------------------------------------------------------
1 | MyEtherWallet CX Logo
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/shapeshift-dark.svg:
--------------------------------------------------------------------------------
1 | shapeshift_logo
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/jbcoin.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Sep 2 09:33:47 2021
5 |
6 | @author: juangabriel
7 | """
8 |
9 |
10 | # Módulo 2 - Crear una Criptomoneda
11 |
12 | # Para Instalar:
13 | # Flask==1.1.2: pip install Flask==1.1.2
14 | # Cliente HTTP Postman: https://www.getpostman.com/
15 | # requests==2.25.1: pip install requests==2.25.1
16 |
17 | # Importar las librerías
18 | import datetime
19 | import hashlib
20 | import json
21 | from flask import Flask, jsonify, request
22 | import requests
23 | from uuid import uuid4
24 | from urllib.parse import urlparse
25 |
26 | # Parte 1 - Crear la Cadena de Bloques
27 |
28 | class Blockchain:
29 |
30 | def __init__(self):
31 | self.chain = []
32 | self.transactions = []
33 | self.create_block(proof = 1, previous_hash = '0')
34 | self.nodes = set()
35 |
36 | def create_block(self, proof, previous_hash):
37 | block = {'index' : len(self.chain)+1,
38 | 'timestamp' : str(datetime.datetime.now()),
39 | 'proof' : proof,
40 | 'previous_hash': previous_hash,
41 | 'transactions': self.transactions}
42 | self.transactions = []
43 | self.chain.append(block)
44 | return block
45 |
46 | def get_previous_block(self):
47 | return self.chain[-1]
48 |
49 | def proof_of_work(self, previous_proof):
50 | new_proof = 1
51 | check_proof = False
52 | while check_proof is False:
53 | hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
54 | if hash_operation[:4] == '0000':
55 | check_proof = True
56 | else:
57 | new_proof += 1
58 | return new_proof
59 |
60 | def hash(self, block):
61 | encoded_block = json.dumps(block, sort_keys = True).encode()
62 | return hashlib.sha256(encoded_block).hexdigest()
63 |
64 | def is_chain_valid(self, chain):
65 | previous_block = chain[0]
66 | block_index = 1
67 | while block_index < len(chain):
68 | block = chain[block_index]
69 | if block['previous_hash'] != self.hash(previous_block):
70 | return False
71 | previous_proof = previous_block['proof']
72 | proof = block['proof']
73 | hash_operation = hashlib.sha256(str(proof**2 - previous_proof**2).encode()).hexdigest()
74 | if hash_operation[:4] != '0000':
75 | return False
76 | previous_block = block
77 | block_index += 1
78 | return True
79 |
80 | def add_transaction(self, sender, receiver, amount):
81 | self.transactions.append({'sender': sender,
82 | 'receiver': receiver,
83 | 'amount': amount})
84 | previous_block = self.previous_block()
85 | return previous_block['index'] + 1
86 |
87 | def add_node(self, address):
88 | parsed_url = urlparse(address)
89 | self.nodes.add(parsed_url.netloc)
90 |
91 | def replace_chain(self):
92 | network = self.nodes
93 | longest_chain = None
94 | max_length = len(self.chain)
95 | for node in network:
96 | response = requests.get(f'http://{node}/get_chain')
97 | if response.status_code == 200:
98 | length = response.json()['length']
99 | chain = response.json()['chain']
100 | if length > max_length and self.is_chain_valid(chain):
101 | max_length = length
102 | longest_chain = chain
103 | if longest_chain:
104 | self.chain = longest_chain
105 | return True
106 | return False
107 |
108 | # Parte 2 - Minado de un Bloque de la Cadena
109 |
110 | # Crear una aplicación web
111 | app = Flask(__name__)
112 | # Si se obtiene un error 500, actualizar flask, reiniciar spyder y ejecutar la siguiente línea
113 | app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
114 |
115 | # Crear la dirección del nodo en el puerto 5000
116 | node_address = str(uuid4()).replace('-', '')
117 |
118 |
119 | # Crear una Blockchain
120 | blockchain = Blockchain()
121 |
122 | # Minar un nuevo bloque
123 | @app.route('/mine_block', methods=['GET'])
124 | def mine_block():
125 | previous_block = blockchain.get_previous_block()
126 | previous_proof = previous_block['proof']
127 | proof = blockchain.proof_of_work(previous_proof)
128 | previous_hash = blockchain.hash(previous_block)
129 | blockchain.add_transaction(sender = node_address, receiver = "Juan Gabriel", amount = 10)
130 | block = blockchain.create_block(proof, previous_hash)
131 | response = {'message' : '¡Enhorabuena, has minado un nuevo bloque!',
132 | 'index': block['index'],
133 | 'timestamp' : block['timestamp'],
134 | 'proof' : block['proof'],
135 | 'previous_hash' : block['previous_hash'],
136 | 'transactions': block['transactions']}
137 | return jsonify(response), 200
138 |
139 | # Obtener la cadena de bloques al completo
140 | @app.route('/get_chain', methods=['GET'])
141 | def get_chain():
142 | response = {'chain' : blockchain.chain,
143 | 'length' : len(blockchain.chain)}
144 | return jsonify(response), 200
145 |
146 | # Comprobar si la cadena de bloques es válida
147 | @app.route('/is_valid', methods = ['GET'])
148 | def is_valid():
149 | is_valid = blockchain.is_chain_valid(blockchain.chain)
150 | if is_valid:
151 | response = {'message' : 'Todo correcto. La cadena de bloques es válida.'}
152 | else:
153 | response = {'message' : 'Houston, tenemos un problema. La cadena de bloques no es válida.'}
154 | return jsonify(response), 200
155 |
156 |
157 | # Añadir una nueva transacción a la cadena de bloques
158 | @app.route('/add_transaction', methods = ['POST'])
159 | def add_transaction():
160 | json = request.get_json()
161 | transaction_keys = ['sender', 'receiver', 'amount']
162 | if not all(key in json for key in transaction_keys):
163 | return 'Faltan algunos elementos de la transacción', 400
164 | index = blockchain.add_transaction(json['sender'], json['receiver'], json['amount'])
165 | response = {'message': f'La transacción será añadida al bloque {index}'}
166 | return jsonify(response), 201
167 |
168 | # Parte 3 - Descentralizar la Cadena de Bloques
169 |
170 | # Conectar nuevos nodos
171 | @app.route('/connect_node', methods = ['POST'])
172 | def connect_node():
173 | json = request.get_json()
174 | nodes = json.get('nodes')
175 | if nodes is None:
176 | return 'No hay nodos para añadir', 400
177 | for node in nodes:
178 | blockchain.add_node(node)
179 | response = {'message' : 'Todos los nodos han sido conectados. La cadena de Jbcoins contiene ahora los nodos siguientes: ',
180 | 'total_nodes': list(blockchain.nodes)}
181 | return jsonify(response), 201
182 |
183 | # Reemplazar la cadena por la más larga (si es necesario)
184 | @app.route('/replace_chain', methods = ['GET'])
185 | def replace_chain():
186 | is_chain_replaced = blockchain.replace_chain()
187 | if is_chain_replaced:
188 | response = {'message' : 'Los nodos tenían diferentes cadenas, que han sido todas reemplazadas por la más larga.',
189 | 'new_chain': blockchain.chain}
190 | else:
191 | response = {'message' : 'Todo correcto. La cadena en todos los nodos ya es la más larga.',
192 | 'actual_chain' : blockchain.chain}
193 | return jsonify(response), 200
194 |
195 |
196 | # Ejecutar la app
197 | app.run(host = '0.0.0.0', port = 5000)
198 |
199 |
200 |
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/jbcoin_node_5002.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Sep 2 09:33:47 2021
5 |
6 | @author: juangabriel
7 | """
8 |
9 |
10 | # Módulo 2 - Crear una Criptomoneda
11 |
12 | # Para Instalar:
13 | # Flask==1.1.2: pip install Flask==1.1.2
14 | # Cliente HTTP Postman: https://www.getpostman.com/
15 | # requests==2.25.1: pip install requests==2.25.1
16 |
17 | # Importar las librerías
18 | import datetime
19 | import hashlib
20 | import json
21 | from flask import Flask, jsonify, request
22 | import requests
23 | from uuid import uuid4
24 | from urllib.parse import urlparse
25 |
26 | # Parte 1 - Crear la Cadena de Bloques
27 |
28 | class Blockchain:
29 |
30 | def __init__(self):
31 | self.chain = []
32 | self.transactions = []
33 | self.create_block(proof = 1, previous_hash = '0')
34 | self.nodes = set()
35 |
36 | def create_block(self, proof, previous_hash):
37 | block = {'index' : len(self.chain)+1,
38 | 'timestamp' : str(datetime.datetime.now()),
39 | 'proof' : proof,
40 | 'previous_hash': previous_hash,
41 | 'transactions': self.transactions}
42 | self.transactions = []
43 | self.chain.append(block)
44 | return block
45 |
46 | def get_previous_block(self):
47 | return self.chain[-1]
48 |
49 | def proof_of_work(self, previous_proof):
50 | new_proof = 1
51 | check_proof = False
52 | while check_proof is False:
53 | hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
54 | if hash_operation[:4] == '0000':
55 | check_proof = True
56 | else:
57 | new_proof += 1
58 | return new_proof
59 |
60 | def hash(self, block):
61 | encoded_block = json.dumps(block, sort_keys = True).encode()
62 | return hashlib.sha256(encoded_block).hexdigest()
63 |
64 | def is_chain_valid(self, chain):
65 | previous_block = chain[0]
66 | block_index = 1
67 | while block_index < len(chain):
68 | block = chain[block_index]
69 | if block['previous_hash'] != self.hash(previous_block):
70 | return False
71 | previous_proof = previous_block['proof']
72 | proof = block['proof']
73 | hash_operation = hashlib.sha256(str(proof**2 - previous_proof**2).encode()).hexdigest()
74 | if hash_operation[:4] != '0000':
75 | return False
76 | previous_block = block
77 | block_index += 1
78 | return True
79 |
80 | def add_transaction(self, sender, receiver, amount):
81 | self.transactions.append({'sender': sender,
82 | 'receiver': receiver,
83 | 'amount': amount})
84 | previous_block = self.get_previous_block()
85 | return previous_block['index'] + 1
86 |
87 | def add_node(self, address):
88 | parsed_url = urlparse(address)
89 | self.nodes.add(parsed_url.netloc)
90 |
91 | def replace_chain(self):
92 | network = self.nodes
93 | longest_chain = None
94 | max_length = len(self.chain)
95 | for node in network:
96 | response = requests.get(f'http://{node}/get_chain')
97 | if response.status_code == 200:
98 | length = response.json()['length']
99 | chain = response.json()['chain']
100 | if length > max_length and self.is_chain_valid(chain):
101 | max_length = length
102 | longest_chain = chain
103 | if longest_chain:
104 | self.chain = longest_chain
105 | return True
106 | return False
107 |
108 | # Parte 2 - Minado de un Bloque de la Cadena
109 |
110 | # Crear una aplicación web
111 | app = Flask(__name__)
112 | # Si se obtiene un error 500, actualizar flask, reiniciar spyder y ejecutar la siguiente línea
113 | app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
114 |
115 | # Crear la dirección del nodo en el puerto 5000
116 | node_address = str(uuid4()).replace('-', '')
117 |
118 |
119 | # Crear una Blockchain
120 | blockchain = Blockchain()
121 |
122 | # Minar un nuevo bloque
123 | @app.route('/mine_block', methods=['GET'])
124 | def mine_block():
125 | previous_block = blockchain.get_previous_block()
126 | previous_proof = previous_block['proof']
127 | proof = blockchain.proof_of_work(previous_proof)
128 | previous_hash = blockchain.hash(previous_block)
129 | blockchain.add_transaction(sender = node_address, receiver = "Kirill", amount = 10)
130 | block = blockchain.create_block(proof, previous_hash)
131 | response = {'message' : '¡Enhorabuena, has minado un nuevo bloque!',
132 | 'index': block['index'],
133 | 'timestamp' : block['timestamp'],
134 | 'proof' : block['proof'],
135 | 'previous_hash' : block['previous_hash'],
136 | 'transactions': block['transactions']}
137 | return jsonify(response), 200
138 |
139 | # Obtener la cadena de bloques al completo
140 | @app.route('/get_chain', methods=['GET'])
141 | def get_chain():
142 | response = {'chain' : blockchain.chain,
143 | 'length' : len(blockchain.chain)}
144 | return jsonify(response), 200
145 |
146 | # Comprobar si la cadena de bloques es válida
147 | @app.route('/is_valid', methods = ['GET'])
148 | def is_valid():
149 | is_valid = blockchain.is_chain_valid(blockchain.chain)
150 | if is_valid:
151 | response = {'message' : 'Todo correcto. La cadena de bloques es válida.'}
152 | else:
153 | response = {'message' : 'Houston, tenemos un problema. La cadena de bloques no es válida.'}
154 | return jsonify(response), 200
155 |
156 |
157 | # Añadir una nueva transacción a la cadena de bloques
158 | @app.route('/add_transaction', methods = ['POST'])
159 | def add_transaction():
160 | json = request.get_json()
161 | transaction_keys = ['sender', 'receiver', 'amount']
162 | if not all(key in json for key in transaction_keys):
163 | return 'Faltan algunos elementos de la transacción', 400
164 | index = blockchain.add_transaction(json['sender'], json['receiver'], json['amount'])
165 | response = {'message': f'La transacción será añadida al bloque {index}'}
166 | return jsonify(response), 201
167 |
168 | # Parte 3 - Descentralizar la Cadena de Bloques
169 |
170 | # Conectar nuevos nodos
171 | @app.route('/connect_node', methods = ['POST'])
172 | def connect_node():
173 | json = request.get_json()
174 | nodes = json.get('nodes')
175 | if nodes is None:
176 | return 'No hay nodos para añadir', 400
177 | for node in nodes:
178 | blockchain.add_node(node)
179 | response = {'message' : 'Todos los nodos han sido conectados. La cadena de Jbcoins contiene ahora los nodos siguientes: ',
180 | 'total_nodes': list(blockchain.nodes)}
181 | return jsonify(response), 201
182 |
183 | # Reemplazar la cadena por la más larga (si es necesario)
184 | @app.route('/replace_chain', methods = ['GET'])
185 | def replace_chain():
186 | is_chain_replaced = blockchain.replace_chain()
187 | if is_chain_replaced:
188 | response = {'message' : 'Los nodos tenían diferentes cadenas, que han sido todas reemplazadas por la más larga.',
189 | 'new_chain': blockchain.chain}
190 | else:
191 | response = {'message' : 'Todo correcto. La cadena en todos los nodos ya es la más larga.',
192 | 'actual_chain' : blockchain.chain}
193 | return jsonify(response), 200
194 |
195 |
196 | # Ejecutar la app
197 | app.run(host = '0.0.0.0', port = 5002)
198 |
199 |
200 |
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/jbcoin_node_5003.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Sep 2 09:33:47 2021
5 |
6 | @author: juangabriel
7 | """
8 |
9 |
10 | # Módulo 2 - Crear una Criptomoneda
11 |
12 | # Para Instalar:
13 | # Flask==1.1.2: pip install Flask==1.1.2
14 | # Cliente HTTP Postman: https://www.getpostman.com/
15 | # requests==2.25.1: pip install requests==2.25.1
16 |
17 | # Importar las librerías
18 | import datetime
19 | import hashlib
20 | import json
21 | from flask import Flask, jsonify, request
22 | import requests
23 | from uuid import uuid4
24 | from urllib.parse import urlparse
25 |
26 | # Parte 1 - Crear la Cadena de Bloques
27 |
28 | class Blockchain:
29 |
30 | def __init__(self):
31 | self.chain = []
32 | self.transactions = []
33 | self.create_block(proof = 1, previous_hash = '0')
34 | self.nodes = set()
35 |
36 | def create_block(self, proof, previous_hash):
37 | block = {'index' : len(self.chain)+1,
38 | 'timestamp' : str(datetime.datetime.now()),
39 | 'proof' : proof,
40 | 'previous_hash': previous_hash,
41 | 'transactions': self.transactions}
42 | self.transactions = []
43 | self.chain.append(block)
44 | return block
45 |
46 | def get_previous_block(self):
47 | return self.chain[-1]
48 |
49 | def proof_of_work(self, previous_proof):
50 | new_proof = 1
51 | check_proof = False
52 | while check_proof is False:
53 | hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
54 | if hash_operation[:4] == '0000':
55 | check_proof = True
56 | else:
57 | new_proof += 1
58 | return new_proof
59 |
60 | def hash(self, block):
61 | encoded_block = json.dumps(block, sort_keys = True).encode()
62 | return hashlib.sha256(encoded_block).hexdigest()
63 |
64 | def is_chain_valid(self, chain):
65 | previous_block = chain[0]
66 | block_index = 1
67 | while block_index < len(chain):
68 | block = chain[block_index]
69 | if block['previous_hash'] != self.hash(previous_block):
70 | return False
71 | previous_proof = previous_block['proof']
72 | proof = block['proof']
73 | hash_operation = hashlib.sha256(str(proof**2 - previous_proof**2).encode()).hexdigest()
74 | if hash_operation[:4] != '0000':
75 | return False
76 | previous_block = block
77 | block_index += 1
78 | return True
79 |
80 | def add_transaction(self, sender, receiver, amount):
81 | self.transactions.append({'sender': sender,
82 | 'receiver': receiver,
83 | 'amount': amount})
84 | previous_block = self.get_previous_block()
85 | return previous_block['index'] + 1
86 |
87 | def add_node(self, address):
88 | parsed_url = urlparse(address)
89 | self.nodes.add(parsed_url.netloc)
90 |
91 | def replace_chain(self):
92 | network = self.nodes
93 | longest_chain = None
94 | max_length = len(self.chain)
95 | for node in network:
96 | response = requests.get(f'http://{node}/get_chain')
97 | if response.status_code == 200:
98 | length = response.json()['length']
99 | chain = response.json()['chain']
100 | if length > max_length and self.is_chain_valid(chain):
101 | max_length = length
102 | longest_chain = chain
103 | if longest_chain:
104 | self.chain = longest_chain
105 | return True
106 | return False
107 |
108 | # Parte 2 - Minado de un Bloque de la Cadena
109 |
110 | # Crear una aplicación web
111 | app = Flask(__name__)
112 | # Si se obtiene un error 500, actualizar flask, reiniciar spyder y ejecutar la siguiente línea
113 | app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
114 |
115 | # Crear la dirección del nodo en el puerto 5000
116 | node_address = str(uuid4()).replace('-', '')
117 |
118 |
119 | # Crear una Blockchain
120 | blockchain = Blockchain()
121 |
122 | # Minar un nuevo bloque
123 | @app.route('/mine_block', methods=['GET'])
124 | def mine_block():
125 | previous_block = blockchain.get_previous_block()
126 | previous_proof = previous_block['proof']
127 | proof = blockchain.proof_of_work(previous_proof)
128 | previous_hash = blockchain.hash(previous_block)
129 | blockchain.add_transaction(sender = node_address, receiver = "Hadelin", amount = 10)
130 | block = blockchain.create_block(proof, previous_hash)
131 | response = {'message' : '¡Enhorabuena, has minado un nuevo bloque!',
132 | 'index': block['index'],
133 | 'timestamp' : block['timestamp'],
134 | 'proof' : block['proof'],
135 | 'previous_hash' : block['previous_hash'],
136 | 'transactions': block['transactions']}
137 | return jsonify(response), 200
138 |
139 | # Obtener la cadena de bloques al completo
140 | @app.route('/get_chain', methods=['GET'])
141 | def get_chain():
142 | response = {'chain' : blockchain.chain,
143 | 'length' : len(blockchain.chain)}
144 | return jsonify(response), 200
145 |
146 | # Comprobar si la cadena de bloques es válida
147 | @app.route('/is_valid', methods = ['GET'])
148 | def is_valid():
149 | is_valid = blockchain.is_chain_valid(blockchain.chain)
150 | if is_valid:
151 | response = {'message' : 'Todo correcto. La cadena de bloques es válida.'}
152 | else:
153 | response = {'message' : 'Houston, tenemos un problema. La cadena de bloques no es válida.'}
154 | return jsonify(response), 200
155 |
156 |
157 | # Añadir una nueva transacción a la cadena de bloques
158 | @app.route('/add_transaction', methods = ['POST'])
159 | def add_transaction():
160 | json = request.get_json()
161 | transaction_keys = ['sender', 'receiver', 'amount']
162 | if not all(key in json for key in transaction_keys):
163 | return 'Faltan algunos elementos de la transacción', 400
164 | index = blockchain.add_transaction(json['sender'], json['receiver'], json['amount'])
165 | response = {'message': f'La transacción será añadida al bloque {index}'}
166 | return jsonify(response), 201
167 |
168 | # Parte 3 - Descentralizar la Cadena de Bloques
169 |
170 | # Conectar nuevos nodos
171 | @app.route('/connect_node', methods = ['POST'])
172 | def connect_node():
173 | json = request.get_json()
174 | nodes = json.get('nodes')
175 | if nodes is None:
176 | return 'No hay nodos para añadir', 400
177 | for node in nodes:
178 | blockchain.add_node(node)
179 | response = {'message' : 'Todos los nodos han sido conectados. La cadena de Jbcoins contiene ahora los nodos siguientes: ',
180 | 'total_nodes': list(blockchain.nodes)}
181 | return jsonify(response), 201
182 |
183 | # Reemplazar la cadena por la más larga (si es necesario)
184 | @app.route('/replace_chain', methods = ['GET'])
185 | def replace_chain():
186 | is_chain_replaced = blockchain.replace_chain()
187 | if is_chain_replaced:
188 | response = {'message' : 'Los nodos tenían diferentes cadenas, que han sido todas reemplazadas por la más larga.',
189 | 'new_chain': blockchain.chain}
190 | else:
191 | response = {'message' : 'Todo correcto. La cadena en todos los nodos ya es la más larga.',
192 | 'actual_chain' : blockchain.chain}
193 | return jsonify(response), 200
194 |
195 |
196 | # Ejecutar la app
197 | app.run(host = '0.0.0.0', port = 5003)
198 |
199 |
200 |
--------------------------------------------------------------------------------
/Modulo 2 - Crear una Criptomoneda/jbcoin_node_5001.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Sep 2 09:33:47 2021
5 |
6 | @author: juangabriel
7 | """
8 |
9 |
10 | # Módulo 2 - Crear una Criptomoneda
11 |
12 | # Para Instalar:
13 | # Flask==1.1.2: pip install Flask==1.1.2
14 | # Cliente HTTP Postman: https://www.getpostman.com/
15 | # requests==2.25.1: pip install requests==2.25.1
16 |
17 | # Importar las librerías
18 | import datetime
19 | import hashlib
20 | import json
21 | from flask import Flask, jsonify, request
22 | import requests
23 | from uuid import uuid4
24 | from urllib.parse import urlparse
25 |
26 | # Parte 1 - Crear la Cadena de Bloques
27 |
28 | class Blockchain:
29 |
30 | def __init__(self):
31 | self.chain = []
32 | self.transactions = []
33 | self.create_block(proof = 1, previous_hash = '0')
34 | self.nodes = set()
35 |
36 | def create_block(self, proof, previous_hash):
37 | block = {'index' : len(self.chain)+1,
38 | 'timestamp' : str(datetime.datetime.now()),
39 | 'proof' : proof,
40 | 'previous_hash': previous_hash,
41 | 'transactions': self.transactions}
42 | self.transactions = []
43 | self.chain.append(block)
44 | return block
45 |
46 | def get_previous_block(self):
47 | return self.chain[-1]
48 |
49 | def proof_of_work(self, previous_proof):
50 | new_proof = 1
51 | check_proof = False
52 | while check_proof is False:
53 | hash_operation = hashlib.sha256(str(new_proof**2 - previous_proof**2).encode()).hexdigest()
54 | if hash_operation[:4] == '0000':
55 | check_proof = True
56 | else:
57 | new_proof += 1
58 | return new_proof
59 |
60 | def hash(self, block):
61 | encoded_block = json.dumps(block, sort_keys = True).encode()
62 | return hashlib.sha256(encoded_block).hexdigest()
63 |
64 | def is_chain_valid(self, chain):
65 | previous_block = chain[0]
66 | block_index = 1
67 | while block_index < len(chain):
68 | block = chain[block_index]
69 | if block['previous_hash'] != self.hash(previous_block):
70 | return False
71 | previous_proof = previous_block['proof']
72 | proof = block['proof']
73 | hash_operation = hashlib.sha256(str(proof**2 - previous_proof**2).encode()).hexdigest()
74 | if hash_operation[:4] != '0000':
75 | return False
76 | previous_block = block
77 | block_index += 1
78 | return True
79 |
80 | def add_transaction(self, sender, receiver, amount):
81 | self.transactions.append({'sender': sender,
82 | 'receiver': receiver,
83 | 'amount': amount})
84 | previous_block = self.get_previous_block()
85 | return previous_block['index'] + 1
86 |
87 | def add_node(self, address):
88 | parsed_url = urlparse(address)
89 | self.nodes.add(parsed_url.netloc)
90 |
91 | def replace_chain(self):
92 | network = self.nodes
93 | longest_chain = None
94 | max_length = len(self.chain)
95 | for node in network:
96 | response = requests.get(f'http://{node}/get_chain')
97 | if response.status_code == 200:
98 | length = response.json()['length']
99 | chain = response.json()['chain']
100 | if length > max_length and self.is_chain_valid(chain):
101 | max_length = length
102 | longest_chain = chain
103 | if longest_chain:
104 | self.chain = longest_chain
105 | return True
106 | return False
107 |
108 | # Parte 2 - Minado de un Bloque de la Cadena
109 |
110 | # Crear una aplicación web
111 | app = Flask(__name__)
112 | # Si se obtiene un error 500, actualizar flask, reiniciar spyder y ejecutar la siguiente línea
113 | app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
114 |
115 | # Crear la dirección del nodo en el puerto 5000
116 | node_address = str(uuid4()).replace('-', '')
117 |
118 |
119 | # Crear una Blockchain
120 | blockchain = Blockchain()
121 |
122 | # Minar un nuevo bloque
123 | @app.route('/mine_block', methods=['GET'])
124 | def mine_block():
125 | previous_block = blockchain.get_previous_block()
126 | previous_proof = previous_block['proof']
127 | proof = blockchain.proof_of_work(previous_proof)
128 | previous_hash = blockchain.hash(previous_block)
129 | blockchain.add_transaction(sender = node_address, receiver = "Juan Gabriel", amount = 10)
130 | block = blockchain.create_block(proof, previous_hash)
131 | response = {'message' : '¡Enhorabuena, has minado un nuevo bloque!',
132 | 'index': block['index'],
133 | 'timestamp' : block['timestamp'],
134 | 'proof' : block['proof'],
135 | 'previous_hash' : block['previous_hash'],
136 | 'transactions': block['transactions']}
137 | return jsonify(response), 200
138 |
139 | # Obtener la cadena de bloques al completo
140 | @app.route('/get_chain', methods=['GET'])
141 | def get_chain():
142 | response = {'chain' : blockchain.chain,
143 | 'length' : len(blockchain.chain)}
144 | return jsonify(response), 200
145 |
146 | # Comprobar si la cadena de bloques es válida
147 | @app.route('/is_valid', methods = ['GET'])
148 | def is_valid():
149 | is_valid = blockchain.is_chain_valid(blockchain.chain)
150 | if is_valid:
151 | response = {'message' : 'Todo correcto. La cadena de bloques es válida.'}
152 | else:
153 | response = {'message' : 'Houston, tenemos un problema. La cadena de bloques no es válida.'}
154 | return jsonify(response), 200
155 |
156 |
157 | # Añadir una nueva transacción a la cadena de bloques
158 | @app.route('/add_transaction', methods = ['POST'])
159 | def add_transaction():
160 | json = request.get_json()
161 | transaction_keys = ['sender', 'receiver', 'amount']
162 | if not all(key in json for key in transaction_keys):
163 | return 'Faltan algunos elementos de la transacción', 400
164 | index = blockchain.add_transaction(json['sender'], json['receiver'], json['amount'])
165 | response = {'message': f'La transacción será añadida al bloque {index}'}
166 | return jsonify(response), 201
167 |
168 | # Parte 3 - Descentralizar la Cadena de Bloques
169 |
170 | # Conectar nuevos nodos
171 | @app.route('/connect_node', methods = ['POST'])
172 | def connect_node():
173 | json = request.get_json()
174 | nodes = json.get('nodes')
175 | if nodes is None:
176 | return 'No hay nodos para añadir', 400
177 | for node in nodes:
178 | blockchain.add_node(node)
179 | response = {'message' : 'Todos los nodos han sido conectados. La cadena de Jbcoins contiene ahora los nodos siguientes: ',
180 | 'total_nodes': list(blockchain.nodes)}
181 | return jsonify(response), 201
182 |
183 | # Reemplazar la cadena por la más larga (si es necesario)
184 | @app.route('/replace_chain', methods = ['GET'])
185 | def replace_chain():
186 | is_chain_replaced = blockchain.replace_chain()
187 | if is_chain_replaced:
188 | response = {'message' : 'Los nodos tenían diferentes cadenas, que han sido todas reemplazadas por la más larga.',
189 | 'new_chain': blockchain.chain}
190 | else:
191 | response = {'message' : 'Todo correcto. La cadena en todos los nodos ya es la más larga.',
192 | 'actual_chain' : blockchain.chain}
193 | return jsonify(response), 200
194 |
195 |
196 | # Ejecutar la app
197 | app.run(host = '0.0.0.0', port = 5001)
198 |
199 |
200 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/signmsg.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MyEtherWallet.com
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Message
71 |
72 |
73 |
79 |
80 |
81 |
82 | Include your nickname and where you use the nickname so someone else cannot use it.
83 |
84 |
85 | Include a specific reason for the message so it cannot be reused for a different purpose.
86 |
87 |
88 |
89 |
90 |
91 |
95 | Sign Message
96 |
97 |
98 |
99 |
100 | Signature
101 |
102 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | Signature
115 |
116 |
121 |
122 |
126 | Verify Message
127 |
128 |
129 |
131 | {{ verifiedMsg.address }} did sign the message {{ verifiedMsg.msg }} .
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
167 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-arrow-left.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/icon-arrow-right.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/logo-shapeshift.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
22 |
23 |
24 |
25 |
29 |
31 |
34 |
37 |
40 |
41 |
42 |
46 |
48 |
49 |
50 |
51 |
53 |
54 |
56 |
57 |
58 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-08.svg:
--------------------------------------------------------------------------------
1 | onboarding_icons
--------------------------------------------------------------------------------
/Modulo 3 - Crear un Contrato Inteligente/etherwallet-v3.11.2.4/images/onboarding_icon-01.svg:
--------------------------------------------------------------------------------
1 | onboarding_icon-01
--------------------------------------------------------------------------------