Ethereum Contract
=================
`Build Status <https://circleci.com/gh/ethereum/eth-abi>`__
`Documentation
Status <https://readthedocs.org/projects/eth-abi/?badge=latest>`__ `PyPi
version <https://pypi.python.org/pypi/eth-abi>`__
Python utilities for working with the Ethereum ABI
Installation
------------
.. code:: sh
pip install eth-abi
Documentation
-------------
Decoding
~~~~~~~~
These functions are intended for decoding return values from the EVM.
- ``eth_abi.decode_single(type, data)``
This function tries to decode ``data`` into the python type that
corresponds to the provided ``type``. This function accepts data of type
bytes.
.. code-block:: python
::
>>> decode_single('uint256', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009')
12345
The **value** parameter is expected to be one of the recognized EVM
types.
.. note:: This function cannot be used to decode dynamic or array types
such as ``bytes32[]``.
- ``eth_abi.decode_abi(types, data)``
This function decodes ``data`` into the python type corresponding to the
provided ``types``. This function accepts arrays of type byte.
.. code-block:: python
::
>>> decode_abi(['uint256'], b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009')
[12345]
>>> decode_abi(['bytes32', 'bytes32'], b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
['a', 'b']
The **values** parameter is expected to be an iterable whose values are
all one of the recognized EVM types.
Encoding
~~~~~~~~
These functions are intended for encoding python values into
representations that are suitable for interacting with the EVM.
- ``eth_abi.encode_single(type, value)``
This function encodes ``value`` in the ABI encoding for the provided
``type``.
.. code-block:: python
::
>>> encode_single('uint256', 12345)
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009'
The **value** parameter is expected to be one of the recognized EVM
types.
.. note:: This function cannot be used to encode array types such as
``bytes32[]``.
- ``eth_abi.encode_abi(types, values)``
This function encodes ``values`` in the ABI encoding for the
corresponding type provided by the ``types`` argument.
.. code-block:: python
::
>>> encode_abi(['uint256'], [12345])
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009'
>>> encode_abi(['bytes32', 'bytes32'], ['a', 'b'])
b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
The **values** parameter is expected to be an iterable whose values are
all one of the recognized EVM types.
Development
-----------
Clone the repository and then run:
.. code:: sh
pip install -e . -r requirements-dev.txt
Running the tests
~~~~~~~~~~~~~~~~~
You can run the tests with:
.. code:: sh
py.test tests
Or you can install ``tox`` to run the full test suite.
Releasing
~~~~~~~~~
Pandoc is required for transforming the markdown README to the proper
format to render correctly on pypi.
For Debian-like systems:
::
apt install pandoc
Or on OSX:
.. code:: sh
brew install pandoc
To release a new version:
.. code:: sh
make release bump=$$VERSION_PART_TO_BUMP$$
How to bumpversion
^^^^^^^^^^^^^^^^^^
The version format for this repo is ``{major}.{minor}.{patch}`` for
stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable
(``stage`` can be alpha or beta).
To issue the next version in line, specify which part to bump, like
``make release bump=minor`` or ``make release bump=devnum``.
If you are in a beta version, ``make release bump=stage`` will switch to
a stable.
To issue an unstable version when the current version is stable, specify
the new version explicitly, like
``make release bump="--new-version 4.0.0-alpha.1 devnum"``
=================
`Build Status <https://circleci.com/gh/ethereum/eth-abi>`__
`Documentation
Status <https://readthedocs.org/projects/eth-abi/?badge=latest>`__ `PyPi
version <https://pypi.python.org/pypi/eth-abi>`__
Python utilities for working with the Ethereum ABI
Installation
------------
.. code:: sh
pip install eth-abi
Documentation
-------------
Decoding
~~~~~~~~
These functions are intended for decoding return values from the EVM.
- ``eth_abi.decode_single(type, data)``
This function tries to decode ``data`` into the python type that
corresponds to the provided ``type``. This function accepts data of type
bytes.
.. code-block:: python
::
>>> decode_single('uint256', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009')
12345
The **value** parameter is expected to be one of the recognized EVM
types.
.. note:: This function cannot be used to decode dynamic or array types
such as ``bytes32[]``.
- ``eth_abi.decode_abi(types, data)``
This function decodes ``data`` into the python type corresponding to the
provided ``types``. This function accepts arrays of type byte.
.. code-block:: python
::
>>> decode_abi(['uint256'], b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009')
[12345]
>>> decode_abi(['bytes32', 'bytes32'], b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
['a', 'b']
The **values** parameter is expected to be an iterable whose values are
all one of the recognized EVM types.
Encoding
~~~~~~~~
These functions are intended for encoding python values into
representations that are suitable for interacting with the EVM.
- ``eth_abi.encode_single(type, value)``
This function encodes ``value`` in the ABI encoding for the provided
``type``.
.. code-block:: python
::
>>> encode_single('uint256', 12345)
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009'
The **value** parameter is expected to be one of the recognized EVM
types.
.. note:: This function cannot be used to encode array types such as
``bytes32[]``.
- ``eth_abi.encode_abi(types, values)``
This function encodes ``values`` in the ABI encoding for the
corresponding type provided by the ``types`` argument.
.. code-block:: python
::
>>> encode_abi(['uint256'], [12345])
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0009'
>>> encode_abi(['bytes32', 'bytes32'], ['a', 'b'])
b'a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
The **values** parameter is expected to be an iterable whose values are
all one of the recognized EVM types.
Development
-----------
Clone the repository and then run:
.. code:: sh
pip install -e . -r requirements-dev.txt
Running the tests
~~~~~~~~~~~~~~~~~
You can run the tests with:
.. code:: sh
py.test tests
Or you can install ``tox`` to run the full test suite.
Releasing
~~~~~~~~~
Pandoc is required for transforming the markdown README to the proper
format to render correctly on pypi.
For Debian-like systems:
::
apt install pandoc
Or on OSX:
.. code:: sh
brew install pandoc
To release a new version:
.. code:: sh
make release bump=$$VERSION_PART_TO_BUMP$$
How to bumpversion
^^^^^^^^^^^^^^^^^^
The version format for this repo is ``{major}.{minor}.{patch}`` for
stable, and ``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable
(``stage`` can be alpha or beta).
To issue the next version in line, specify which part to bump, like
``make release bump=minor`` or ``make release bump=devnum``.
If you are in a beta version, ``make release bump=stage`` will switch to
a stable.
To issue an unstable version when the current version is stable, specify
the new version explicitly, like
``make release bump="--new-version 4.0.0-alpha.1 devnum"``
Metadata
Release files for eth-abi 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eth-abi-1.2.0.tar.gz | 19.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eth_abi-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.4 kB
Release files / eth-abi-1.2.0.tar.gz
| Download URL | eth-abi-1.2.0.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd8ff5a21d710fa6751190992fd3483ba21d57e53cb1092f091dfeea29f66ba4
|
|
BLAKE2b-256 checksum How to use checksums |
503b23c1b88bc52ea1449ed8acc2d28660b5dc39b2cbcc113efc75982149bb09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Release files / eth_abi-1.2.0-py3-none-any.whl
| Download URL | eth_abi-1.2.0-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d893f8c8732e53c39338ef0a813732c1b1869db9d3e1fd096c1968ae8afbab9c
|
|
BLAKE2b-256 checksum How to use checksums |
3d4e66d711f39c892c295cd61d2a241d26e4fa253e483382bdb34e39ea4c4d96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|