ReceiptHub is a decentralized application (dApp) built on the Internet Computer platform for managing and storing digital receipts. This project allows users to register, store receipts, and retrieve receipt information using a user-friendly dashboard interface.
- User registration
- Store digital receipts
- Retrieve individual receipts
- Get receipts by group ID
- Interactive dashboard
- Interact with API canister
- Node.js (version 16.0.0 or higher)
- npm (version 7.0.0 or higher)
- dfx (DFINITY Canister SDK)
- Clone the repository:
git clone https://github.com/hydraerozine/ICPContracts.git cd receipthub - Install dependencies:
npm install
- Create a
.envfile in the root directory and add necessary environment variables:DFX_NETWORK=local CANISTER_ID_RECEIPT=your_receipt_canister_id CANISTER_ID_INTERNET_IDENTITY=your_internet_identity_canister_id DFX_VERSION='your_version' DFX_NETWORK='local' CANISTER_CANDID_PATH_RECEIPT='your_path/canisters/RECEIPT/RECEIPT.did' CANISTER_ID_RECEIPT_FRONTEND=your_canister_id CANISTER_ID_RECEIPT=your_canister_id CANISTER_ID_API=your_canister_id CANISTER_CANDID_PATH='your_path/canisters/RECEIPT_frontend/assetstorage.did' INTERNET_IDENTITY_CANISTER_ID=your_canister_id II_URL=http://your_canister_id.localhost:your_port/ RECEIPT_CANISTER_ID=your_canister_id LOCAL_NETWORK_URL_API='http://your_canister_id.localhost:your_port/'
- Start the local Internet Computer replica:
dfx start --background --clean
- Deploy the canisters:
dfx deploy
- Build the development server:
npm run build
- Start the development server:
This will start a server at
npm run start
http://localhost:8080, proxying API requests to the replica at port 4943.
npm run build: Build the project for productionnpm start: Start the development servernpm run Ogen: Generate API key for mainnet API canisternpm run Otest: Test the mainnet API canisternpm run gen: Generate local APInpm run get: Fetch a receiptnpm run getg: Fetch receipts by groupnpm run store: Store a new receipt
The project includes several scripts for interacting with the canisters:
src/FetchAPI/MakeAPI.js: Create an API keysrc/FetchAPI/GetReceipt.js: Retrieve a specific receiptsrc/FetchAPI/GetGroup.js: Retrieve receipts for a groupsrc/FetchAPI/Store.js: Store a new receipt example
To use these scripts, run them with Node.js. For example:
node src/FetchAPI/GetReceipt.jsThe frontend is built using HTML, CSS, and JavaScript. The main files are:
src/RECEIPT_frontend/assets/index.html: Main HTML filesrc/RECEIPT_frontend/assets/index.js: Main JavaScript filesrc/RECEIPT_frontend/assets/styles.css: Stylesheet
To deploy the project to the Internet Computer mainnet:
- Configure your dfx.json for mainnet deployment
- Run:
dfx deploy --network ic
Contributions are welcome! Please feel free to submit a Pull Request.