Skip to main content

No project description provided

Project description

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

This project is actively maintained and ready for experimentation and integration. Expect occasional breaking changes as features evolve.

CashScript-Py builds on earlier work by Jonald Fyookball on the anyhedge-ec-plugin.

Note: CashScript-Py currently targets real networks (including chipnet, a public BCH testnet). A fully local mock network provider (mocknet) is not available yet. For experiments and tests on chipnet, this repo includes cashscript_py_support.utils and uses FAUCET_WIF to reduce funding/cleanup boilerplate.

Installation

Install from PyPI:

pip install cashscript-py

If you use uv:

uv add cashscript-py

Minimal example

from cashscript_py import Contract, ElectrumNetworkProvider, SignatureTemplate, TransactionBuilder

provider = ElectrumNetworkProvider("chipnet")
contract = Contract(artifact, constructor_args, provider)

unlocker = contract.unlock["spend"](SignatureTemplate(alice_wif))
builder = TransactionBuilder(provider).add_input(contract_utxo, unlocker).add_output(...)
tx_hex = builder.build()
print(tx_hex)

Documentation

Developer notes

Prerequisites:

  • Python 3.11 or above
  • uv installed (recommended via pipx or Homebrew)
    • pipx: pipx install uv
    • Homebrew (macOS/Linux): brew install uv

Environment setup (using uv):

  • Create a virtual environment:
    • uv venv
  • Activate the environment:
    • Linux/macOS: source .venv/bin/activate
    • Windows (PowerShell): .venv\Scripts\Activate.ps1
  • Install dependencies from pyproject.toml:
    • Runtime dependencies only: uv sync
    • With development tools (ruff, pytest, sphinx): uv sync --group dev

Debugging

For runtime debug output (e.g., preimage/sighash/signature/script details), set:

  • Linux/macOS: export CASHSCRIPT_PY_DEBUG=1
  • Windows (PowerShell): $env:CASHSCRIPT_PY_DEBUG = "1"

Testing:

  • Run tests with: uv run pytest

Coding standards and development process:

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cashscript_py-1.0.0.tar.gz (58.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cashscript_py-1.0.0-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

Details for the file cashscript_py-1.0.0.tar.gz.

File metadata

  • Download URL: cashscript_py-1.0.0.tar.gz
  • Upload date:
  • Size: 58.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cashscript_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c2faa2d2326af07a946a6a9d5169e55c1edecc4a1f6ae8c13ef4ac6a2c0bb17e
MD5 b96b97c7120ea9eda89e7f1bf17b5836
BLAKE2b-256 da50d7a929166111ef01d43989c0e776dffdb034b97375a46e43c2afa8019c62

See more details on using hashes here.

File details

Details for the file cashscript_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cashscript_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cashscript_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba5fe89927ce3304c846b1ecc3ac4f0eb4a3a04014a9eede20cfd30927b9e74
MD5 df294ed1c1a461d7b57b66d297031794
BLAKE2b-256 2d694b41cacb79e8b2296210334c7cb5e95109481310e75a56b4c9e325af3c03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page