{"id":20162646,"url":"https://github.com/codeamt/fastapi-blockchain-template","last_synced_at":"2025-04-10T00:36:10.471Z","repository":{"id":201923639,"uuid":"331461229","full_name":"codeamt/fastapi-blockchain-template","owner":"codeamt","description":"Blockchain Network Implementation with FastAPI and Python","archived":false,"fork":false,"pushed_at":"2021-01-23T04:03:40.000Z","size":18,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T02:21:57.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codeamt.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}},"created_at":"2021-01-20T23:36:02.000Z","updated_at":"2024-12-25T18:31:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"53ba5e36-e449-4c8e-877b-04447c8709b8","html_url":"https://github.com/codeamt/fastapi-blockchain-template","commit_stats":null,"previous_names":["codeamt/fastapi-blockchain-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeamt%2Ffastapi-blockchain-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeamt%2Ffastapi-blockchain-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeamt%2Ffastapi-blockchain-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeamt%2Ffastapi-blockchain-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeamt","download_url":"https://codeload.github.com/codeamt/fastapi-blockchain-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137936,"owners_count":21053771,"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":[],"created_at":"2024-11-14T00:26:07.157Z","updated_at":"2025-04-10T00:36:10.440Z","avatar_url":"https://github.com/codeamt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e fastapi-blockchain-template\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eCloud-native Blockchain Network Implementation in Python with \u003cb\u003eFastAPI\u003c/b\u003e, Docker, Kubernetes and Okteto Cloud.\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://www.nicepng.com/png/detail/67-670388_the-blockchain-is-a-decentralized-technology-that-it.png\" width=\"25%\" /\u003e\n\u003c/p\u003e\n\n\n## Dependencies and Tools \npip packages: \n- fastapi\n- httpx \n- gunicorn \n- uvicorn \n- pif \n- pydantic \n- python-dotenv \n\ndev: \n- Okteto \n- Docker \n\ndeployment: \n- Heroku\n- Kubernetes\n\n\n## Documentation \n\n- Blockchain Server: [http://{ip_address}:{port}/docs]() \n- Node Application: [http://{ip_address}:{port}/node/docs]()\n\n\n## Development \n\n\u003cb\u003eLocal:\u003c/b\u003e \n```\n$ git clone https://github.com/codeamt/fastapi-blockchain-template.git\n$ cd fastapi-blockchain-template\n$ sh run.sh \n```\n\n\u003cb\u003eDocker (Build):\u003c/b\u003e \n```\n$ docker build -f Dockerfile -t app:latest ./code\n```\n\n\u003cb\u003e Docker (Run):\u003c/b\u003e\u003cbr\u003e\nAdd a ```.env``` file to your root and: \n```\n$ docker run -p 5000:5000 --env-file=env_file_name app:latest\n```\n\n\u003cb\u003eOkteto:\u003c/b\u003e\n```\n$ okteto login \n$ okteto namespace\n$ okteto init --deploy\n```\n\n## Production \n\n\u003cb\u003eHeroku:\u003c/b\u003e \n\nInstall [Heroku CLI tools](), then from the root:\n```\n$ git init\n$ touch .gitignore \n$ echo \".env\" \u003e\u003e .gitignore\n$ git add . \n$ git commit -m \"deploying to heroku\"\n$ heroku login\n$ heroku create \u003coptional: app_name\u003e\n$ heroku config:set PORT=\u003cdesired_port\u003e\n$ heroku config:set BLOCKCHAIN_URL=http://127.0.0.1:{PORT}\n$ heroku config:set INITIAL_DIFFICULTY=2\n$ git push heroku main\n$ heroku open \n```\n\n\u003cb\u003eKubernetes Cluster:\u003c/b\u003e \n```\n$ kubectl apply -f k8s.yml\n```\n\n\n## Endpoints \n\n\u003cb\u003eBlockchain Server:\u003c/b\u003e \n\n\u003ctable style=\"align: left; width:100%\"\u003e\n\u003cth\u003e\n  \u003cb style=\"text-align:center\"\u003eEndpoint\u003c/b\u003e\n\u003c/th\u003e\n\u003cth\u003e\n  \u003cb style=\"text-align:center\"\u003eDescription\u003c/b\u003e\n\u003c/th\u003e\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n      Index endpoint for Blockchain server.\u003cbr\u003e\n    :return: str\n  \u003c/td\u003e\n\u003c/tr\u003e\n \n \u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/mainchain\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n    Ledger endpoint for Blockchain server.\u003cbr\u003e\n    :return: dict -\u003e keys: peers: List[str]\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/peers\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Peers List endpoint for Blockchain Server.\u003cbr\u003e\n   :return: dict -\u003e keys: chain:Lis[dict] -\u003e Serialized Blocks\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/new-peer\u003c/code\u003e\u003cb\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Endpoint for creating new peer.\u003cbr\u003e\n   :param request: Request\u003cbr\u003e\n    :return: dict -\u003e keys: new_peer:str -\u003e IP Address\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/new_tx\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   New Transaction endpoint for Blockchain Server.\u003cbr\u003e\n    :param request: Request -\u003e HTTP POST request.\u003cbr\u003e\n    :return: dict -\u003e keys: sender:str; receipt:dict\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/mempool\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Mempool endpoint for Blockchain Server.\u003cbr\u003e\n    :return: dict -\u003e keys: mempool:dict\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/new_block\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   ew Block endpoint for Blockchain Server.\u003cbr\u003e\n    :param request: Request -\u003e HTTP POST request.\u003cbr\u003e\n    :return: dict -\u003e keys: miner_address:str, latest_block:dict, new_chain:List[dict]\n  \u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n\n\n\u003cb\u003eBootstrap Node Application:\u003c/b\u003e\n\n\n\u003ctable style=\"align: left; width: 500px\"\u003e\n\u003cth\u003e\n  \u003cb style=\"text-align:center\"\u003eEndpoint\u003c/b\u003e\n\u003c/th\u003e\n\u003cth\u003e\n  \u003cb style=\"text-align:center\"\u003eDescription\u003c/b\u003e\n\u003c/th\u003e\n\u003ctr\u003e\n  \u003ctd style=\"width:25%;\"\u003e\n   \u003cb\u003e\u003ccode\u003e/node\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Index endpoint for Bootstrap Node Client.\u003cbr\u003e\n   :return: dict: keys: local_chain: List[dict] -\u003e Local chain.\n  \u003c/td\u003e\n\u003c/tr\u003e\n \n \u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/chain\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Consensus Endpoint for BootStrap Node App.\u003cbr\u003e\n   :return: dict: keys: local_chain: List[dict]\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/peer-nodes\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Network Peers List Endpoint for Bootstrap Node App.\u003cbr\u003e\n   :return: dict: List[str]\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/mine\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Mining Endpoint for Bootstrap Node App.\u003cbr\u003e\n   :return: dict: block:dict -\u003e New Block (serialized)\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/transact\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   New Transaction Endpoint for Bootstrap Node App.\u003cbr\u003e\n   :return: dict: keys: sender:str; receipt:dict\n  \u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n  \u003ctd\u003e\n   \u003cb\u003e\u003ccode\u003e/mem_pool\u003c/code\u003e\u003c/b\u003e\n  \u003c/td\u003e\n  \u003ctd\u003e\n   Mempool Endpoint for Bootstrap Node App.\u003cbr\u003e\n   :return: dict: keys: mempool:dict -\u003e Mempool State.\n  \u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n**TODO:** \n- Configure Postgres DB\n- Reactive Frontend Application for Bootstrap Node\n- Unit Tests \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeamt%2Ffastapi-blockchain-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeamt%2Ffastapi-blockchain-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeamt%2Ffastapi-blockchain-template/lists"}