{"id":25323960,"url":"https://github.com/opshin/opshin-starter-kit","last_synced_at":"2025-10-29T02:31:03.601Z","repository":{"id":170393328,"uuid":"593578863","full_name":"OpShin/opshin-starter-kit","owner":"OpShin","description":"On-chain and off-chain code for a Python Smart Contract using opshin and pycardano","archived":false,"fork":false,"pushed_at":"2023-09-15T13:33:22.000Z","size":86,"stargazers_count":16,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T13:15:21.459Z","etag":null,"topics":["cardano","demeter-run","off-chain","on-chain","plutus","python","smart-contracts"],"latest_commit_sha":null,"homepage":"https://demeter.run/code?repository=https://github.com/opshin/opshin-starter-kit.git\u0026template=python\u0026source=demeter\u0026key=opshin-starter-kit","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpShin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-01-26T11:09:14.000Z","updated_at":"2024-12-20T06:02:23.000Z","dependencies_parsed_at":"2024-01-28T11:23:05.653Z","dependency_job_id":"3aaf7c94-43b7-477c-a3c4-d3cca802273a","html_url":"https://github.com/OpShin/opshin-starter-kit","commit_stats":null,"previous_names":["opshin/opshin-starter-kit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-starter-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-starter-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-starter-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-starter-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpShin","download_url":"https://codeload.github.com/OpShin/opshin-starter-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238759663,"owners_count":19525873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cardano","demeter-run","off-chain","on-chain","plutus","python","smart-contracts"],"created_at":"2025-02-14T00:55:11.508Z","updated_at":"2025-10-29T02:31:03.583Z","avatar_url":"https://github.com/OpShin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpShin Starter-kit\n\u003ca href=\"https://github.com/OpShin/awesome-opshin\"\u003e\u003cimg src=\"https://img.shields.io/badge/awesome-opshin-blue?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAYAAAB2+A+pAAAGQklEQVRIx52Ve2yVdxnHP8/vPe+59U5pqdwqFxFpwbVzHesgWVwZrsJKZRMd4ObMkjkVDIst3ZSEzU0mNkv8wzGXoazFWc1YRA0MBsNuZg4lZXRgay3QcisF2lJoT8/pe97HP87pVUDPfsmb35vf7ft8n8v3kfu//HCR40TzgUvA4f1v110kPn6wJyxu2C1BWQXcCUwFXOAkcAD4RXV5oJ1PMKRy4+an3z303vPh8ADJSanRYFLKH4HdiPHm3PPVR73+7IV2MBNfahYeX3D8/RCwvro88GrCwEuWrrqjuanhcFdXBwB5+QtJTc0gEgnT030JMQa/P0gwmELOzPmkz1lEvycFJxolKzcPY9kA364uD2xLBNgAJwKBpMGhBVUl78mnQtd6u2ltbeTfLR/xceMHHG2oZ+BKK3J6D9+5W/A0vsK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5G4+ric0yhYgOJaxZSpipkOHO40uTwBrrOs6nm/R9cAWY/DH6xgExEC+XiLfaog1G8957MCIyx0P6baPFxVmoYSGgfXKGxNxtShWo0pnJBuxRulEjNUeMSNgs5OhPQJqIJUIJU49cTGZ2EfaBmOP3G+6TrVlM9Q2z4ww9lrTUARXwVVC6h/D9kYjxQtJAmFRSgeP4Lf638GVLQjrHOPDlnjcY6wniMQMEeHdEWDb6him5iqZch3jDsviaIkcjufx/tj8gKeRqXLqI4x5SKasUb1QezIg/QSSwYkA0Zi7RcAykGOcXw8Di3/lBdXd76G6GFeZYbczxcym0w2MAZZRRRjA4T49Rq77rw9BlknW6p6YLMk7fhM6P8P0TD6XnI7rxAxOZ4DFoYY3J2cU/21MHav+eR7wPmgGKD1uBrvDRVyL2kMxRgR8EmWBOc8C/Ri/9r1G1P2epK0KjXmr+7dfiJjgrrPemdN6TCo+jZAbbj2YPNhVLhO/3vvfAqJ7PwtsB4pBcbA4FZ1BjxvAQsk2XeSY83g0fBRXK8Uu33dTvb/2uwCwFMgBmnH1kKSt0lt2J9X9i4Ay0DtAJ4EK6EXQw+D+AfSvIsuVTzj+AwGKaSmc5OLIAAAAAElFTkSuQmCC\"\u003e\u003c/a\u003e\n\nThis Starter-Kit is a small tutorial of how to use the [PyCardano](https://github.com/Python-Cardano/pycardano) library \nwith [opshin](https://github.com/OpShin/opshin) for interacting with a simple vesting contract on Cardano.\n\nPyCardano is a Cardano library written in Python. It allows users to create and sign transactions without depending on third-party Cardano serialization tools, such as cardano-cli and cardano-serialization-lib, making it a lightweight library, which is simple and fast to set up in all types of environments.\n\nopshin is a Smart Contract language based on Python. It allows users to define and compile Smart Contracts directly within a python environment.\nIt also interacts seemlessly with PyCardano.\n\n## Dev Environment\n\nFor executing the scripts in this starter kit you'll need access to a running [Ogmios](https://ogmios.dev/) instance.\n\nIn case you don't want to install the required components yourself, you can use [Demeter.run](https://demeter.run) platform to create a cloud environment with access to common Cardano infrastructure. The following command will open this repo in a private, web-based VSCode IDE with access to a running Ogmios instance in the preview network.\n\n[![Code in Cardano Workspace](https://demeter.run/code/badge.svg)](https://demeter.run/code?repository=https://github.com/opshin/opshin-starter-kit.git\u0026template=python\u0026source=demeter\u0026key=opshin-starter-kit)\n\n\n## What is Included\n\nWe have included a number of python scripts for executing specific actions.\nYou can find scripts to initialize addresses and interact with the cardano-node in `scripts`.\n`src` contains two folders, `on_chain` which hosts the actual opshin contract and `off-chain` which\nhosts tooling to interact with the contract.\n\n\n## Setup\n\n\n1. Install uv.\n\nOn demeter.run or Linux/Ubuntu run \n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\nFollow the instructions diplayed to add uv to your local shell.\n\nOtherwise, follow the official documentation [here](https://docs.astral.sh/uv/getting-started/installation/).\n\n2. Set up a virtual environment and install the required packages.\n\n```bash\nuv python install\nuv venv\nsource .venv/bin/activate\n```\n\n2. Alternatively set up Ogmios or Blockfrost\n\n#### Set up Blockfrost\n\nFollow the instructions on [Blockfrost](https://blockfrost.io/) to create a free account and get an API key for the preview network.\nMake sure the following environment variables are set (defaults are displayed):\n\n```bash\nexport BLOCKFROST_API_KEY=\"previewyourkey\"\n```\n\n#### Set up [ogmios](https://ogmios.dev/) and optionally [kupo](https://cardanosolutions.github.io/kupo/).\n\nOn demeter.run, simply add the Ogmios Extension for the Preview network\nthrough the project console website (the page that shows you demeter.run project -\u003e Connected Extensions -\u003e Browse Extensions -\u003e Cardano Ogmios)\nIf you want to add kupo, use the Kupo Extension as well.\n\nMake sure the following environment variables are set (defaults are displayed):\n\n```bash\nexport OGMIOS_API_HOST=localhost\nexport OGMIOS_API_PORT=1337\nexport OGMIOS_API_PROTOCOL=ws\n\nexport KUPO_API_HOST=None\nexport KUPO_API_PORT=80\nexport KUPO_API_PROTOCOL=http\n```\n\n## Running the scripts\n\nOnce you have set up uv, you can start interacting with the contract through the prepared scripts.\n\nFirst, we have to build the vesting contract and generate two key pairs, one for the\nowner of funds and one for the intended beneficiary.\n\n```bash\nuv run scripts/build.py\nuv run scripts/create_key_pair.py owner\nuv run scripts/create_key_pair.py beneficiary\n```\n\nMake sure that the owner is loaded up with some testnet ada before proceeding,\nby using the [testnet faucet](https://docs.cardano.org/cardano-testnet/tools/faucet).\nYou can find the address of the owner key by running this command\n\n```bash\ncat keys/owner.addr\n```\n\nAfter requesting ada for the owner, send some ada to the beneficiary. The receiver address needs a small amount of ada\nin order to provide it as collateral when unlocking the funds later.\n\n```bash\npython3 src/off_chain/distribute.py owner beneficiary \n```\n\nThen you can place a vested amount of ada at the contract.\nIf you just requested funds for the owner address, you might need to wait a few minutes or the script will display an error that funds are missing.\n\n\n```bash\npython3 src/off_chain/make_vest.py owner beneficiary \n```\n\nBy default the deadline is 0 seconds after the creation of the vesting, so you can directly proceed and unlock\nthe vested amount with the beneficiary!\n\n```bash\npython3 src/off_chain/collect_vest.py beneficiary\n```\n\nThat's it! You successfully compiled a Smart Contract on cardano and interacted with it through off-chain tooling.\nFeel free to dive into the provided scripts and start customizing them for your needs.\n\n\n### Typical issues\n\nIf you see the following errors when running the scripts, don't panic, they are temporary issues when the blockchain has not yet included your previous transactions.\n```\npycardano.exception.TransactionFailedException: Failed to submit transaction. Error code: 400. Error message: {\"contents\":{\"contents\":{\"contents\":{\"era\":\"ShelleyBasedEraConway\",\"error\":[\"ConwayUtxowFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash \\\"5033df02e3cb82488d8cf46fbe18c783c586320cdcb43b77e8d88df5e50ccbc8\\\"}) (TxIx {unTxIx = 1})])))\",\"ConwayUtxowFailure (UtxoFailure (ValueNotConservedUTxO (Mismatch {mismatchSupplied = MaryValue (Coin 0) (MultiAsset (fromList [])), mismatchExpected = MaryValue (Coin 9936335092) (MultiAsset (fromList []))})))\"],\"kind\":\"ShelleyTxValidationError\"},\"tag\":\"TxValidationErrorInCardanoMode\"},\"tag\":\"TxCmdTxSubmitValidationError\"},\"tag\":\"TxSubmitFail\"}\n```\nThis means that the transaction you are trying to submit is invalid, because the previous transaction has not yet been included in a block.\nJust wait a few minutes and try again, it should work after a short while.\n\n```\nAssertionError: No script UTxOs found!\n```\nThis means that the script UTxO you are trying to spend from does not exist.\nThis can happen if the transaction creating the script UTxO has not yet been included in a\nblock on the blockchain. Retry in a few minutes.\n```\npycardano.exception.TransactionFailedException: Namespace(EvaluationFailure=Namespace(ScriptFailures=Namespace()))\n```\nThis means there was an error when evaluating the script. The contract raised an error, maybe due to invalid inputs or due to a program bug. Unfortunately, Blockfrost does not provide detailed error messages for script failures. If you are running your own ogmios and kupo instances, you can get more detailed error messages that help you figuring out what went wrong.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopshin%2Fopshin-starter-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopshin%2Fopshin-starter-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopshin%2Fopshin-starter-kit/lists"}