# contract-attestation (Python SDK)

Python client for the Contract Attestation API — on-chain security attestation for smart contracts (ERC-8004).

## Install

```bash
pip install contract-attestation
# Optional crypto helpers
pip install "contract-attestation[crypto]"
```

## Development Install

```bash
pip install -e .
pip install -e ".[dev]"
# Optional crypto helpers while developing
pip install -e ".[dev,crypto]"
```

## Quickstart (async)

```python
from contract_attestation import AsyncClient

async def main() -> None:
    async with AsyncClient(api_key="your-key") as client:
        review = await client.review("contract C {}")
        print(review.score, review.evidence_level)
```

## Quickstart (sync)

```python
from contract_attestation import SyncClient

with SyncClient(api_key="your-key") as client:
    review = client.review("contract C {}")
    print(review.score, review.attestation_status)
```

## CI Gate

```python
from contract_attestation import GatePolicy, check_contract

policy = GatePolicy(min_score=80)
result = check_contract("contract C {}", api_key="your-key", policy=policy)
if not result.passed:
    raise SystemExit(1)
```

## Optional Crypto Helpers

```python
from contract_attestation import verify_response_hash, decrypt_findings

ok = verify_response_hash(ipfs_payload, on_chain_hash)
findings = decrypt_findings(ipfs_payload, private_key_hex)
```

## Manual Publish Fallback

```bash
pip install build twine
cd sdk/python
python -m build
TWINE_USERNAME=__token__ TWINE_PASSWORD="$PYPI_TOKEN" twine upload dist/*
```
