{"id":20074562,"url":"https://github.com/mgthetrain/cardano-blockchain-sample","last_synced_at":"2025-05-05T21:31:51.896Z","repository":{"id":209152464,"uuid":"723356870","full_name":"MGTheTrain/cardano-blockchain-sample","owner":"MGTheTrain","description":"Sample repository implemented in regards to the Cardano blockchain.","archived":false,"fork":false,"pushed_at":"2024-02-07T07:42:39.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-07T08:36:55.323Z","etag":null,"topics":["cardano-blockchain","cardano-node","cardano-smart-contracts","cardano-wallet","sample"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MGTheTrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-11-25T12:11:48.000Z","updated_at":"2023-11-26T14:05:52.000Z","dependencies_parsed_at":"2024-02-07T08:44:44.292Z","dependency_job_id":null,"html_url":"https://github.com/MGTheTrain/cardano-blockchain-sample","commit_stats":null,"previous_names":["mgthetrain/python-cardano-blockchain-sample","mgthetrain/cardano-blockchain-sample"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGTheTrain%2Fcardano-blockchain-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGTheTrain%2Fcardano-blockchain-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGTheTrain%2Fcardano-blockchain-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MGTheTrain%2Fcardano-blockchain-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MGTheTrain","download_url":"https://codeload.github.com/MGTheTrain/cardano-blockchain-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224470591,"owners_count":17316704,"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-blockchain","cardano-node","cardano-smart-contracts","cardano-wallet","sample"],"created_at":"2024-11-13T14:52:55.393Z","updated_at":"2024-11-13T14:52:56.029Z","avatar_url":"https://github.com/MGTheTrain.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cardano-blockchain-sample\n\n## Table of Contents\n\n+ [Summary](#summary)\n+ [References](#references)\n+ [How to use](#how-to-use)\n\n## Summary\n\nSample repository implemented in regards to the Cardano blockchain.\n\nCopilot: *Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code. They are stored on a blockchain network and automatically execute when certain conditions are met. Here are some examples of smart contract use cases:*\n- *Finance: Smart contracts can be used for trading, investing, lending, and borrowing*\n- *Healthcare: Smart contracts can be used to store and share medical records securely and efficiently*\n- *Gaming: Smart contracts can be used to create decentralized gaming platforms that allow players to earn cryptocurrency rewards* \n- *Real Estate: Smart contracts can be used to automate the process of buying and selling real estate, reducing the need for intermediaries*\n- *Legal Industry: Smart contracts can be used to automate legal agreements, such as wills and trusts*\n\n## References\n\n### Cardano basics (e.g. cardano-node and cardano-wallet)\n\n- [Python cardano-tools pip package](https://pypi.org/project/cardano-tools/)\n- [Cardano Python Module quickstart](https://cardano-python.readthedocs.io/en/latest/quickstart.html)\n- [cardano-wallet](https://github.com/cardano-foundation/cardano-wallet/tree/master)\n- [Getting started with Cardano testnets](https://docs.cardano.org/cardano-testnet/getting-started/#:~:text=To%20get%20started%20and%20join,ada%20to%20test%20your%20transactions.)\n- [The official Cardano Environment configuration files](https://book.world.dev.cardano.org/environments.html#vasil-dev)\n\n### Deploying smart contracts to Cardano blockchain\n\n- [Smart Contracts](https://developers.cardano.org/docs/smart-contracts/)\n- [Plutus Pioneer Program - Part 2: How to “deploy” a Smart Contract in Cardano](https://www.essentialcardano.io/article/plutus-pioneer-program-part-2-how-to-deploy-a-smart-contract-in-cardano)\n- [how to deploy smart contract on cardano](https://www.youtube.com/results?search_query=how+to+deploy+smart+contract+on+cardano)\n\n## How to use\n\n### Prerequisite\n\n- Install the [Docker Engine](https://docs.docker.com/engine/install/)\n- Install [Python 3 from the official site](https://www.python.org/downloads/) or via package manager (apt, choco, brew)\n\n### Ramp up the docker-compose cluster containing the cardano-node container and cardano-wallet container\n\nRefer to [`Quickstart` section here](https://github.com/cardano-foundation/cardano-wallet/tree/master). Ramp up the docker-compose and select one of the  Cardano Environment:\n\n```sh\n# On Unix systems or on Windows OS 10 with Git Bash or WSL\nNETWORK=preview docker-compose up -d --build # Preview Testnet (preferred for development)\nNETWORK=preprod docker-compose up -d --build # Pre-Production Testnet\nNETWORK=mainnet docker-compose up -d --build # Production (Mainnet)\n# This will start up the Cardano node and wallet applications and connect to the specified network (mainnet, preview, preprod)\n```\n\n### Execute commands within a running container interactively\n\n```sh\ndocker exec -it \u003ccardano-wallet or cardano-node container id\u003e sh\n```\n\n### Test connection to the cardano-wallet\n\n```sh\n# with curl\ncurl http://localhost:8090/v2/network/information\n# with cli in cardano-wallet container\ndocker run --network host --rm cardanofoundation/cardano-wallet network information\n\n# Wallet operations\ndocker run --network host --rm cardanofoundation/cardano-wallet wallet list\ndocker run --network host --rm cardanofoundation/cardano-wallet wallet delete \u003cwallet id\u003e\n```\n\n### Run Python sample app interfacing with the Cardano wallet\n\nExecute sample app:\n\n```sh\ncd cardano-wallet-app\npip install -r requirements.txt\npython main.py\n```\n\nExecute sample app in a docker container:\n\n```sh\ncd cardano-wallet-app\ndocker build -t python-cardano-sample-app:stable . # Build docker image\ndocker run --network host --rm python-cardano-sample-app:stable sh \"python main.py\" # Start a container\n```\n\n### Compile Python smart contract\n\nCompile contract:\n\n```sh\ncd cardano-smart-contract\npip install -r requirements.txt\nopshin build simple-withdraw-contract.py # It checks the presence of a specific signature in the transaction to approve spending funds\nopshin build simple-healthcare-contract.py # This smart contract defines a HealthDatum data class that inherits from PlutusData. The HealthDatum class has five attributes: patient_id, doctor_id, diagnosis, treatment, and cost. The validator function checks if the cost attribute of the datum object is greater than zero and if the length of the patient_id and doctor_id attributes is 32 bytes. If any of these conditions are not met, the function raises an AssertionError with an appropriate message.\n```\n\nCompile contract in a docker container:\n\n```sh\ncd cardano-smart-contract\ndocker build -t python-cardano-sample-smart-contract:stable . # Build docker image\ndocker run --rm -v $(pwd)/contract/:/app/build/simple-withdraw-contract/ python-cardano-sample-smart-contract:stable sh \"opshin build simple-withdraw-contract.py\" # Start a container, It checks the presence of a specific signature in the transaction to approve spending funds\ndocker run --rm -v $(pwd)/contract/:/app/build/simple-healthcare-contract/ python-cardano-sample-smart-contract:stable sh \"opshin build simple-healthcare-contract.py\" # Start a container, It checks the presence of a specific signature in the transaction to approve spending funds\n```\n\nSmart contracts need to be deployed to the Cardano blockchain. See [Plutus Pioneer Program - Part 2: How to “deploy” a Smart Contract in Cardano](https://www.essentialcardano.io/article/plutus-pioneer-program-part-2-how-to-deploy-a-smart-contract-in-cardano).\n\n### Clear docker resources\n\n```sh\ndocker rm -f $(docker ps -qa)\ndocker system prune --volumes --force\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgthetrain%2Fcardano-blockchain-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgthetrain%2Fcardano-blockchain-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgthetrain%2Fcardano-blockchain-sample/lists"}