Skip to main content

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 funding
  • PROJECT_ASSET_CREATION - Create project-specific Algorand Standard Asset (ASA)
  • PROJECT_CONTRACT_CREATION - Deploy public smart contract
  • PROJECT_PRIVATE_CONTRACT_CREATION - Deploy private smart contract
  • PROJECT_CREATION_CLAWBACK_CREDITS - Deduct credits for project creation

User Operations

  • USER_CREATION_FUNDING - Fund new user accounts
  • USER_ESCROW_OPT_IN - Opt user into credits system
  • USER_CREDITS_ASSET_TRANSFER - Transfer credits to users

Project Invitations

  • PROJECT_USER_ACCOUNT_FUNDING - Fund invited user account
  • PROJECT_INVITATION_FUNDING - Fund project for invitation
  • PROJECT_ASSET_OPT_IN - User opts into project asset
  • PROJECT_ASSET_TRANSFER - Transfer project tokens to user
  • PROJECT_APPLICATION_OPT_IN - User opts into public contract
  • PROJECT_PRIVATE_APPLICATION_OPT_IN - User opts into private contract
  • PROJECT_WHITELIST - Whitelist user in public contract
  • PROJECT_PRIVATE_WHITELIST - Whitelist user in private contract
  • PROJECT_INVITATION_CLAWBACK_CREDITS - Deduct credits for invitation

File Operations

  • PROJECT_FILE_UPLOAD_FUNDING - Fund user for file upload
  • PROJECT_FILE_UPLOAD - Record file on blockchain
  • PROJECT_FILE_DELETION_FUNDING - Fund user for file deletion
  • PROJECT_FILE_DELETION - Record file deletion on blockchain
  • FILE_UPLOAD_CLAWBACK_CREDITS - Deduct credits for upload
  • FILE_DELETION_CLAWBACK_CREDITS - Deduct credits for deletion

User Removal

  • PROJECT_USER_REMOVAL_FUNDING - Fund removal process
  • PROJECT_USER_REMOVAL_USER_FUNDING - Fund user account for removal
  • PROJECT_USER_REMOVAL_ASSET_CLAWBACK - Reclaim project tokens
  • PROJECT_USER_REMOVAL_PUBLIC_CLOSEOUT - Close out public contract
  • PROJECT_USER_REMOVAL_PRIVATE_CLOSEOUT - Close out private contract

1. Project Creation Saga

Project creation involves multiple sequential transactions: Step 1: Credits Deduction
Step 2: Account Funding
Step 3: Asset Creation
Step 4: Public Contract Deployment
Step 5: Private Contract Deployment

2. Project Invitation Saga

Adding users to projects requires multiple blockchain operations: Step 1: Credits Deduction
Step 2: User Account Funding
Step 3: Project Funding
Step 4: Asset Opt-In
Step 5: Asset Transfer
Step 6: Public Contract Opt-In
Step 7: Public Whitelist
Step 8: Private Contract Opt-In
Step 9: Private Whitelist

3. File Upload Saga

File uploads involve blockchain recording with IPFS integration: Step 1: Credits Deduction
Step 2: Account Funding
Step 3: File Upload Record
What gets recorded:
  • 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
Step 2: Account Funding
Step 3: File Deletion Record
What gets recorded:
  • Original file IPFS hash
  • Deletion reason
  • Deletion timestamp
  • User authorization proof

5. User Removal Saga

Removing users involves complex cleanup: Step 1: Project Funding
Step 2: User Funding
Step 3: Asset Clawback
Step 4: Public Contract Closeout
Step 5: Private Contract Closeout

Smart 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 sent
  • SENT - Transaction submitted to network
  • CONFIRMED - Transaction confirmed on blockchain
  • EXPIRED - Transaction expired without confirmation
  • ERROR - Transaction failed
Monitoring Process:
  1. Transactions are created and stored with CREATED status
  2. Periodic job sends transactions to Algorand network
  3. Status updates to SENT when successfully submitted
  4. Confirmation monitoring checks for blockchain inclusion
  5. Status updates to CONFIRMED with timestamp when included
  6. Saga continuation triggered by confirmation events