{"id":25323959,"url":"https://github.com/opshin/opshin-example","last_synced_at":"2025-10-29T02:31:05.070Z","repository":{"id":130901228,"uuid":"610484773","full_name":"OpShin/opshin-example","owner":"OpShin","description":"A simple example setup for an opshin project","archived":false,"fork":false,"pushed_at":"2023-04-08T09:22:56.000Z","size":31,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T13:15:21.334Z","etag":null,"topics":["cardano","haskell","plutus","python","smart-contracts"],"latest_commit_sha":null,"homepage":"","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-06T21:39:24.000Z","updated_at":"2025-01-29T22:01:39.000Z","dependencies_parsed_at":"2023-05-25T19:16:40.628Z","dependency_job_id":null,"html_url":"https://github.com/OpShin/opshin-example","commit_stats":null,"previous_names":["opshin/opshin-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpShin%2Fopshin-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpShin","download_url":"https://codeload.github.com/OpShin/opshin-example/tar.gz/refs/heads/master","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","haskell","plutus","python","smart-contracts"],"created_at":"2025-02-14T00:55:11.508Z","updated_at":"2025-10-29T02:31:04.689Z","avatar_url":"https://github.com/OpShin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Opshin example contract\n\n\u003e Note: Consider checking out the [opshin-starter-kit](https://github.com/OpShin/opshin-starter-kit) instead,\nas it also provides off-chain code and runs in the demeter.run Browser environment\n\nThis is a sample repository to get you started with compiling your own smart contract with opshin in less than 10 minutes (even less if you have python3.8 already installed!).\nIt requires you to know how to use the terminal on your computer ([Ubuntu and other Linux distributions](https://www.freecodecamp.org/news/command-line-for-beginners/), [Windows](https://www.makeuseof.com/tag/a-beginners-guide-to-the-windows-command-line/), [Mac](https://support.apple.com/guide/terminal/execute-commands-and-run-tools-apdb66b5242-0d18-49fc-9c47-a2498b7c91d5/mac)).\nYou should also have `git` installed.\n\n## Installation\n\n#### TL;DR\n\n```bash\n$ git clone https://github.com/opshin/opshin-example.git\n$ cd opshin-example\n$ python3.8 -m venv venv\n$ pip install -r requirements\n```\n\nDone! If you have no clue what happened here, feel free to read the next section, which explains it step for step.\nOtherwise, skip to [Running](#Running)\n\n#### Install Python\n\nMake sure you have `python3.8` installed.\nIf you don't have it installed you can download the installer for your OS [here](https://www.python.org/downloads/release/python-3810/).\nIf you want to learn more about python, don't worry.\nPython is the second most used language on GitHub and there are tons of tutorials on how to use it.\n\n#### Clone the repository\n\nOnce you have installed python, clone this repository.\nOpen your terminal and navigate to a folder, then run\n\n```\n$ git clone https://github.com/opshin/opshin-example.git\n```\n\nThis copies this repository on your local computer.\nIf you want to modify the code and keep your modifications, [fork the repository first](https://docs.github.com/en/get-started/quickstart/fork-a-repo), then clone the fork instead.\n\nThen navigate into the the repository using the CLI, like this\n\n```\n$ cd opshin-example\n```\n\n#### Setup the environment\n\nThis project uses the specific version of python 3.8.\nFor this reason we want to make sure that only this version is used for all operations.\nA common way to establish that i.e. `python` also refers to `python3.8` is to set up a virtual environment.\n\n```\n$ python3.8 -m venv venv\n$ source venv/bin/activate\n```\n\nYou are now in a so called virtual environment.\nMake sure to run the `source` command everytime you enter this repository to work on the contract,\nor configure your IDE to use the created virtual environment.\nWhen operations require you to be inside the environment, commands are prefixed with `(venv)`.\n\n#### Install opshin\n\nWe're almost done.\nAs the final step, we install the compiler, `opshin-lang`.\nWe can simply use `pip` for this.\nWe install all projects listed in `requirements.txt`, which includes `opshin-lang`.\nIf you want to use other tools as well, you can add them there!\n\n```bash\n(venv) $ pip install -r requirements.txt\n```\n\n## Testing\n\nRun the tests for this contract like this:\n```bash\n(venv) $ python3 -m unittest\n```\n\nThis example includes a simple test suite with a simple example for each how to write\nnormal tests, parameterized tests and property based tests.\nYou can check out the packages [parameterized](https://github.com/wolever/parameterized) and [hypothesis](https://hypothesis.readthedocs.io/en/latest/)\nfor more information on how to use them.\nYou can also use any other testing framework for python.\n\n\n## Deploying\n\nThe main code for the smart contract is located in `src`.\nYou can build the contract with opshin in a single command:\n\n```bash\n(venv) $ # builds the spending example, a contract that controls who can spend funds\n(venv) $ opshin build src/contract_spending.py\n(venv) $ # builds the minting example, a contract that controls who can mint tokens\n(venv) $ opshin build src/contract_minting.py\n```\n\nNow you will find a number of useful artifacts in the folders `contract_minting` and `contract_spending`,\namong them a `script.plutus` file used by the CLI and other tools for using the contract in transactions,\nthe address of the contract on main- and testnets and the policy id of the token for which the contract controls minting.\n\nExamples on how to use smart contracts for minting and spending can be found for different tools:\n- Cardano CLI (Shell): [Spending](https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/plutus/plutus-spending-script-example.md), [Minting](https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/plutus/plutus-minting-script-example.md)\n- PyCardano (Python): [Spending](https://pycardano.readthedocs.io/en/latest/guides/plutus.html)\n- Lucid (TypeScript): [Spending](https://aiken-lang.org/example--vesting#off-chain-code)\n\nMore example smart contracts can be found [in the example section of opshin](https://github.com/OpShin/opshin/tree/master/examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopshin%2Fopshin-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopshin%2Fopshin-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopshin%2Fopshin-example/lists"}