Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 3 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,8 @@ signed_tx = tx.sign("0xYourPrivateKey...")
tx_hash = w3.eth.send_raw_transaction(signed_tx.encode())
```

### Legacy API (Backwards Compatible)

```python
from pytempo import patch_web3_for_tempo, create_tempo_transaction
from web3 import Web3

# Step 1: Patch web3.py to add Tempo support
# (Only needed if using web3's internal transaction parsing)
patch_web3_for_tempo()

# Step 2: Use web3.py normally with Tempo features
w3 = Web3(Web3.HTTPProvider("https://rpc.testnet.tempo.xyz"))
account = w3.eth.account.from_key("0x...")

# Step 3: Create Tempo AA transaction (Type 0x76)
tx = create_tempo_transaction(
to="0xRecipient...",
value=0,
gas=100000,
max_fee_per_gas=w3.eth.gas_price * 2,
max_priority_fee_per_gas=w3.eth.gas_price,
nonce=w3.eth.get_transaction_count(account.address),
chain_id=w3.eth.chain_id,
fee_token="0x20c0000000000000000000000000000000000001", # AlphaUSD
)

# Step 4: Sign and send using standard web3.py
tx.sign(account.key.hex())
tx_hash = w3.eth.send_raw_transaction(tx.encode())
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
```
The legacy API (`create_tempo_transaction`, `patch_web3_for_tempo`) was removed in
`v0.3.0`. Use the typed API shown above.

## Typed API (v0.2.1+)

Expand Down Expand Up @@ -152,42 +123,6 @@ h = as_hash32("0x" + "ab" * 32) # -> bytes (32)
data = as_bytes("0xabcdef") # -> b'\xab\xcd\xef'
```

## Legacy Usage

### Basic Transaction

```python
from pytempo import create_tempo_transaction

tx = create_tempo_transaction(
to="0xRecipient...",
value=1000000000000000,
gas=100000,
max_fee_per_gas=2000000000,
max_priority_fee_per_gas=2000000000,
nonce=0,
chain_id=42429,
)

tx.sign("0xYourPrivateKey...")
encoded = tx.encode()
```

### With Custom Fee Token

```python
tx = create_tempo_transaction(
to="0xRecipient...",
value=0,
fee_token="0xTokenAddress...", # Pay gas in this ERC-20 token
gas=100000,
max_fee_per_gas=2000000000,
max_priority_fee_per_gas=2000000000,
nonce=0,
chain_id=42429,
)
```

### Gas Sponsorship

```python
Expand Down Expand Up @@ -313,32 +248,6 @@ EIP-2930 access list entry.

- `AccessListItem.create(address, storage_keys=())` - Create with type coercion

### `patch_web3_for_tempo()`

Monkey patches web3.py to recognize Tempo AA transactions. **Must be called before using web3**.

### `create_tempo_transaction(...)` (Legacy)

Creates a mutable Tempo AA transaction.

**Parameters:**

- `to` (str): Destination address
- `value` (int): Value in wei (default: 0)
- `gas` (int): Gas limit
- `max_fee_per_gas` (int): Maximum fee per gas
- `max_priority_fee_per_gas` (int): Maximum priority fee per gas
- `nonce` (int): Transaction nonce
- `chain_id` (int): Chain ID
- `nonce_key` (int): Nonce key for parallel execution (default: 0)
- `fee_token` (str, optional): ERC-20 token address for gas payment
- `calls` (list, optional): List of calls for batching
- `data` (str, optional): Transaction data
- `valid_before` (int, optional): Timestamp before which tx is valid
- `valid_after` (int, optional): Timestamp after which tx becomes valid

**Returns:** `LegacyTempoTransaction`

## Development

```bash
Expand All @@ -354,8 +263,7 @@ make check # Run all checks (lint + format-check + test)
See the `examples/` directory:

- `simple_send.py` - Simple value transfer
- `basic_transaction.py` - Transaction with fee token
- `fee_payer_sponsored.py` - Gas sponsorship and call batching
- `batch_calls.py` - Batch multiple calls

## Contributing

Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Sphinx configuration for pytempo."""

from pytempo import __version__

project = "pytempo"
copyright = "2025, Tempo"
author = "Tempo"
release = "0.3.0"
release = __version__

extensions = [
"sphinx.ext.autodoc",
Expand Down
2 changes: 1 addition & 1 deletion pytempo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
as_optional_address,
)

__version__ = "0.3.0"
__version__ = "0.3.1"

__all__ = [
# Types
Expand Down
40 changes: 40 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Version consistency tests."""

import re
import runpy
from pathlib import Path

from pytempo import __version__

ROOT = Path(__file__).resolve().parent.parent


def _project_version() -> str:
pyproject = ROOT / "pyproject.toml"
in_project_section = False
version_re = re.compile(r'^version\s*=\s*"([^"]+)"\s*$')

for raw_line in pyproject.read_text().splitlines():
line = raw_line.strip()

if line.startswith("[") and line.endswith("]"):
in_project_section = line == "[project]"
continue

if not in_project_section:
continue

match = version_re.match(line)
if match:
return match.group(1)

raise AssertionError("Unable to find [project].version in pyproject.toml")


def test_package_version_matches_pyproject() -> None:
assert __version__ == _project_version()


def test_docs_release_matches_package_version() -> None:
conf_vars = runpy.run_path(str(ROOT / "docs" / "conf.py"))
assert conf_vars["release"] == __version__
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.