Blockchain Service
The blockchain service is a dedicated microservice that handles all interactions with the Algorand blockchain. It manages smart contracts, processes transactions, and maintains the immutable record of all platform operations.Core Blockchain Operations
LabTrace performs five main types of blockchain transactions, each recorded permanently on the Algorand blockchain:Project Creation
Initialize new projects with blockchain identity and access control
Project Invitations
Add users to projects with specific roles and permissions
Invitation Removal
Remove user access from projects with audit trail
File Upload
Record file storage and metadata on the blockchain
File Deletion
Mark files as deleted while preserving historical records
Transaction Types
The blockchain service implements complex multi-step operations called “sagas” rather than single transactions. Each major operation involves multiple Algorand transactions executed in sequence. The system supports 29 different transaction types across five main categories:Transaction Categories
Project Management
PROJECT_FUNDING- Initial project account fundingPROJECT_ASSET_CREATION- Create project-specific Algorand Standard Asset (ASA)PROJECT_CONTRACT_CREATION- Deploy public smart contractPROJECT_PRIVATE_CONTRACT_CREATION- Deploy private smart contractPROJECT_CREATION_CLAWBACK_CREDITS- Deduct credits for project creation
User Operations
USER_CREATION_FUNDING- Fund new user accountsUSER_ESCROW_OPT_IN- Opt user into credits systemUSER_CREDITS_ASSET_TRANSFER- Transfer credits to users
Project Invitations
PROJECT_USER_ACCOUNT_FUNDING- Fund invited user accountPROJECT_INVITATION_FUNDING- Fund project for invitationPROJECT_ASSET_OPT_IN- User opts into project assetPROJECT_ASSET_TRANSFER- Transfer project tokens to userPROJECT_APPLICATION_OPT_IN- User opts into public contractPROJECT_PRIVATE_APPLICATION_OPT_IN- User opts into private contractPROJECT_WHITELIST- Whitelist user in public contractPROJECT_PRIVATE_WHITELIST- Whitelist user in private contractPROJECT_INVITATION_CLAWBACK_CREDITS- Deduct credits for invitation
File Operations
PROJECT_FILE_UPLOAD_FUNDING- Fund user for file uploadPROJECT_FILE_UPLOAD- Record file on blockchainPROJECT_FILE_DELETION_FUNDING- Fund user for file deletionPROJECT_FILE_DELETION- Record file deletion on blockchainFILE_UPLOAD_CLAWBACK_CREDITS- Deduct credits for uploadFILE_DELETION_CLAWBACK_CREDITS- Deduct credits for deletion
User Removal
PROJECT_USER_REMOVAL_FUNDING- Fund removal processPROJECT_USER_REMOVAL_USER_FUNDING- Fund user account for removalPROJECT_USER_REMOVAL_ASSET_CLAWBACK- Reclaim project tokensPROJECT_USER_REMOVAL_PUBLIC_CLOSEOUT- Close out public contractPROJECT_USER_REMOVAL_PRIVATE_CLOSEOUT- Close out private contract
1. Project Creation Saga
Project creation involves multiple sequential transactions: Step 1: Credits Deduction2. Project Invitation Saga
Adding users to projects requires multiple blockchain operations: Step 1: Credits Deduction3. File Upload Saga
File uploads involve blockchain recording with IPFS integration: Step 1: Credits Deduction- IPFS content identifier (CID)
- Linked file references
- Upload timestamp
- User authorization proof
4. File Deletion Saga
File deletions maintain audit trail while marking files as deleted: Step 1: Credits Deduction- Original file IPFS hash
- Deletion reason
- Deletion timestamp
- User authorization proof
5. User Removal Saga
Removing users involves complex cleanup: Step 1: Project FundingSmart Contract Details
Contract Structure
The system uses a single smart contract template deployed twice per project:- Public Contract: For general project files
- Private Contract: For sensitive project files
Contract Operations
Transaction Notes Format
- Funding:
LT-funding-{uuid} - File Upload:
CID: {ipfsHash} | Linked to: {linkedFiles} - File Deletion:
Deletion reason: {reason} | CID: {ipfsHash} - Whitelist:
{uuid}
Transaction Monitoring
The system continuously monitors all transactions through multiple states: Transaction States:CREATED- Transaction prepared but not sentSENT- Transaction submitted to networkCONFIRMED- Transaction confirmed on blockchainEXPIRED- Transaction expired without confirmationERROR- Transaction failed
- Transactions are created and stored with
CREATEDstatus - Periodic job sends transactions to Algorand network
- Status updates to
SENTwhen successfully submitted - Confirmation monitoring checks for blockchain inclusion
- Status updates to
CONFIRMEDwith timestamp when included - Saga continuation triggered by confirmation events
