Skip to main content

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.

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

Installation

Install from PyPI:

pip install cashscript-py

Or, with uv:

uv add cashscript-py

Example

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

Contributing

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

Acknowledgements

Release files for cashscript-py 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cashscript-py 1.0.3
File Size Uploaded
cashscript_py-1.0.3.tar.gz 36.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cashscript-py 1.0.3
File Interpreter ABI Platform
cashscript_py-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.4 MB

Release files / cashscript_py-1.0.3.tar.gz

Download URL cashscript_py-1.0.3.tar.gz
Size 36.4 MB
Tags Source
SHA-256 checksum
How to use checksums
cee26b372d2a4c12112c04ae3bf30ed9a309f962616e5a8ff8b8bef3a3778543
BLAKE2b-256 checksum
How to use checksums
d27b1259de5162858d68ab3a6c2107eb20ed1778934a8526effc19e3122d4138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / cashscript_py-1.0.3-py3-none-any.whl

Download URL cashscript_py-1.0.3-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fd2f2be7f5e99038e682091cd0dc09a970159b0fac4efbfb38cf0b2ef545592
BLAKE2b-256 checksum
How to use checksums
9491f1878fd9a711812ac9b01407f3f2c1fc36f802a9a0c717e635958bc53bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page