Skip to main content

# Ethereum Contract

[![Build Status](https://circleci.com/gh/ethereum/eth-abi.svg?style=shield)](https://circleci.com/gh/ethereum/eth-abi) [![Documentation Status](https://readthedocs.org/projects/eth-abi/badge/?version=latest)](https://readthedocs.org/projects/eth-abi/?badge=latest) [![PyPi version](https://img.shields.io/pypi/v/eth-abi.svg)](https://pypi.python.org/pypi/eth-abi)

Python utilities for working with the Ethereum ABI

## Installation

`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.

>>> 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.

  • 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.

>>> 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.

>>> 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.

  • eth_abi.encode_abi(types, values)

This function encodes values in the ABI encoding for the corresponding type provided by the types argument.

>>> 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:

`sh pip install -e . -r requirements-dev.txt `

### Running the tests

You can run the tests with:

`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:

`sh brew install pandoc `

To release a new version:

`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 veriteos-eth-abi 1.2.0.post0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for veriteos-eth-abi 1.2.0.post0
File Size Uploaded Provenance Actions
veriteos-eth-abi-1.2.0.post0.tar.gz 44.3 kB Without provenance Details for veriteos-eth-abi-1.2.0.post0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for veriteos-eth-abi 1.2.0.post0
File Interpreter ABI Platform Actions
veriteos_eth_abi-1.2.0.post0-py2-none-any.whl Python 2 none any Details for veriteos_eth_abi-1.2.0.post0-py2-none-any.whl

Total release size: 65.1 kB

Release files / veriteos-eth-abi-1.2.0.post0.tar.gz

Download URL veriteos-eth-abi-1.2.0.post0.tar.gz
Size 44.3 kB
Tags Source
SHA-256 checksum
How to use checksums
70f12fa50917c198b1406dc695b96e257b6dc9885ca2d04931383e57be0b3b46
BLAKE2b-256 checksum
How to use checksums
e5ed63914c131201844e2935d0835c3b0daebeea7c1fb2373f7b9bd0ef6000ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.5

Release files / veriteos_eth_abi-1.2.0.post0-py2-none-any.whl

Download URL veriteos_eth_abi-1.2.0.post0-py2-none-any.whl
Size 20.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
a35952df26b2ecc28fc7bbcd2093fa137d6b20271e47d2c4b814a47c750fded8
BLAKE2b-256 checksum
How to use checksums
1a903410db6d2c15255dc7551b3771d868875dfe8ff787486ac5d206eebe32a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.5

Security for veriteos-eth-abi 1.2.0.post0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.0.post0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page