PharmaPort is blockchain based decentralised app (DApp) which should act as a unified interface to current track & trace solutions and provide additional functionalities. Centralised registries, which are currently maintained by central organisations like EMA (European Medicine Agency), such as verified stakeholders, managing marketing authorization holders, certifications such as Good Manufacturing Practice (GMP)/Good Distribution Practice (GDP), or a list of verified wholesale distributors, will be stored in a decentralised manner and made available for further usage in current track & trace solutions. This data should be able to be easily accessed and processed by authorised entities, thus creating a decentralised system for the European market.
-
Information Handling: The smart contract is capable of handling and storing information such as Competent Authorities and Verified Products, Stakeholders and wallet addresses, Authorisations for stakeholders, and Inspections/Compliance Reports. The smart contract also provides the functionality to mark stored records as inactive.
-
Notification/Events: Specific events are emitted when new data is added or updated in the smart contract, providing additional information about new transactions to the network. This information is logged on the blockchain and visible to all participants.
-
Controlled Upload: The backend provides a simple but effective access control mechanism to manage access rights and protect the system from unauthorized function calls. The smart contract offers different permission levels based on user responsibilities, allowing read and write access to the appropriate users.
-
Batch Load (Data): The backend is capable of batch loading data from structured JSON files during the deployment phase and passing this data as blockchain transactions to the smart contract. This enables testing the smart contract's functionalities using a realistic amount of data.
-
Display Smart Contract Data: The user interface allows users to retrieve and display all stored data from the smart contract, including Competent Authorities, Products, Stakeholders, Authorisations, and the results of the last inspection and compliance reports.
-
Integration with MetaMask: It is possible to connect the Ethereum wallet from MetaMask to securely interact with the smart contract. The interface displays the currently connected wallet.
-
Data Input Forms: Users can input new data into the frontend through interfaces and forms.
-
Notification/Events: Users are informed through the web interface with notifications after performing specific actions. Successful and failed transactions are visually differentiated using different colors.
- Solidity (Writing Smart Contracts & Tests)
- Javascript (React & Testing)
- Hardhat (Development Framework)
- Ethers.js (Blockchain Interaction)
- React.js (Frontend Framework)
- Install NodeJS
- Backend (Smart Contract | Hardhat):
cd .\contract\
$ npm install
- Fronted (Reactjs)
cd .\client\
$ npm install
cd .\contract\
$ npx hardhat test
cd .\contract\
$ npx hardhat node
In a separate terminal execute:
cd .\contract\
$ npx hardhat run ./scripts/deploy.js --network localhost
cd .\client\
$ npm run start
- Instead of connecting to the Mainnet, we it is needed to connect to the RPC connection to the WebSocket (http://localhost:8545)
- MetaMask Extention -> Network -> add Network
- Network Name: Localhost 8545
- RPC-URL: http://localhost:8545
- Chain-ID: 31337
- Import Hardhat test account (public/private key) to MetaMask and to sign the actions/transactions
- This Accounts can be found in the Terminal of the running node
- The following accounts are automatically listed as Competent Authorities and can sign transaction: Account #0, Account #1, Accoung #2
unclean shutting down of the node or unprocessed transactions can lead to high noce which blocks transactions can't be queued when automining. -> to fix this: Clear the Transaction Hisotry for the used accoung: Open MetaMask window -> Settings -> Advanced and hit "Delete Activity Tab data"
The local hardhat node can emmit eth_call errors as this is a hardhat/metamask integration bug currently: MetaMask/metamask-extension#14963 Transactions will still pass and this is considered as test net bug only
Released under the MIT License. Feel free to use, modify, and distribute this implementation in accordance with the terms of the license.