Metadata-Version: 2.4
Name: ethpm-types
Version: 0.6.30
Summary: ethpm_types: Implementation of EIP-2678
Author-email: "ApeWorX Ltd." <admin@apeworx.io>
License: Apache-2.0
Project-URL: Homepage, https://github.com/ApeWorX/ethpm-types
Keywords: ethereum
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: <4,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic<3,>=2.9
Requires-Dist: eth-abi<6,>=5.1.0
Requires-Dist: eth-utils<6,>=2.1.0
Requires-Dist: py-cid<0.4,>=0.3.0
Requires-Dist: requests<3,>=2.32.3
Requires-Dist: eth-pydantic-types<0.3,>=0.2.1
Dynamic: license-file

# Quick Start

EthPM is an Ethereum package manifest containing data types for contracts, deployments, and source code using [EIP-2678](https://eips.ethereum.org/EIPS/eip-2678).
The library validates and serializes contract related data and provides JSON schemas.

## Dependencies

- [python3](https://www.python.org/downloads) version 3.9 to 3.12.

## Installation

### via `pip`

You can install the latest release via [`pip`](https://pypi.org/project/pip/):

```bash
pip install ethpm-types
```

### via `setuptools`

You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:

```bash
git clone https://github.com/ApeWorX/ethpm-types.git
cd ethpm-types
python3 setup.py install
```

## Quick Usage

Starting with a dictionary of attribute data, such as a contract instance, you can build an EthPM typed object.

```python
from ethpm_types import ContractInstance

contract = ContractInstance(contractType="ContractClassName", address="0x123...")
print(contract.contract_type)
```

### Contract Type

Perhaps the most common artifact type from `ethmp_types` is `ContractType`.
`ContractType` represents components of a compiled contract, such as the `.abi` or the `.runtime_bytecode`.

```python
from ethpm_types import ContractType

contract = ContractType(abi=[], runtimeBytecode="0x...")
```

For convenience, you can also initialize a `ContractType` using the `.from_signature()` classmethod:

```python
from ethpm_types.abi import MethodABI, EventABI

MethodABI.from_signature("function_name(uint256 arg1)")
# => MethodABI(type='function', name='function_name', inputs=[...], ...)

EventABI.from_signature("Transfer(address indexed from, address indexed to, uint256 value)")
# => EventABI(type='event', name='Transfer', inputs=[...], ...)
```

#### ABI JSON

To easily acquire the ABI JSON for a `ContractType` artifact, `.model_dump_json()` the `.abi` property:

```python
from ethpm_types import ContractType

contract_type = ContractType(abi=[], runtimeBytecode="0x...")

# Use the ABI in other application requiring ABI JSON.
abi = contract_type.abi.model_dump_json()
```
