Skip to content

The repository containing code for creating subgraph for medichain project.

License

Notifications You must be signed in to change notification settings

sadityakumar9211/medichain-thegraph

Repository files navigation

Contributors Forks Stargazers Issues GPL-3.0 License LinkedIn


Logo

MediChain: Decentralized Telemedicine and Medical Records

This repository is one of the three repositories which are part of MediChain Project.
medichain-hardhat: Hardhat Repository of MediChain Project»
medichain-nextjs: The Next.js Repository of MediChain Project»

Watch Demo Videos
View Demo · Report Bug · Request Feature

This is the The Graph repository of this project.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Locally Deploying
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

current image

Blockchain being an immutable ledger and with decentralized nature has a great potential for increasing the security, privacy and efficiency of Medical Health Record keeping systems. Currently existing solutions rely on centralised database which are susceptible to Ransomware attacks, Denial of Service(DoS) attacks and also have significant counterparty risks. Some decentralized solutions are also exist but some of them are not really decentralized that are based on private or permis- sioned blockchain, while some which are based on public blockchain have not properly addressed the performance and scalability issues.

The proposed system is based on EVM compatible public blockchains using IPFS as a decentralized file storage solution and uses 2048 bit RSA encryption to encrypt the IPFS HASH of file metadata on the client-side before uploading the HASH on the blockchain. For supporting fast and complex queries this system uses a decentralized indexing protocol The Graph. The smart contract is currently deployed on Goerli Testnet.

With this system patients can access their medical records anytime anywhere without the counterparty risk from centralized entity. This system also features QR code for sharing of medical files from patients to doctors. With the proposed implementation the decentralized medical record keeping system provides increased security and privacy compared to centralized systems without loss of significant performance or scalability benefits.

The links to other repositories of this project is at the top.

(back to top)

Built With

This repository contains the code for developing a subgraph which indexes the smart-contract deployed in the medichain-hardhat repository.

  • The Graph

(back to top)

Getting Started

Requirements

  • git
    • You'll know you did it right if you can run git --version and you see a response like git version x.x.x
  • Nodejs
    • You'll know you've installed nodejs right if you can run:
      • node --version and get an ouput like: vx.x.x
  • Yarn instead of npm
    • You'll know you've installed yarn right if you can run:
      • yarn --version and get an output like: x.x.x
      • You might need to install it with npm
  • Optional Instruction
    • Make sure that this repository and medichain-hardhat repository are in the same level in your directory structure.
    • This makes sure that whenever you deploy the smart contract, this repository's constants files are updated.

Quickstart

  1. Install Subgraph CLI
yarn global add @graphprotocol/graph-cli
  1. Log into the graph UI and create a new Subgraph.

Use Goerli as the network.

  1. Initialize Subgraph
graph init --studio medichain
  1. Authenticate CLI
graph auth  --studio YOUR_DEPLOY_KEY_HERE
  1. Update your subgraph.yaml:
  • Update the address with your PatientMedicalRecordSystem Contract Address
  • Update the startBlock with the block right before your contract was deployed
  1. Build graph locally
graph codegen && graph build
  • graph codegen: Generates code in the generated folder based on your schema.graphql
  • graph build: Generates the build that will be uploaded to the graph
  1. Deploy subgraph

Replace VERSION_NUMBER_HERE with a version number like v0.0.1.

graph deploy --studio medichain -l VERSION_NUMBER_HERE
  1. Update the temporary query URI in the Next.js project
  • update the uri in your _app.js with the temporary query URI generated after deploying your subgraph.

  • To start your frontend run:

yarn dev

Optional Gitpod

If you can't or don't want to run and install locally, you can work with this repo in Gitpod. If you do this, you can skip the clone this repo part.

Open in Gitpod

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GPL-3.0 License. See COPYING for more information.

(back to top)

Contact

If you appreciated this, feel free to follow me or donate!

ETH Address: 0xED5A704De64Ff9699dB62d09248C8d179bb77D8A

Aditya Singh Linkedin Aditya Singh Twitter Aditya Singh StackOverflow Aditya Singh Medium Aditya Singh Gmail

Project Link: https://github.com/sadityakumar9211/medichain-hardhat

(back to top)

Acknowledgments

About

The repository containing code for creating subgraph for medichain project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published