Metadata-Version: 2.4
Name: cashscript-py
Version: 1.0.3
Summary: Python SDK for Bitcoin Cash (BCH) CashScript smart contracts.
Author: CashScript-Py contributors
Maintainer: CashScript-Py maintainers
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: bitcash~=1.1.1
Requires-Dist: coincurve~=21.0.0
Requires-Dist: semver~=3.0.4
Requires-Dist: typing-extensions~=4.15.0
Provides-Extra: docs
Requires-Dist: myst-parser>=4.0.1; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=3.0.2; extra == 'docs'
Requires-Dist: sphinx>=8.2.3; extra == 'docs'
Description-Content-Type: text/markdown

# CashScript-Py

CashScript-Py is a Python SDK for Bitcoin Cash (BCH) smart contract development. It is a port of the original TypeScript
[CashScript SDK](https://cashscript.org/). The goal is to enable Python developers (e.g., those working on server-side
tools, bots, and Electron Cash plugins) to construct and interact with smart contracts on the BCH blockchain without
re-implementing common low-level details.

CashScript-Py builds on earlier work by Jonald Fyookball on the
[anyhedge-ec-plugin](https://github.com/fyookball/anyhedge-ec-plugin).

## Installation

Install from PyPI:

```bash
pip install cashscript-py
```

Or, with `uv`:

```bash
uv add cashscript-py
```

## Example

```python
from cashscript_py import Contract, ElectrumNetworkProvider, Output, SignatureTemplate, TransactionBuilder
from .artifact import p2pkh_artifact
from .somewhere import contract_arguments, alice_wif, send_amount, recipient_address

provider = ElectrumNetworkProvider("chipnet")
contract = Contract(p2pkh_artifact, contract_arguments, provider)

alice_signature_template = SignatureTemplate(alice_wif)
unlocker = contract.unlock["transfer"](alice_signature_template)

contract_utxos = await contract.get_utxos()
contract_utxo = contract_utxos[0]

transaction_builder = TransactionBuilder(provider)
transaction_builder.add_input(contract_utxo, unlocker)
transaction_builder.add_output(Output(amount=send_amount, to=recipient_address))

tx_details = await transaction_builder.send()
```

## Documentation

- SDK documentation: https://cashscript-py.readthedocs.io/
- Runnable examples: [examples/](https://gitlab.com/cashscript-py/cashscript-py/-/tree/master/examples) (e.g. `uv run python examples/op_return_memo.py`, `uv run python examples/hodl_vault.py`)

## Contributing

For local development setup, testing, documentation generation, and project workflow details, see:

- [CONTRIBUTING.md](https://gitlab.com/cashscript-py/cashscript-py/-/blob/master/CONTRIBUTING.md)
- [STYLEGUIDE.md](https://gitlab.com/cashscript-py/cashscript-py/-/blob/master/STYLEGUIDE.md)

## Acknowledgements
- Original CashScript SDK: https://cashscript.org/
- AnyHedge Plugin: https://github.com/fyookball/anyhedge-ec-plugin
- Bitcash library: https://pybitcash.github.io/bitcash/
