{"id":24306,"library":"pycardano","title":"PyCardano","description":"A Python library for interacting with the Cardano blockchain. Supports transaction building, staking, native assets, smart contracts (Plutus), and integration with blockfrost, ogmios, and kupo. Current version: 0.19.2. Release cadence: roughly monthly.","status":"active","version":"0.19.2","language":"python","source_language":"en","source_url":"https://github.com/Python-Cardano/pycardano","tags":["cardano","blockchain","cryptocurrency","plutus","transaction-builder"],"install":[{"cmd":"pip install pycardano","lang":"bash","label":"Install latest"}],"dependencies":[{"reason":"CBOR serialization/deserialization for Cardano binary data","package":"cbor2","optional":false},{"reason":"Blockfrost API client for accessing chain data","package":"blockfrost-python","optional":true},{"reason":"HTTP client for OGMios and other backends","package":"httpx","optional":false}],"imports":[{"note":"All key types were moved to pycardano top-level in v0.12.0.","wrong":"from pycardano.keys import PaymentSigningKey","symbol":"PaymentSigningKey","correct":"from pycardano import PaymentSigningKey"},{"note":"Incorrect import path, TransactionBuilder is now at pycardano.","wrong":"from pycardano.txbuilder import TransactionBuilder","symbol":"TransactionBuilder","correct":"from pycardano import TransactionBuilder"},{"note":"Chain contexts are top-level exports.","wrong":"from pycardano.blockfrost import BlockFrostChainContext","symbol":"BlockFrostChainContext","correct":"from pycardano import BlockFrostChainContext"}],"quickstart":{"code":"import os\nfrom pycardano import (\n    PaymentSigningKey,\n    PaymentVerificationKey,\n    Address,\n    BlockFrostChainContext,\n    TransactionBuilder,\n    TransactionOutput,\n    Value,\n    Network\n)\n\n# Generate a key pair\nsigning_key = PaymentSigningKey.generate()\nverification_key = PaymentVerificationKey.from_signing_key(signing_key)\n\n# Derive address (testnet)\naddress = Address(payment_part=verification_key.hash(), network=Network.TESTNET)\nprint(f\"Address: {address}\")\n\n# Create a chain context (use Blockfrost API key from env)\ncontext = BlockFrostChainContext(\n    base_url=\"https://cardano-testnet.blockfrost.io/api/v0\",\n    project_id=os.environ.get(\"BLOCKFROST_PROJECT_ID\", \"\")\n)\n\n# Build a simple transaction (requires actual UTXOs and funds)\ntry:\n    builder = TransactionBuilder(context)\n    builder.add_output(TransactionOutput(address, Value(1000000)))\n    tx_body, tx_hash = builder.build_and_sign([signing_key], change_address=address)\n    print(f\"Transaction hash: {tx_hash}\")\nexcept Exception as e:\n    print(f\"Error building transaction: {e}\")","lang":"python","description":"Generates a key pair, derives an address, and attempts to build a simple transaction using Blockfrost."},"warnings":[{"fix":"export PYCA_CBOR2=1 or use cbor2 explicitly via pycardano configuration.","message":"In v0.19.0, the default CBOR library was changed to cbor2pure. If you rely on cbor2 C extension, set environment variable PYCA_CBOR2=1.","severity":"breaking","affected_versions":">=0.19.0"},{"fix":"Pin dependencies in your project's requirements or test thoroughly when upgrading pycardano.","message":"From v0.16.0, version capping on dependencies was removed. This may cause incompatibility with older environments due to newer transitive dependencies.","severity":"breaking","affected_versions":">=0.16.0"},{"fix":"Upgrade to Python 3.9 or later.","message":"Support for Python 3.8 was dropped in v0.14.0.","severity":"deprecated","affected_versions":">=0.14.0"},{"fix":"Wrap your key in a list: [signing_key]","message":"TransactionBuilder's build_and_sign expects a list of signing keys, not a single key. Passing a single key will cause cryptic errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade pycardano: pip install --upgrade pycardano","cause":"Using an older version (<0.12.0) where keys were in a submodule.","error":"from pycardano import PaymentSigningKey\nImportError: cannot import name 'PaymentSigningKey' from 'pycardano'"},{"fix":"Pass the signing key(s) as a list: tx_body, tx_hash = builder.build_and_sign([signing_key], change_address=address)","cause":"The signing key was not passed or incorrectly passed to build_and_sign.","error":"pycardano.exception.InvalidTransactionException: Missing required signers"},{"fix":"Ensure pycardano >=0.8.0 and use: from pycardano import TransactionBuilder","cause":"Using a version before TransactionBuilder was added (pre-0.8.0) or incorrect import.","error":"AttributeError: module 'pycardano' has no attribute 'TransactionBuilder'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}