{ "info": { "author": "Jason Carver", "author_email": "ut96caarrs@snkmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Topic :: Database :: Front-Ends", "Topic :: Security :: Cryptography", "Topic :: Software Development :: Libraries", "Topic :: System :: Distributed Computing", "Topic :: Utilities" ], "description": "\n# web3utils.py - Some sugar on top of web3.py\n\nweb3utils is a thin layer over [web3.py](https://github.com/pipermerriam/web3.py)\nwith these features:\n\n* immediate access to a `web3` and `eth` object, if you have a standard setup\n* shorter way to call contract functions\n* autoset encoding of input value to `web3.sha3(value)`, if `type(value) == bytes`\n\nThis handful of changes made for quicker shell usage and coding for me. I hope it does for you, too!\n\nI intend to push these pieces upstream to web3.py, if they are open to it.\n\n### Setup\n\n*Note: web3utils requires Python 3*\n\n#### To use the web3utils library\n\n`pip install web3utils`\n\n\n#### To contribute to the web3utils library\n\n```\ngit clone git@github.com/carver/web3utils.py.git\nvirtualenv -p python3 venv\n. venv/bin/activate\npip install -r requirements-dev.txt\npip install -e .\n```\n\n### Usage\n\n#### Instant access to web3 and eth\n\nPrint your primary account balance, denominated in ether:\n\n```\nfrom web3utils import web3, eth\n\nwei = eth.getBalance(eth.accounts[0])\nbalance = web3.fromWei(wei, 'ether')\n\nprint(balance)\n```\n\nCompare this to web3.py:\n```\nfrom web3 import Web3, IPCProvider\n\nweb3 = Web3(IPCProvider())\n\nwei = web3.eth.getBalance(web3.eth.accounts[0])\nbalance = web3.fromWei(wei, 'ether')\n\nprint(balance)\n```\n\nIt's a small imporvement, but nice at the command line.\n\n#### Succinct contract access\n\nSeveral important changes:\n * quicker method calls like `contract.owner()` instead of `contract.call().owner()`\n * encode all method argument strings as utf-8 ([like Solidity](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#argument-encoding))\n * instead of returning `\"0x000...\"` on empty results, return `None`\n\nShort contract calls will be assumed to be read-only (equivalent to `.call()` in web3.py),\nunless it is modified first.\n\nNote that this will *not* prevent you from calling a method that tries to alter state.\nThat state change will just never be sent to the rest of the network as a transaction.\n\nYou can switch back to a transaction like so:\n\n```\ncontract.withdraw(amount, transact={'from': eth.accounts[1], 'gas': 100000, ...})\n```\n\nWhich is equivalent to this web3.py approach:\n\n\n```\ncontract.transact({'from': eth.accounts[1], 'gas': 100000, ...}).withdraw(amount)\n```\n\n### Why is Python 3 required?\n\n*Short version*\n\nIt turns out that the distinction between `str` and `bytes` is important. If\nyou want to write code for the future (Ethereum), don't use a language from the past.\n\n*Long version*\n\nInteracting with the EVM requires clarity on the bits you're using. For example, a sha3 hash expects\nto receive a series of bytes to process. Calculating the sha3 hash of a string is (or should be)\na Type Error; the hash algorithm doesn't know what to do with\na series of characters, aka Unicode code points. As the caller, you need to know which thing you're\ncalculating the hash of:\n1. a series of bytes: `b'[ c$o!\\x91\\xf1\\x8f&u\\xce\\xdb\\x8b(\\x10.\\x95tX'`\n2. the bytes represented by a string in hex format: `'0x5b2063246f2191f18f2675cedb8b28102e957458'`\n3. the bytes generated by encoding a string using utf-8: **Oops, these bytes cannot be read using utf-8**\n4. the bytes generated by encoding a string using utf-16: `'\u205b\u2463\u216f\\uf191\u268f\uce75\u8bdb\u1028\u952e\u5874'`\n\nPython 3 doesn't let you ignore a lot of these details. That's good, because precision with dealing\nwith the EVM is critical. Ether is at stake.\n\nIf you are resistant -- I get it, I've been there. It is not intuitive for most people. But it's\nseriously worth it to [learn about\nencoding](https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/) \nif you're going to develop on top of Ethereum. Your money depends on it!\n\n### Wishlist\n\nFilters can timeout and cause the following exception.\n\nInstead, catch the exception in web3.py and notify watchers with an error\n (or even better, recreate the filter and pick up events where you left off)\n\n```\nException in thread Thread-22:8957\nTraceback (most recent call last):\n File \"/usr/lib/python2.7/threading.py\", line 801, in __bootstrap_inner\n self.run()\n File \"/usr/lib/python2.7/threading.py\", line 754, in run\n self.__target(*self.__args, **self.__kwargs)\n File \"/home/carver/filter_listener/venv/local/lib/python2.7/site-packages/web3/utils/filters.py\", line 84, in _run\n changes = self.web3.eth.getFilterChanges(self.filter_id)\n File \"/home/carver/filter_listener/venv/local/lib/python2.7/site-packages/web3/utils/functional.py\", line 14, in inner\n value = fn(*args, **kwargs)\n File \"/home/carver/filter_listener/venv/local/lib/python2.7/site-packages/web3/eth.py\", line 312, in getFilterChanges\n \"eth_getFilterChanges\", [filter_id],\n File \"/home/carver/filter_listener/venv/local/lib/python2.7/site-packages/web3/providers/manager.py\", line 35, in request_blocking\n raise ValueError(response[\"error\"])\nValueError: {u'message': u'filter not found', u'code': -32000}\n```\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/carver/web3utils.py", "keywords": "ethereum eth web3 web3.py development library", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "web3utils", "package_url": "https://pypi.org/project/web3utils/", "platform": "", "project_url": "https://pypi.org/project/web3utils/", "project_urls": { "Homepage": "https://github.com/carver/web3utils.py" }, "release_url": "https://pypi.org/project/web3utils/0.1.3/", "requires_dist": [ "toolz (<1)", "web3 (==3.11.1)" ], "requires_python": ">=3.5", "summary": "Convenience tools for web3.py", "version": "0.1.3" }, "last_serial": 3115944, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "42e8f2efbdc61561612e493328bb3f36", "sha256": "2e916a7c00b42f68e6d055ab9c8104bd42a4df9e4db3cdfb174089e15a12deac" }, "downloads": -1, "filename": "web3utils-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "42e8f2efbdc61561612e493328bb3f36", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11268, "upload_time": "2017-07-23T23:50:26", "url": "https://files.pythonhosted.org/packages/72/2d/51dac0ec6ea896575749335855191b4a5de366f89c5a09e314b8ad3ac5d9/web3utils-0.0.1-py3-none-any.whl" } ], "0.0.1.dev0": [ { "comment_text": "", "digests": { "md5": "489a8f1b61bec53f1dfbcdf4d814b958", "sha256": "2f2ccb2c934e8d7de4c72088aa8f44804847dd45ea2198c2531c9aea50abc962" }, "downloads": -1, "filename": "web3utils-0.0.1.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "489a8f1b61bec53f1dfbcdf4d814b958", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 9745, "upload_time": "2017-07-23T23:38:52", "url": "https://files.pythonhosted.org/packages/c5/db/0ecedc10d38588b12eace4fd6800883f6f994c20801952c323be2ad426c4/web3utils-0.0.1.dev0-py3-none-any.whl" } ], "0.0.1.dev1": [ { "comment_text": "", "digests": { "md5": "961336a2264b59c5b1127dcfe1b43398", "sha256": "7fb4acad4b309da1b6b7367ac00730fdac77592879036d356e9815ee3b15a26c" }, "downloads": -1, "filename": "web3utils-0.0.1.dev1-py3-none-any.whl", "has_sig": false, "md5_digest": "961336a2264b59c5b1127dcfe1b43398", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11340, "upload_time": "2017-07-23T23:46:15", "url": "https://files.pythonhosted.org/packages/b6/fd/3974fef58f4207ce479bb37f425a82c143107bca9fa0dd31276643b07af9/web3utils-0.0.1.dev1-py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "5711095ecc19357024c4d8da4104a120", "sha256": "602535ee3197c82562baf0e14eed4af49c0f9028e158da47515e85ede12335a8" }, "downloads": -1, "filename": "web3utils-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5711095ecc19357024c4d8da4104a120", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11356, "upload_time": "2017-07-27T03:43:29", "url": "https://files.pythonhosted.org/packages/24/5d/38a58ae146a85cc311b8f5aa11351d7310f293d7064022422a6ef5a7aa42/web3utils-0.0.2-py3-none-any.whl" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "36a12a35235ea9ef9d40f1a00f75ca53", "sha256": "aa3e7b40e87f7cb8ff59cf9cc2e04801cb9dd6faf30d57f5d8ca6c1e742ea016" }, "downloads": -1, "filename": "web3utils-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "36a12a35235ea9ef9d40f1a00f75ca53", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11513, "upload_time": "2017-07-28T02:00:44", "url": "https://files.pythonhosted.org/packages/0d/f2/1baed35c2ddd7df2c41bc2aad52f134255b65407ca90f392182d6693068f/web3utils-0.0.3-py3-none-any.whl" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "a1de677c23c96b41f1db83ee8b7ef485", "sha256": "27ddfdf399b3237efe233124445241a480505556e8a0740f67244c25277bcfad" }, "downloads": -1, "filename": "web3utils-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "a1de677c23c96b41f1db83ee8b7ef485", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11494, "upload_time": "2017-08-10T20:34:20", "url": "https://files.pythonhosted.org/packages/58/a8/9b18790597fb32653a9ec1acb22f141ee629c992cfd1b8506b7d630e5567/web3utils-0.0.4-py3-none-any.whl" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "05b902e8ad461bbab275f2a69f4f2aed", "sha256": "dc0ae14edfa7c6d41d35d5ed3f781e1c3f3e91a59e447b5579d0b4ff55527fbc" }, "downloads": -1, "filename": "web3utils-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "05b902e8ad461bbab275f2a69f4f2aed", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11400, "upload_time": "2017-08-18T20:31:11", "url": "https://files.pythonhosted.org/packages/bb/91/4b9405ca00e80667eb5a8381bd535223a1cc0fb05e64c844701402690106/web3utils-0.0.5-py3-none-any.whl" } ], "0.1.0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1c0dcc0dd7ef0061118df47997d4bbb9", "sha256": "2a53089464823128017349d3d37da8703ddf2869f33b402849f4b66cb021f743" }, "downloads": -1, "filename": "web3utils-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1c0dcc0dd7ef0061118df47997d4bbb9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11612, "upload_time": "2017-08-22T18:48:06", "url": "https://files.pythonhosted.org/packages/ed/26/7a9da6fee06e7ac6433747463e2458d40b1d0bbbd2bbfef19117fb493bba/web3utils-0.1.1-py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "7956b682c03c5fce59442aa8b076d230", "sha256": "03a7ccdfed68819d14c3b44c512c1e31f684378ead60e23478d0d16042f93fd3" }, "downloads": -1, "filename": "web3utils-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7956b682c03c5fce59442aa8b076d230", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 12352, "upload_time": "2017-08-22T20:54:25", "url": "https://files.pythonhosted.org/packages/09/85/c405a2ab4933fa2dc2141f910f36ad68fdeba059a283ec1b6462b321616b/web3utils-0.1.2-py3-none-any.whl" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "48d5e1629ae5f81227eeb9afa2f6d000", "sha256": "4f8a05ad0b36af8b3a6ef0d2d2415511f3f5c3895717c596617b4f293651cf19" }, "downloads": -1, "filename": "web3utils-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "48d5e1629ae5f81227eeb9afa2f6d000", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 12366, "upload_time": "2017-08-22T22:49:52", "url": "https://files.pythonhosted.org/packages/4f/23/97dee20cef1e3043e954607d7d6eb9fe1a1518e3511214f3c3f96dec56e1/web3utils-0.1.3-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "48d5e1629ae5f81227eeb9afa2f6d000", "sha256": "4f8a05ad0b36af8b3a6ef0d2d2415511f3f5c3895717c596617b4f293651cf19" }, "downloads": -1, "filename": "web3utils-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "48d5e1629ae5f81227eeb9afa2f6d000", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 12366, "upload_time": "2017-08-22T22:49:52", "url": "https://files.pythonhosted.org/packages/4f/23/97dee20cef1e3043e954607d7d6eb9fe1a1518e3511214f3c3f96dec56e1/web3utils-0.1.3-py3-none-any.whl" } ] }