pccontext


Namepccontext JSON
Version 0.5.1 PyPI version JSON
download
home_pagehttps://github.com/Python-Cardano/pycardano
SummaryChain Contexts for PyCardano library
upload_time2025-07-22 00:12:20
maintainerNone
docs_urlNone
authorHareem Adderley
requires_python<4.0,>=3.10
licenseMIT
keywords python cardano blockchain crypto
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ## PyCardano Chain Contexts

This library contains the various Chain Contexts to use with the PyCardano library as well as a few 
helper functions for working with and building certain types of transactions.

### Chain Context Usage

#### Blockfrost

```python
from pccontext import BlockFrostChainContext, Network

chain_context = BlockFrostChainContext(
    project_id="your_project_id",
    network=Network.MAINNET,
)

```

#### Cardano-CLI

```python
from pccontext import CardanoCliChainContext, Network
from pathlib import Path

chain_context = CardanoCliChainContext(
            binary=Path("cardano-cli"),
            socket=Path("node.socket"),
            config_file=Path("config.json"),
            network=Network.MAINNET,
)

```

#### Koios

```python
from pccontext import KoiosChainContext

chain_context = KoiosChainContext(api_key="api_key")

```

#### Ogmios

```python
from pccontext import OgmiosChainContext

chain_context = OgmiosChainContext(host="localhost", port=1337)

```

#### Kupo

```python
from pccontext import OgmiosChainContext, KupoChainContextExtension

ogmios_chain_context = OgmiosChainContext(host="localhost", port=1337)
chain_context = KupoChainContextExtension(wrapped_backend=ogmios_chain_context)

```

#### Offline Transfer File

```python
from pathlib import Path
from pccontext import OfflineTransferFileContext

chain_context = OfflineTransferFileContext(offline_transfer_file=Path("offline-transfer.json"))

```

#### Yaci Devkit

```python
from pccontext import YaciDevkitChainContext

chain_context = YaciDevkitChainContext(api_url="http://localhost:8080")

```

### Transactions Usage

```python
from pycardano import (
    Address,
    StakeSigningKey,
    StakeVerificationKey,
    PaymentSigningKey,
    PaymentVerificationKey,
)

from pccontext.transactions import stake_address_registration
import os

from pccontext import BlockFrostChainContext, Network


network = Network.PREPROD
blockfrost_api_key = os.getenv("BLOCKFROST_API_KEY_PREPROD")
chain_context = BlockFrostChainContext(
    project_id=blockfrost_api_key, network=network
)

payment_signing_key = PaymentSigningKey.generate()
payment_verification_key = PaymentVerificationKey.from_signing_key(
    payment_signing_key
)

stake_signing_key = StakeSigningKey.generate()
stake_verification_key = StakeVerificationKey.from_signing_key(stake_signing_key)

address = Address(
    payment_part=payment_verification_key.hash(),
    staking_part=stake_verification_key.hash(),
    network=network.get_network(),
)

# Example Stake Address Registration Transaction
signed_stake_address_registration_tx = stake_address_registration(
    context=chain_context,
    stake_vkey=stake_verification_key,
    send_from_addr=address,
    signing_keys=[payment_signing_key, stake_signing_key],
)

print(f"Signed Transaction: {signed_stake_address_registration_tx}")

chain_context.submit_tx(signed_stake_address_registration_tx)

print(f"Transaction ID: {signed_stake_address_registration_tx.id}")


```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Python-Cardano/pycardano",
    "name": "pccontext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "python, cardano, blockchain, crypto",
    "author": "Hareem Adderley",
    "author_email": "haddderley@kingpinapps.com",
    "download_url": "https://files.pythonhosted.org/packages/46/d1/4d40604926d6c7cfc830658714b45e4c9e9c014f0792a7713884f05f6780/pccontext-0.5.1.tar.gz",
    "platform": null,
    "description": "## PyCardano Chain Contexts\n\nThis library contains the various Chain Contexts to use with the PyCardano library as well as a few \nhelper functions for working with and building certain types of transactions.\n\n### Chain Context Usage\n\n#### Blockfrost\n\n```python\nfrom pccontext import BlockFrostChainContext, Network\n\nchain_context = BlockFrostChainContext(\n    project_id=\"your_project_id\",\n    network=Network.MAINNET,\n)\n\n```\n\n#### Cardano-CLI\n\n```python\nfrom pccontext import CardanoCliChainContext, Network\nfrom pathlib import Path\n\nchain_context = CardanoCliChainContext(\n            binary=Path(\"cardano-cli\"),\n            socket=Path(\"node.socket\"),\n            config_file=Path(\"config.json\"),\n            network=Network.MAINNET,\n)\n\n```\n\n#### Koios\n\n```python\nfrom pccontext import KoiosChainContext\n\nchain_context = KoiosChainContext(api_key=\"api_key\")\n\n```\n\n#### Ogmios\n\n```python\nfrom pccontext import OgmiosChainContext\n\nchain_context = OgmiosChainContext(host=\"localhost\", port=1337)\n\n```\n\n#### Kupo\n\n```python\nfrom pccontext import OgmiosChainContext, KupoChainContextExtension\n\nogmios_chain_context = OgmiosChainContext(host=\"localhost\", port=1337)\nchain_context = KupoChainContextExtension(wrapped_backend=ogmios_chain_context)\n\n```\n\n#### Offline Transfer File\n\n```python\nfrom pathlib import Path\nfrom pccontext import OfflineTransferFileContext\n\nchain_context = OfflineTransferFileContext(offline_transfer_file=Path(\"offline-transfer.json\"))\n\n```\n\n#### Yaci Devkit\n\n```python\nfrom pccontext import YaciDevkitChainContext\n\nchain_context = YaciDevkitChainContext(api_url=\"http://localhost:8080\")\n\n```\n\n### Transactions Usage\n\n```python\nfrom pycardano import (\n    Address,\n    StakeSigningKey,\n    StakeVerificationKey,\n    PaymentSigningKey,\n    PaymentVerificationKey,\n)\n\nfrom pccontext.transactions import stake_address_registration\nimport os\n\nfrom pccontext import BlockFrostChainContext, Network\n\n\nnetwork = Network.PREPROD\nblockfrost_api_key = os.getenv(\"BLOCKFROST_API_KEY_PREPROD\")\nchain_context = BlockFrostChainContext(\n    project_id=blockfrost_api_key, network=network\n)\n\npayment_signing_key = PaymentSigningKey.generate()\npayment_verification_key = PaymentVerificationKey.from_signing_key(\n    payment_signing_key\n)\n\nstake_signing_key = StakeSigningKey.generate()\nstake_verification_key = StakeVerificationKey.from_signing_key(stake_signing_key)\n\naddress = Address(\n    payment_part=payment_verification_key.hash(),\n    staking_part=stake_verification_key.hash(),\n    network=network.get_network(),\n)\n\n# Example Stake Address Registration Transaction\nsigned_stake_address_registration_tx = stake_address_registration(\n    context=chain_context,\n    stake_vkey=stake_verification_key,\n    send_from_addr=address,\n    signing_keys=[payment_signing_key, stake_signing_key],\n)\n\nprint(f\"Signed Transaction: {signed_stake_address_registration_tx}\")\n\nchain_context.submit_tx(signed_stake_address_registration_tx)\n\nprint(f\"Transaction ID: {signed_stake_address_registration_tx.id}\")\n\n\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Chain Contexts for PyCardano library",
    "version": "0.5.1",
    "project_urls": {
        "Documentation": "https://pycardano.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/Python-Cardano/pycardano",
        "Repository": "https://github.com/KINGH242/pccontext.git"
    },
    "split_keywords": [
        "python",
        " cardano",
        " blockchain",
        " crypto"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a113f98b3c21ffa6247d0dd6a35c423b791ec4a799dcaf7c1e7cb36157726643",
                "md5": "e3088ef2aef6c406d15823832a72e9e3",
                "sha256": "e64d63deeaaebc31d537172b2176f058747113e9ad337a672a42823f3e04556c"
            },
            "downloads": -1,
            "filename": "pccontext-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e3088ef2aef6c406d15823832a72e9e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 58399,
            "upload_time": "2025-07-22T00:12:19",
            "upload_time_iso_8601": "2025-07-22T00:12:19.046724Z",
            "url": "https://files.pythonhosted.org/packages/a1/13/f98b3c21ffa6247d0dd6a35c423b791ec4a799dcaf7c1e7cb36157726643/pccontext-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46d14d40604926d6c7cfc830658714b45e4c9e9c014f0792a7713884f05f6780",
                "md5": "d268099c5375f94c4eb17d330d110817",
                "sha256": "a3d2ccc5b84aed9fe10497b3e05239c50de8dc75d02a2a70ea71409152b1ffe9"
            },
            "downloads": -1,
            "filename": "pccontext-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d268099c5375f94c4eb17d330d110817",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 35381,
            "upload_time": "2025-07-22T00:12:20",
            "upload_time_iso_8601": "2025-07-22T00:12:20.313622Z",
            "url": "https://files.pythonhosted.org/packages/46/d1/4d40604926d6c7cfc830658714b45e4c9e9c014f0792a7713884f05f6780/pccontext-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 00:12:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Python-Cardano",
    "github_project": "pycardano",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pccontext"
}
        
Elapsed time: 0.84372s