A decentralized, transparent, and secure platform for managing retail transactions and loyalty points using blockchain technology.
Traditional retail systems often suffer from:
✅ Solution: Leverage blockchain to provide decentralized, transparent, and tamper-proof retail transaction management.
Technology | Purpose | Why? |
---|---|---|
Solidity | Smart contract programming language. | Standard for EVM-based blockchains. |
Ethereum/Ganache | Blockchain platform for transaction and loyalty records. | Decentralized ledger with local dev support via Ganache. |
FastAPI | Web API framework (Python 3.7+). | High-performance, async support, automatic interactive docs. |
Web3.py | Ethereum blockchain interaction library. | Connects to Ethereum nodes, manages smart contracts and transactions. |
Pydantic | Data validation and management. | Robust validation for API requests and responses. |
python-dotenv | Environment variable management. | Safely handles sensitive config like private keys. |
solcx | Solidity compiler wrapper for Python. | Compiles smart contracts programmatically. |
Docker | Containerization platform. | Consistent, portable deployment environment. |
+--------------------+ +----------------------------+ +-----------------------+
| Frontend (Optional)| | FastAPI Backend (Python) | | Ethereum Blockchain |
| (e.g., React/Vue) | | | | (Ganache for Dev) |
+--------+-----------+ +------------+---------------+ +-----------+-----------+
| | |
| HTTP Requests (API Calls) | REST Endpoints | Smart Contract Calls
|--------------------------------->+--(/transactions, /loyalty, /status)--|--------------------------->
| | | - RetailTransaction.sol
| | | - LoyaltyPoints.sol
| | |
|<---------------------------------| API Responses |<---------------------------
| Data / Status | | Transaction Receipts
| | | Loyalty Balances
| | |
+--------+---------+ +------------+---------------+ +-----------+-----------+
|
| Services:
| - Contracts Manager (compile, deploy, load)
| - Currency Converter (INR <-> Wei)
| - Loyalty Manager (calculate, award, redeem, check)
| - Transaction Manager (match off-chain IDs)
|
| Startup:
| - Initializes/Deploys Contracts
|
| Models:
| - Pydantic Schemas
Services:
Workflow:
Base URL: http://localhost:8000
Available at:
/docs
(Swagger UI)/redoc
Check API Status
curl -X GET "http://localhost:8000/"
Record a Retail Transaction
curl -X POST "http://localhost:8000/transactions/record" -H "Content-Type: application/json" -d '{ "customer_address": "0xCustomerEthAddress", "retailer_address": "0xRetailerEthAddress", "amount_INR": 1500.75, "product_id": "PROD123", "quantity": 2, "description": "Purchase of electronics" }'
Get Transaction Details
curl -X GET "http://localhost:8000/transactions/1"
Get Loyalty Balance
curl -X GET "http://localhost:8000/loyalty/balance/0xCustomerEthAddress"
Redeem Loyalty Points
curl -X POST "http://localhost:8000/loyalty/redeem" -H "Content-Type: application/json" -d '{ "customer_address": "0xCustomerEthAddress", "points_amount": 100 }'
Prerequisites:
Steps:
📈 Increased Potential Customer Retention: Engineered a blockchain-based loyalty transaction system, increasing potential customer retention by 5–10% through transparent, tamper-proof reward point tracking and redemption.