eth-event


Nameeth-event JSON
Version 1.2.3 PyPI version JSON
download
home_pagehttps://github.com/iamdefinitelyahuman/eth-event
SummaryEthereum event decoder and topic generator
upload_time2021-04-16 16:48:05
maintainer
docs_urlNone
authorBenjamin Hauser
requires_python>=3.6, <4
licenseMIT
keywords ethereum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # eth-event

[![Pypi Status](https://img.shields.io/pypi/v/eth-event.svg)](https://pypi.org/project/eth-event/) [![Build Status](https://img.shields.io/github/workflow/status/iamdefinitelyahuman/eth-event/main%20workflow)](https://github.com/iamdefinitelyahuman/eth-event/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/iamdefinitelyahuman/eth-event)](https://codecov.io/gh/iamdefinitelyahuman/eth-event)

Tools for Ethereum event decoding and topic generation.

## Installation

You can install the latest release via `pip`:

```bash
pip install eth-event
```

Or clone the repository and use `setuptools` for the most up-to-date version:

```bash
git clone https://github.com/iamdefinitelyahuman/eth-event.git
cd eth-event
python3 setup.py install
```

## Usage

The public API is well documented within the docstrings. The following example may also help:

```python
>>> from eth_event import get_topics

# generating a topic map
>>> abi = open('abi.json').read()
>>> topic_map = get_topic_map(abi)
>>> topic_map
{
    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef': {
        'name': 'Transfer',
        'inputs': [
            {'name': 'from', 'type': 'address', 'indexed': True},
            {'name': 'to', 'type': 'address', 'indexed': True},
            {'name': 'value', 'type': 'uint256', 'indexed': False}
        ]
    }
}

# decoding event logs from a transaction receipt
>>> tx = token.transfer(account[1], 100, {'from': account[0]})
<Transaction object '0x615a157e84715d5f960a38fe2a3ddb566c8393cfc71f15b06170a0eff74dfdde'>
>>> eth_event.decode_logs(tx.logs, topic_map)
[{
    'name': 'Transfer',
    'address': "0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87",
    'data': [
        {'name': 'from', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},
        {'name': 'to', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},
        {'name': 'tokens', 'type': 'uint256', 'value': 100, 'decoded': True}
    ],
}]

# decoding a structLog from Geth's debug_traceTransaction endpoint
>>> trace = web3.provider.make_request(
    "debug_traceTransaction",
    ['0x615a157e84715d5f960a38fe2a3ddb566c8393cfc71f15b06170a0eff74dfdde', {}]
)
>>> struct_log = trace['result']['structLogs']

>>> eth_event.decode_trace(struct_log, topic_map, initial_address="0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87")
[{
    'name': 'Transfer',
    'address': "0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87",
    'data': [
        {'name': 'from', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},
        {'name': 'to', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},
        {'name': 'tokens', 'type': 'uint256', 'value': 100, 'decoded': True}
    ],
}]
```

## Limitations

* If an array is indexed in an event, the topic is generated as a sha3 hash and so cannot be decrypted. In this case, the unencrypted topic is returned and `decoded` is set to `False`.

* Anonymous events cannot be decoded. Use the `allow_undecoded` kwarg when calling `decode_logs` and `decode_trace` to receive the undecoded log without raising an exception.

* When decoding a trace, the initial address for the call cannot be determined. To include addresses where decoded events were emitted you must supply the initial address with the `initial_address` keyword argument.

## Tests

To run the test suite:

```bash
$ tox
```

## Development

This project is still in development. Comments, questions, criticisms and pull requests are welcomed.

## License

This project is licensed under the [MIT license](LICENSE).



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iamdefinitelyahuman/eth-event",
    "name": "eth-event",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6, <4",
    "maintainer_email": "",
    "keywords": "ethereum",
    "author": "Benjamin Hauser",
    "author_email": "ben@hauser.id",
    "download_url": "https://files.pythonhosted.org/packages/36/97/e67f6a0dd0b2b0563868c084005a553ce6ee0626766af8a33ed259579027/eth-event-1.2.3.tar.gz",
    "platform": "",
    "description": "# eth-event\n\n[![Pypi Status](https://img.shields.io/pypi/v/eth-event.svg)](https://pypi.org/project/eth-event/) [![Build Status](https://img.shields.io/github/workflow/status/iamdefinitelyahuman/eth-event/main%20workflow)](https://github.com/iamdefinitelyahuman/eth-event/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/iamdefinitelyahuman/eth-event)](https://codecov.io/gh/iamdefinitelyahuman/eth-event)\n\nTools for Ethereum event decoding and topic generation.\n\n## Installation\n\nYou can install the latest release via `pip`:\n\n```bash\npip install eth-event\n```\n\nOr clone the repository and use `setuptools` for the most up-to-date version:\n\n```bash\ngit clone https://github.com/iamdefinitelyahuman/eth-event.git\ncd eth-event\npython3 setup.py install\n```\n\n## Usage\n\nThe public API is well documented within the docstrings. The following example may also help:\n\n```python\n>>> from eth_event import get_topics\n\n# generating a topic map\n>>> abi = open('abi.json').read()\n>>> topic_map = get_topic_map(abi)\n>>> topic_map\n{\n    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef': {\n        'name': 'Transfer',\n        'inputs': [\n            {'name': 'from', 'type': 'address', 'indexed': True},\n            {'name': 'to', 'type': 'address', 'indexed': True},\n            {'name': 'value', 'type': 'uint256', 'indexed': False}\n        ]\n    }\n}\n\n# decoding event logs from a transaction receipt\n>>> tx = token.transfer(account[1], 100, {'from': account[0]})\n<Transaction object '0x615a157e84715d5f960a38fe2a3ddb566c8393cfc71f15b06170a0eff74dfdde'>\n>>> eth_event.decode_logs(tx.logs, topic_map)\n[{\n    'name': 'Transfer',\n    'address': \"0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87\",\n    'data': [\n        {'name': 'from', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},\n        {'name': 'to', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},\n        {'name': 'tokens', 'type': 'uint256', 'value': 100, 'decoded': True}\n    ],\n}]\n\n# decoding a structLog from Geth's debug_traceTransaction endpoint\n>>> trace = web3.provider.make_request(\n    \"debug_traceTransaction\",\n    ['0x615a157e84715d5f960a38fe2a3ddb566c8393cfc71f15b06170a0eff74dfdde', {}]\n)\n>>> struct_log = trace['result']['structLogs']\n\n>>> eth_event.decode_trace(struct_log, topic_map, initial_address=\"0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87\")\n[{\n    'name': 'Transfer',\n    'address': \"0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87\",\n    'data': [\n        {'name': 'from', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},\n        {'name': 'to', 'type': 'address', 'value': '0xbd4940951bfa463f8fb6db762e55686f6cfdb73a', 'decoded': True},\n        {'name': 'tokens', 'type': 'uint256', 'value': 100, 'decoded': True}\n    ],\n}]\n```\n\n## Limitations\n\n* If an array is indexed in an event, the topic is generated as a sha3 hash and so cannot be decrypted. In this case, the unencrypted topic is returned and `decoded` is set to `False`.\n\n* Anonymous events cannot be decoded. Use the `allow_undecoded` kwarg when calling `decode_logs` and `decode_trace` to receive the undecoded log without raising an exception.\n\n* When decoding a trace, the initial address for the call cannot be determined. To include addresses where decoded events were emitted you must supply the initial address with the `initial_address` keyword argument.\n\n## Tests\n\nTo run the test suite:\n\n```bash\n$ tox\n```\n\n## Development\n\nThis project is still in development. Comments, questions, criticisms and pull requests are welcomed.\n\n## License\n\nThis project is licensed under the [MIT license](LICENSE).\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ethereum event decoder and topic generator",
    "version": "1.2.3",
    "split_keywords": [
        "ethereum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "7ae3490ab7afa626b80d563584e38e0e",
                "sha256": "5d86d049eded86d0fb41538590487e1ccea2e1fa3e6d16ee2fc0952be7e5c59a"
            },
            "downloads": -1,
            "filename": "eth_event-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ae3490ab7afa626b80d563584e38e0e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6, <4",
            "size": 7260,
            "upload_time": "2021-04-16T16:48:03",
            "upload_time_iso_8601": "2021-04-16T16:48:03.615831Z",
            "url": "https://files.pythonhosted.org/packages/87/cc/50f1b6482f72204e87a505dde4d31752b9ac24c7291b24dd66e927a2f3a3/eth_event-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "dad71c847d0bb709b9dd736181c31f09",
                "sha256": "1589b583a9b0294f9aba4dedce8077685ced298393872f7f19bbf7d67ed9e49a"
            },
            "downloads": -1,
            "filename": "eth-event-1.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "dad71c847d0bb709b9dd736181c31f09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6, <4",
            "size": 7109,
            "upload_time": "2021-04-16T16:48:05",
            "upload_time_iso_8601": "2021-04-16T16:48:05.726422Z",
            "url": "https://files.pythonhosted.org/packages/36/97/e67f6a0dd0b2b0563868c084005a553ce6ee0626766af8a33ed259579027/eth-event-1.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-16 16:48:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "iamdefinitelyahuman",
    "github_project": "eth-event",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "eth-event"
}
        
Elapsed time: 0.02766s