{ "info": { "author": "Yaz Khoury", "author_email": "yaz.khoury@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# ![nakamoto logo](https://s3.amazonaws.com/occupied-mars/crypto/logo.png) Nakamoto: A Python Library for Quantifying Decentralization\n\nA Python library for measuring the Nakamoto Coefficient of a Sector.\nBased on the post [\"Quantifying Dectralization\"](https://news.earn.com/quantifying-decentralization-e39db233c28e?gi=26ec1a01794a)\n\n![nakamoto plot](https://s3.amazonaws.com/occupied-mars/crypto/plot.png)\n\nFeatures:\n- Nakamoto Coefficient Measurement\n- [Gini](https://www.investopedia.com/terms/g/gini-index.asp) Coefficient Measurement\n- Lorenz Curve Plot on [Plotly](https://plot.ly/)\n- Decentralization Plot (Lorenz + Nakamoto Features)\n- Custom + Built In Sectors (See Sectors section)\n\n## Installation Instructions\n\n```\n$ pip install nakamoto\n```\n\n## Running Tests\n\nMake sure to sign up for Plotly to get an API Key, as well as get a Github API Key.\nGithub and Market URL Environment Variables aren't required to run full test script below.\n\n```\nPLOT_NOTEBOOK=1 PLOT_IMAGE_PATH=image.png GITHUB_URL=Z python3 test.py\n```\n\n## Sectors\n\nWe need to specify if we want to run this in a Jupyter Notebook or save the plot images.\nWe can save the config in a dictionary like this:\n```\nnakamoto_config = {\n 'plot_notebook': TRUE,\n 'plot_image_path': \"image.png\"\n}\n```\nwhere `PLOT_NOTEBOOK` and `PLOT_IMAGE_PATH` are the values you ge.\n\n### Custom Sectors\nThis module allows passing a numpy array of data to be processed in order to measure inequality distribution (gini) and decentralization\n(nakamoto coefficient). We use `CustomSector` for that. \n\nWe can generate sample data for our gini and lorenz curve via the following command, which appends 2 Poisson random samples to \nget a skewed dataset. We will also name a currency here, which we will use `ETC` for.:\n```python\nrandom_data = np.append(np.random.poisson(lam=10, size=40), \n np.random.poisson(lam=100, size=10))\n\ncurrency = 'ETC'\n```\n\nNow, we will generate the `CustomSector` object using those variables:\n\n```python\nfrom nakamoto.sector import CustomSector\n\ncustom_sector = CustomSector(random_data, \n currency, \n 'custom_sector_type',\n **nakamoto_config)\n```\nwhere `'custom_sector_type'` is a string describing the sector type. For example, if the data I'm passing into the `CustomSector`\nclass is about mining rewards, I can just call the type `mining_rewards`.\n\nTo first get the Gini coefficient, we run the following command:\n\n```python\ngini = custom_sector.get_gini_coefficient()\nprint(gini)\n```\n\n```shell\n$ 0.5093952180028129535951653520 \n```\n\nTo get the Nakamoto coefficient, we run the following command:\n\n```python\nnakamoto = custom_sector.get_nakamoto_coefficient()\nprint(nakamoto)\n```\n```shell\n$ 7\n```\n\nTo generate the Plotly graph and get the URL for the graph, we run this command:\n```python\nplot = custom_sector.get_plot()\n```\n![nakamoto plot 2](https://s3.amazonaws.com/occupied-mars/crypto/plot2.png)\n\n### Repository\nMeasures Github contributions of all who contribute to a specific repository and determines\nhow decentralized the repository is and the minimum number of developers needed to compromise it.\n\nIn order to get started, you first need to get a [\"Github API Key\"](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/).\n\nYou also need to find a github repository url that you want to analyze for decentralization.\n\nIn this example, I'll be using IOHK's [\"Mantis Client\"](https://github.com/input-output-hk/mantis) for Ethereum Classic.\n\n```python\nfrom nakamoto.sector import Repository\n\ngithub_url = \"https://github.com/input-output-hk/mantis\"\ngithub_api = YOUR_GITHUB_API\nrepository = Repository(currency, github_api, github_url, **nakamoto_config)\n```\n\n`Repository` class will automatically analyze the github url data for you, so you can just call then `.get_nakamoto_coefficient()`\n& `.get_gini_coefficient()` on `repository`. It also supports `.get_plot_url()` like `CustomSector`.\n\n\n### Market\nMeasures volume by cryptocurrency exchange using data from CoinMarketCap for a specific currency.\nMeasures how centralized exchanges are in respect to a particular volume of a cryptocurrency and \nminimum exchanges needed to centralize volume.\n\nNote: You need the #market link for your currency for CoinMarketCap. In this example, I use the Ethereum Classic Market URL:\n\n```python\nfrom nakamoto.sector import Market\n\nmarket_url = 'https://coinmarketcap.com/currencies/ethereum-classic/#markets'\nmarket = Market(currency, market_url, **nakamoto_config)\n```\n\nSame methods to generate Gini, Nakamoto, and Lorenz Curve like `CustomSector`.\n\n\n### Client \nMeasures decentralization by client usage. Currently scrapes data for combined EVM nodes. Future versions aim to separate the data \nand have more coins. For now, only 2 currencies you can pass it are `ETC` and `ETH`. It only calculates combined EVM nodes.\nFuture versions will have a separation between EVM chains and will include BTC. Pull Requests welcome!\n\n```python\nfrom nakamoto.sector import Client\n\nclient = Client(currency, **nakamoto_config)\n```\n\nSame methods to generate Gini, Nakamoto, and Lorenz Curve like `CustomSector`.\n\n\n### Geography\nMeasures miner decentralization by country. Sames as `Client`, measures for combined EVM nodes. Future versions aim to separate \nthe data and have more coins. For now, only 2 currencies you can pass it are `ETC` and `ETH`. It only calculates combined EVM nodes.\nFuture versions will have a separation between EVM chains and will include BTC. Pull Requests welcome!\n\n```python\nfrom nakamoto.sector import Geography\n\ngeography = Geography(currency, **nakamoto_config)\n```\n\nSame methods to generate Gini, Nakamoto, and Lorenz Curve like `CustomSector`.\n\n\n## Nakamoto Coefficient Class\n\nThe `Nakamoto` class can take in a list of sectors that you created above and can generate an analysis\nover the entire ecosystem. \n\nIt returns back 2 things:\n1. Minimum Nakamoto: This is the minimum nakamoto of each sector's nakamoto, highlighting the most vulnerable sector as measured by\nthe number of entities needed to compromise it.\n2. Maximum Gini: This shows the highest gini coefficient, indicating the sector with the highest distribution of inequality, indicating a centralization point.\n\nYou can also generate a nice dataframe summary of all the sectors.\n\n```python\nfrom nakamoto.coefficient import Nakamoto\n\n\nsector_list = [geography, \n market, \n client, \n repository, \n custom_sector]\nnakamoto = Nakamoto(sector_list)\n```\n\nNow, let's get the maximum gini and accompanying sector id\n```python\nnakamoto.get_maximum_gini()\n```\n\nTo get the minimum nakamoto coefficient, we execute the `.get_minimum_nakamoto()` method.\n```python\nnakamoto.get_minimum_nakamoto()\n```\n\nIn order to get a Pandas dataframe summary, use the `.summary()` method.\n```python\nnakamoto.get_summary()\n```\n\n![nakamoto summary](https://s3.amazonaws.com/occupied-mars/crypto/summary.png)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/YazzyYaz/nakamoto-coefficient", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "nakamoto", "package_url": "https://pypi.org/project/nakamoto/", "platform": "", "project_url": "https://pypi.org/project/nakamoto/", "project_urls": { "Homepage": "https://github.com/YazzyYaz/nakamoto-coefficient" }, "release_url": "https://pypi.org/project/nakamoto/0.1.4.1/", "requires_dist": null, "requires_python": "", "summary": "Python Library to Generate Nakamoto Coefficient", "version": "0.1.4.1" }, "last_serial": 4787835, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "c6d8d790fca68c87d1aa336e4d9fba18", "sha256": "d21d389a6af37749015b4bd63c1164f2fb3122a6b0a369f65e7a6c618cec6244" }, "downloads": -1, "filename": "nakamoto-0.1.tar.gz", "has_sig": false, "md5_digest": "c6d8d790fca68c87d1aa336e4d9fba18", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2040, "upload_time": "2019-01-23T00:08:51", "url": "https://files.pythonhosted.org/packages/06/60/b52af5957669721f716b8fc96a4d53540055d3b6d727bb9b780fb0976a78/nakamoto-0.1.tar.gz" } ], "0.1.1.1": [ { "comment_text": "", "digests": { "md5": "47ae6cc3270213128d7e956bf6280d93", "sha256": "a84d45e659bd47ad4e7c429876b7646e109dadf99980e3e5d293f34c6fa85df1" }, "downloads": -1, "filename": "nakamoto-0.1.1.1.tar.gz", "has_sig": false, "md5_digest": "47ae6cc3270213128d7e956bf6280d93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2320, "upload_time": "2019-01-25T19:44:39", "url": "https://files.pythonhosted.org/packages/d6/03/7afc629be3aa4a1cc1a7d8612bb079294159e7caebb4efc0872fd2196b03/nakamoto-0.1.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "8664bd8ac233f27d4f8c13bed8daeba7", "sha256": "b44166c19362e65fe028b21777755998f8811a2ea407ba8e871e256855276238" }, "downloads": -1, "filename": "nakamoto-0.1.2.tar.gz", "has_sig": false, "md5_digest": "8664bd8ac233f27d4f8c13bed8daeba7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4166, "upload_time": "2019-01-28T06:10:11", "url": "https://files.pythonhosted.org/packages/42/29/5016062669cad838c7a470722a4877b0bd485e10442e47932e515188b429/nakamoto-0.1.2.tar.gz" } ], "0.1.2.1": [ { "comment_text": "", "digests": { "md5": "214fd1b39b851e5f242651ee64c32e67", "sha256": "ceb454267ce05f16577eebce3d393b716aa9e2baa4ac375e5bd0274995775af3" }, "downloads": -1, "filename": "nakamoto-0.1.2.1.tar.gz", "has_sig": false, "md5_digest": "214fd1b39b851e5f242651ee64c32e67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9199, "upload_time": "2019-01-28T06:29:25", "url": "https://files.pythonhosted.org/packages/de/f9/b7fda23706a126daa41a386de5aa2e4f44d8d2c2ab090bfe8a033897c136/nakamoto-0.1.2.1.tar.gz" } ], "0.1.2.2": [ { "comment_text": "", "digests": { "md5": "39fecb9d68b5d36bccab3a1aafa050c4", "sha256": "ac1e563fe655377e583671ff9d43edfba328c5201164f424d972c194d45b0a6f" }, "downloads": -1, "filename": "nakamoto-0.1.2.2.tar.gz", "has_sig": false, "md5_digest": "39fecb9d68b5d36bccab3a1aafa050c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9232, "upload_time": "2019-01-28T18:11:16", "url": "https://files.pythonhosted.org/packages/e6/7d/c1bd19c40e504644aa3bf91e7c22bac9a3f63b5bfc5e13e0db8fda672c18/nakamoto-0.1.2.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b2d5bace4eac9eb64bd8deea6fb34457", "sha256": "7dbfaa83d5c30ca4c555c4a8270c60ab82418fd4ec5ba8d6b3b01f00dcf37c1b" }, "downloads": -1, "filename": "nakamoto-0.1.3.tar.gz", "has_sig": false, "md5_digest": "b2d5bace4eac9eb64bd8deea6fb34457", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10268, "upload_time": "2019-01-30T21:42:00", "url": "https://files.pythonhosted.org/packages/27/48/08e597bddc08b4729f1a552d7174fa8e18dbcbfacc6320f8bad27db3ac85/nakamoto-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "525133b512e4e98d9f5157fffb3b9534", "sha256": "c29101e7c46a8274ac6132d33109f61d40984e4b8da34ca7904107ec6fc6f0ac" }, "downloads": -1, "filename": "nakamoto-0.1.4.tar.gz", "has_sig": false, "md5_digest": "525133b512e4e98d9f5157fffb3b9534", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10327, "upload_time": "2019-02-06T04:39:45", "url": "https://files.pythonhosted.org/packages/12/70/00a4d9eecc72931d5324d9e9c0d5495debc811f69b71a9c5fe7555916c78/nakamoto-0.1.4.tar.gz" } ], "0.1.4.1": [ { "comment_text": "", "digests": { "md5": "3ceaca3ffae311015f90acb2d333bcce", "sha256": "6ac4b385ac847e0abd4c545a9fb7f60a072a40a122bd6bfef328dbfff3aff3b7" }, "downloads": -1, "filename": "nakamoto-0.1.4.1.tar.gz", "has_sig": false, "md5_digest": "3ceaca3ffae311015f90acb2d333bcce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10325, "upload_time": "2019-02-06T18:02:10", "url": "https://files.pythonhosted.org/packages/93/b6/87f4d96ccd65430336523b206eb49a723536d21b8352ee7f62cce1943891/nakamoto-0.1.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3ceaca3ffae311015f90acb2d333bcce", "sha256": "6ac4b385ac847e0abd4c545a9fb7f60a072a40a122bd6bfef328dbfff3aff3b7" }, "downloads": -1, "filename": "nakamoto-0.1.4.1.tar.gz", "has_sig": false, "md5_digest": "3ceaca3ffae311015f90acb2d333bcce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10325, "upload_time": "2019-02-06T18:02:10", "url": "https://files.pythonhosted.org/packages/93/b6/87f4d96ccd65430336523b206eb49a723536d21b8352ee7f62cce1943891/nakamoto-0.1.4.1.tar.gz" } ] }