bsv-sdk


Namebsv-sdk JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://github.com/bitcoin-sv/py-sdk
SummaryBSV BLOCKCHAIN | Software Development Kit for Python
upload_time2025-08-13 03:40:47
maintainerNone
docs_urlNone
authorAaron
requires_python>=3.9
licenseNone
keywords bsv
VCS
bugtrack_url
requirements pycryptodomex coincurve aiohttp requests pytest setuptools
Travis-CI No Travis.
coveralls test coverage
            # BSV SDK

[![build](https://github.com/bitcoin-sv/py-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/bitcoin-sv/py-sdk/actions/workflows/build.yml)
[![PyPI version](https://img.shields.io/pypi/v/bsv-sdk)](https://pypi.org/project/bsv-sdk)
[![Python versions](https://img.shields.io/pypi/pyversions/bsv-sdk)](https://pypi.org/project/bsv-sdk)


Welcome to the BSV Blockchain Libraries Project, the comprehensive Python SDK designed to provide an updated and unified layer for developing scalable applications on the BSV Blockchain. This SDK addresses the limitations of previous tools by offering a fresh, peer-to-peer approach, adhering to SPV, and ensuring privacy and scalability.
## Table of Contents

1. [Objective](#objective)
2. [Getting Started](#getting-started)
3. [Features & Deliverables](#features--deliverables)
4. [Documentation](#documentation)
5. [Tutorial](#Tutorial)
5. [Contribution Guidelines](#contribution-guidelines)
6. [Support & Contacts](#support--contacts)

## Objective

The BSV Blockchain Libraries Project aims to structure and maintain a middleware layer of the BSV Blockchain technology stack. By facilitating the development and maintenance of core libraries, it serves as an essential toolkit for developers looking to build on the BSV Blockchain.

## Getting Started

### Requirements

Python 3.9 or higher
pip package manager

### Installation

```bash
pip install bsv-sdk
```

### Basic Usage

```python
import asyncio
from bsv import (
    PrivateKey, P2PKH, Transaction, TransactionInput, TransactionOutput
)


# Replace with your private key (WIF format)
PRIVATE_KEY = 'KyEox4cjFbwR---------VdgvRNQpDv11nBW2Ufak'

# Replace with your source tx which contains UTXO that you want to spend (raw hex format)
SOURCE_TX_HEX = '01000000018128b0286d9c6c7b610239bfd8f6dcaed43726ca57c33aa43341b2f360430f23020000006b483045022100b6a60f7221bf898f48e4a49244e43c99109c7d60e1cd6b1f87da30dce6f8067f02203cac1fb58df3d4bf26ea2aa54e508842cb88cc3b3cec9b644fb34656ff3360b5412102cdc6711a310920d8fefbe8ee73b591142eaa7f8668e6be44b837359bfa3f2cb2ffffffff0201000000000000001976a914dd2898df82e086d729854fc0d35a449f30f3cdcc88acce070000000000001976a914dd2898df82e086d729854fc0d35a449f30f3cdcc88ac00000000'

async def create_and_broadcast_transaction():
    priv_key = PrivateKey(PRIVATE_KEY)
    source_tx = Transaction.from_hex(SOURCE_TX_HEX)

    tx_input = TransactionInput(
        source_transaction=source_tx,
        source_txid=source_tx.txid(),
        source_output_index=1,
        unlocking_script_template=P2PKH().unlock(priv_key),
    )

    tx_output = TransactionOutput(
        locking_script=P2PKH().lock(priv_key.address()),
        change=True
    )

    tx = Transaction([tx_input], [tx_output], version=1)

    tx.fee()
    tx.sign()

    await tx.broadcast()

    print(f"Transaction ID: {tx.txid()}")
    print(f"Raw hex: {tx.hex()}")

if __name__ == "__main__":
    asyncio.run(create_and_broadcast_transaction())
```

For a more detailed tutorial and advanced examples, check our [Documentation](#documentation).

## Features & Deliverables

### Advanced Transaction Building:

* Support for P2PKH, P2PK, OP_RETURN, and BareMultisig scripts
* Automated fee calculation and change output management
* Custom script development
* Support for various SIGHASH types


### HD Wallet Capabilities:

* Full BIP32/39/44 implementation for hierarchical deterministic wallets
* Multiple language support for mnemonic phrases (English, Chinese)
* Advanced key derivation and management


### SPV & Validation:

* Built-in SPV verification with BEEF format support
* Merkle proof validation
* Efficient transaction broadcast with Arc
* Support for chain tracking and verification


## Documentation

Detailed documentation of the SDK with code examples can be found at [BSV Skills Center](https://docs.bsvblockchain.org/guides/sdks/py).

You can also refer to the [User Test Report](./docs/Py-SDK%20User%20Test%20Report.pdf) for insights and feedback provided by
[Yenpoint](https://yenpoint.jp/).

## Beginner Tutorial
#### [Step-by-Step BSV Tutorial: Sending BSV and NFTs](./docs/beginner_tutorial.md)

This beginner-friendly guide will walk you through sending BSV (Bitcoin SV) and creating NFTs using the BSV Python SDK. We'll take it step-by-step so you can learn at your own pace.

## Contribution Guidelines

We're always looking for contributors to help us improve the project. Whether it's bug reports, feature requests, or pull requests - all
contributions are welcome.

1. **Fork & Clone**: Fork this repository and clone it to your local machine.
2. **Set Up**: Run `pip install -r requirements.txt` to install all dependencies.
3. **Make Changes**: Create a new branch and make your changes.
4. **Test**: Ensure all tests pass by running `pytest --cov=bsv --cov-report=html`.
5. **Commit**: Commit your changes and push to your fork.
6. **Pull Request**: Open a pull request from your fork to this repository.

For more details, check the [contribution guidelines](./CONTRIBUTING.md).

## Support & Contacts
Project Owners: Thomas Giacomo and Darren Kellenschwiler
Development Team Lead: sCrypt
Maintainer: Ken Sato @ Yenpoint inc. & Yosuke Sato @ Yenpoint inc.
For questions, bug reports, or feature requests, please open an issue on GitHub or contact us directly.
## License

The license for the code in this repository is the Open BSV License. Refer to [LICENSE.txt](./LICENSE.txt) for the license text.

Thank you for being a part of the BSV Blockchain ecosystem. Let's build the future of BSV Blockchain together!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bitcoin-sv/py-sdk",
    "name": "bsv-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "bsv",
    "author": "Aaron",
    "author_email": "aaron@scrypt.io",
    "download_url": "https://files.pythonhosted.org/packages/31/1b/60612383b011a46a409dd89fa51b4a967f5e62ae7a84c98aeaaaffbff06e/bsv_sdk-1.0.8.tar.gz",
    "platform": null,
    "description": "# BSV SDK\n\n[![build](https://github.com/bitcoin-sv/py-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/bitcoin-sv/py-sdk/actions/workflows/build.yml)\n[![PyPI version](https://img.shields.io/pypi/v/bsv-sdk)](https://pypi.org/project/bsv-sdk)\n[![Python versions](https://img.shields.io/pypi/pyversions/bsv-sdk)](https://pypi.org/project/bsv-sdk)\n\n\nWelcome to the BSV Blockchain Libraries Project, the comprehensive Python SDK designed to provide an updated and unified layer for developing scalable applications on the BSV Blockchain. This SDK addresses the limitations of previous tools by offering a fresh, peer-to-peer approach, adhering to SPV, and ensuring privacy and scalability.\n## Table of Contents\n\n1. [Objective](#objective)\n2. [Getting Started](#getting-started)\n3. [Features & Deliverables](#features--deliverables)\n4. [Documentation](#documentation)\n5. [Tutorial](#Tutorial)\n5. [Contribution Guidelines](#contribution-guidelines)\n6. [Support & Contacts](#support--contacts)\n\n## Objective\n\nThe BSV Blockchain Libraries Project aims to structure and maintain a middleware layer of the BSV Blockchain technology stack. By facilitating the development and maintenance of core libraries, it serves as an essential toolkit for developers looking to build on the BSV Blockchain.\n\n## Getting Started\n\n### Requirements\n\nPython 3.9 or higher\npip package manager\n\n### Installation\n\n```bash\npip install bsv-sdk\n```\n\n### Basic Usage\n\n```python\nimport asyncio\nfrom bsv import (\n    PrivateKey, P2PKH, Transaction, TransactionInput, TransactionOutput\n)\n\n\n# Replace with your private key (WIF format)\nPRIVATE_KEY = 'KyEox4cjFbwR---------VdgvRNQpDv11nBW2Ufak'\n\n# Replace with your source tx which contains UTXO that you want to spend (raw hex format)\nSOURCE_TX_HEX = '01000000018128b0286d9c6c7b610239bfd8f6dcaed43726ca57c33aa43341b2f360430f23020000006b483045022100b6a60f7221bf898f48e4a49244e43c99109c7d60e1cd6b1f87da30dce6f8067f02203cac1fb58df3d4bf26ea2aa54e508842cb88cc3b3cec9b644fb34656ff3360b5412102cdc6711a310920d8fefbe8ee73b591142eaa7f8668e6be44b837359bfa3f2cb2ffffffff0201000000000000001976a914dd2898df82e086d729854fc0d35a449f30f3cdcc88acce070000000000001976a914dd2898df82e086d729854fc0d35a449f30f3cdcc88ac00000000'\n\nasync def create_and_broadcast_transaction():\n    priv_key = PrivateKey(PRIVATE_KEY)\n    source_tx = Transaction.from_hex(SOURCE_TX_HEX)\n\n    tx_input = TransactionInput(\n        source_transaction=source_tx,\n        source_txid=source_tx.txid(),\n        source_output_index=1,\n        unlocking_script_template=P2PKH().unlock(priv_key),\n    )\n\n    tx_output = TransactionOutput(\n        locking_script=P2PKH().lock(priv_key.address()),\n        change=True\n    )\n\n    tx = Transaction([tx_input], [tx_output], version=1)\n\n    tx.fee()\n    tx.sign()\n\n    await tx.broadcast()\n\n    print(f\"Transaction ID: {tx.txid()}\")\n    print(f\"Raw hex: {tx.hex()}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(create_and_broadcast_transaction())\n```\n\nFor a more detailed tutorial and advanced examples, check our [Documentation](#documentation).\n\n## Features & Deliverables\n\n### Advanced Transaction Building:\n\n* Support for P2PKH, P2PK, OP_RETURN, and BareMultisig scripts\n* Automated fee calculation and change output management\n* Custom script development\n* Support for various SIGHASH types\n\n\n### HD Wallet Capabilities:\n\n* Full BIP32/39/44 implementation for hierarchical deterministic wallets\n* Multiple language support for mnemonic phrases (English, Chinese)\n* Advanced key derivation and management\n\n\n### SPV & Validation:\n\n* Built-in SPV verification with BEEF format support\n* Merkle proof validation\n* Efficient transaction broadcast with Arc\n* Support for chain tracking and verification\n\n\n## Documentation\n\nDetailed documentation of the SDK with code examples can be found at [BSV Skills Center](https://docs.bsvblockchain.org/guides/sdks/py).\n\nYou can also refer to the [User Test Report](./docs/Py-SDK%20User%20Test%20Report.pdf) for insights and feedback provided by\n[Yenpoint](https://yenpoint.jp/).\n\n## Beginner Tutorial\n#### [Step-by-Step BSV Tutorial: Sending BSV and NFTs](./docs/beginner_tutorial.md)\n\nThis beginner-friendly guide will walk you through sending BSV (Bitcoin SV) and creating NFTs using the BSV Python SDK. We'll take it step-by-step so you can learn at your own pace.\n\n## Contribution Guidelines\n\nWe're always looking for contributors to help us improve the project. Whether it's bug reports, feature requests, or pull requests - all\ncontributions are welcome.\n\n1. **Fork & Clone**: Fork this repository and clone it to your local machine.\n2. **Set Up**: Run `pip install -r requirements.txt` to install all dependencies.\n3. **Make Changes**: Create a new branch and make your changes.\n4. **Test**: Ensure all tests pass by running `pytest --cov=bsv --cov-report=html`.\n5. **Commit**: Commit your changes and push to your fork.\n6. **Pull Request**: Open a pull request from your fork to this repository.\n\nFor more details, check the [contribution guidelines](./CONTRIBUTING.md).\n\n## Support & Contacts\nProject Owners: Thomas Giacomo and Darren Kellenschwiler\nDevelopment Team Lead: sCrypt\nMaintainer: Ken Sato @ Yenpoint inc. & Yosuke Sato @ Yenpoint inc.\nFor questions, bug reports, or feature requests, please open an issue on GitHub or contact us directly.\n## License\n\nThe license for the code in this repository is the Open BSV License. Refer to [LICENSE.txt](./LICENSE.txt) for the license text.\n\nThank you for being a part of the BSV Blockchain ecosystem. Let's build the future of BSV Blockchain together!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "BSV BLOCKCHAIN | Software Development Kit for Python",
    "version": "1.0.8",
    "project_urls": {
        "Bug Tracker": "https://github.com/bitcoin-sv/py-sdk/issues",
        "Homepage": "https://github.com/bitcoin-sv/py-sdk"
    },
    "split_keywords": [
        "bsv"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "65afb67161f96bf678d2fe1ef8c586bca90d024077e41817b4171605aa98e2f7",
                "md5": "ad08af32916d4c915165ffac963e56ad",
                "sha256": "2f56b46246fc47f1194f0fa6da302d04a38ef74373c4712fd3fe6dc4020f88f8"
            },
            "downloads": -1,
            "filename": "bsv_sdk-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ad08af32916d4c915165ffac963e56ad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 78029,
            "upload_time": "2025-08-13T03:40:44",
            "upload_time_iso_8601": "2025-08-13T03:40:44.882544Z",
            "url": "https://files.pythonhosted.org/packages/65/af/b67161f96bf678d2fe1ef8c586bca90d024077e41817b4171605aa98e2f7/bsv_sdk-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "311b60612383b011a46a409dd89fa51b4a967f5e62ae7a84c98aeaaaffbff06e",
                "md5": "1c1a170f2a9db295ff2d9937258df9a9",
                "sha256": "c33e0da1b45c3fb9b1df074a783e4eaa63c5ee9f370ff89ab7e6e4f0858b1521"
            },
            "downloads": -1,
            "filename": "bsv_sdk-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "1c1a170f2a9db295ff2d9937258df9a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 107790,
            "upload_time": "2025-08-13T03:40:47",
            "upload_time_iso_8601": "2025-08-13T03:40:47.773470Z",
            "url": "https://files.pythonhosted.org/packages/31/1b/60612383b011a46a409dd89fa51b4a967f5e62ae7a84c98aeaaaffbff06e/bsv_sdk-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-13 03:40:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bitcoin-sv",
    "github_project": "py-sdk",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "pycryptodomex",
            "specs": [
                [
                    "~=",
                    "3.21.0"
                ]
            ]
        },
        {
            "name": "coincurve",
            "specs": [
                [
                    "~=",
                    "20.0.0"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    ">=",
                    "3.12.14"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "~=",
                    "2.32.3"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    ">=",
                    "78.1.1"
                ]
            ]
        }
    ],
    "lcname": "bsv-sdk"
}
        
Elapsed time: 4.27042s