Skip to content

Latest commit

Β 

History

History
330 lines (273 loc) Β· 9.23 KB

File metadata and controls

330 lines (273 loc) Β· 9.23 KB

πŸ”₯ Test Real Cardano Blockchain Transactions

βœ… Status: NO SIMULATIONS - 100% Real Blockchain

All simulated transaction fallbacks have been removed. Every transaction now goes directly to the Cardano blockchain.

πŸš€ Quick Test (5 Minutes)

Prerequisites Checklist:

  • βœ… Blockfrost API key configured in frontend/.env
  • βœ… Cardano wallet installed (Nami/Lace/Eternl/Flint)
  • βœ… Wallet has testnet ADA (get from faucet)
  • βœ… Development servers running (npm run dev)
  • βœ… Freelancer needs: 1.2 ADA minimum (1 ADA + fees for completion)
  • βœ… Client needs: Milestone amount + 0.2 ADA (for payment + fees)

Step 1: Get Testnet ADA (2 minutes)

# 1. Open your Cardano wallet
# 2. Copy your wallet address
# 3. Visit: https://docs.cardano.org/cardano-testnet/tools/faucet/
# 4. Paste your address and request ADA
# 5. Wait ~20 seconds for confirmation

You need:

  • Freelancer wallet: Minimum 2 ADA (1 ADA for completion proof + fees)
  • Client wallet: Minimum 3 ADA (2 ADA milestone payment + fees)
  • Total for full test: 5 ADA across both wallets

Step 2: Connect Wallet

  1. Open http://localhost:3000
  2. Click "Connect Wallet" (top right)
  3. Select your wallet (Nami/Lace/etc)
  4. Approve the connection
  5. Verify your address and balance display

Step 3: Create Test Project

  1. Click "Create Project"
  2. Fill in:
    Title: Real Blockchain Test
    Description: Testing real Cardano transactions
    Freelancer Address: [paste another address or same for testing]
    
    Milestone 1:
    - Description: Test milestone
    - Amount: 2000000 (2 ADA)
    - Deadline: [any future date]
    
  3. Click "Create Project"
  4. Note the project ID

Step 4: Complete Milestone (Freelancer) πŸ”₯

This is a REAL blockchain transaction!

  1. Navigate to the project detail page
  2. As freelancer, click "Mark Complete"
  3. Wallet popup appears - Review transaction:
    Sending: 1 ADA (proof of completion)
    To: [client address]
    Fee: ~0.17 ADA
    Metadata: Completion proof with milestone details
    
  4. Click "Confirm" in wallet
  5. Wait 5-10 seconds
  6. Success! Completion transaction hash displayed
  7. Status changes to "Completed"

Why 1 ADA? This creates an immutable on-chain record that the freelancer has completed the work and is requesting approval. The client receives 1 ADA as proof.

Step 5: Approve & Release Funds (Client) πŸ”₯

This is the REAL blockchain transaction!

  1. As client, click "Approve & Release Funds"
  2. Wallet popup appears - Review transaction:
    Sending: 2 ADA
    To: [freelancer address]
    Fee: ~0.17 ADA
    Metadata: Project and milestone info
    
  3. Click "Confirm" in wallet
  4. Wait 5-10 seconds
  5. Success! Transaction hash displayed

Step 6: Verify on Blockchain Explorer

  1. Copy the transaction hash from the success message
  2. Visit: https://preprod.cardanoscan.io/
  3. Paste the transaction hash
  4. See your real transaction!
    • βœ… Amount: 2 ADA
    • βœ… Sender: Your address
    • βœ… Recipient: Freelancer address
    • βœ… Metadata: Project details
    • βœ… Status: Confirmed
    • βœ… Block number
    • βœ… Timestamp

🎯 What Happens Behind the Scenes

Transaction 1: Mark Complete (Freelancer)

1. Freelancer clicks "Mark Complete"
2. Lucid builds transaction: 1 ADA β†’ Client
3. Metadata: Completion proof + milestone details
4. Wallet signs transaction locally
5. Lucid submits to Blockfrost API
6. Blockfrost submits to Cardano network
7. Transaction hash returned
8. Backend updated with completion tx hash

Transaction 2: Approve & Release Funds (Client)

1. Client clicks "Approve & Release Funds"
2. Lucid builds transaction: Full amount β†’ Freelancer
3. Metadata: Payment proof + milestone details
4. Wallet signs transaction locally
5. Lucid submits to Blockfrost API
6. Blockfrost submits to Cardano network
7. Transaction hash returned
8. Backend updated with payment tx hash

Backend (Node.js):

1. Receives transaction hash from frontend
2. Validates and stores in database
3. Returns success with explorer URL
4. NO simulation fallbacks

Blockchain (Cardano):

1. Transaction enters mempool
2. Validators pick up transaction
3. Transaction included in block
4. Block confirmed (~20 seconds)
5. Funds transferred on-chain
6. Permanent immutable record

πŸ” Transaction Details

Completion Transaction (Freelancer β†’ Client):

  • Amount: 1 ADA (proof of completion)
  • Sender: Freelancer wallet address
  • Recipient: Client wallet address
  • Fee: ~0.17 ADA (network fee)
  • Metadata (Label 674):
    {
      "type": "milestone_completion",
      "projectId": "project_123",
      "milestoneId": 1,
      "projectTitle": "Real Blockchain Test",
      "milestoneDescription": "Test milestone",
      "completedBy": "addr_test1freelancer...",
      "timestamp": "2024-12-15T16:30:00Z",
      "message": "Freelancer has completed this milestone and is requesting approval"
    }

Payment Transaction (Client β†’ Freelancer):

  • Amount: Full milestone amount (e.g., 2 ADA)
  • Sender: Client wallet address
  • Recipient: Freelancer wallet address
  • Fee: ~0.17 ADA (network fee)
  • Metadata (Label 674):
    {
      "type": "milestone_payment",
      "projectId": "project_123",
      "milestoneId": 1,
      "projectTitle": "Real Blockchain Test",
      "milestoneDescription": "Test milestone",
      "timestamp": "2024-12-15T16:30:00Z"
    }

Transaction Properties:

  • βœ… Immutable: Cannot be reversed or modified
  • βœ… Transparent: Anyone can verify on blockchain
  • βœ… Permanent: Stored forever on Cardano
  • βœ… Trustless: No intermediary needed
  • βœ… Verifiable: Check on any Cardano explorer

⚠️ Important Notes

NO Simulations:

  • ❌ No fallback to mock transactions
  • ❌ No simulated transaction hashes
  • ❌ No demo mode for approvals
  • βœ… 100% real blockchain or error

Requirements:

  • βœ… Valid Blockfrost API key (free from blockfrost.io)
  • βœ… Wallet connected with sufficient ADA
  • βœ… Development mode (npm run dev)
  • βœ… Network connectivity

If Transaction Fails:

The app will show a detailed error message:

  • Wallet not connected β†’ Connect wallet first
  • Insufficient funds β†’ Get more testnet ADA
  • Invalid API key β†’ Configure Blockfrost key
  • Network error β†’ Check internet connection

πŸ§ͺ Advanced Testing

Test Multiple Milestones:

Create project with 3 milestones:
- Milestone 1: 2 ADA
- Milestone 2: 3 ADA  
- Milestone 3: 5 ADA

Complete and approve each one separately.
Each creates a separate blockchain transaction.

Test Different Wallets:

1. Create project with Wallet A (client)
2. Set Wallet B as freelancer
3. Complete milestone with Wallet B
4. Approve with Wallet A
5. Verify funds arrive in Wallet B

Test Transaction Metadata:

1. Complete transaction
2. View on explorer
3. Click "Metadata" tab
4. See project and milestone details
5. Verify all information is correct

πŸ“Š Expected Results

Console Logs (Frontend):

πŸ’° Approving milestone and releasing funds...
Amount: 2 ADA
Recipient: addr_test1...
πŸ”¨ Building real blockchain transaction...
βœ… Transaction signed, submitting to blockchain...
πŸ“‘ Submitting to Cardano network via Blockfrost...
βœ… Transaction submitted successfully to Cardano blockchain!
Transaction hash: a1b2c3d4e5f6...
View on explorer: https://preprod.cardanoscan.io/transaction/a1b2c3d4e5f6...

Console Logs (Backend):

βœ… Approving milestone 1 for project project_123
πŸ’° Recording blockchain transaction...
Transaction hash: a1b2c3d4e5f6...
View on explorer: https://preprod.cardanoscan.io/transaction/a1b2c3d4e5f6...

User Experience:

  1. Click button
  2. Wallet popup (5 seconds)
  3. Confirm transaction
  4. Success message with tx hash (5 seconds)
  5. Funds transferred on blockchain (20 seconds)
  6. Verifiable on explorer (immediately)

πŸŽ‰ Success Indicators

You'll know it's working when:

  • βœ… Wallet prompts for signature
  • βœ… Real transaction hash returned (64 characters)
  • βœ… Transaction visible on Cardano explorer
  • βœ… Funds actually transferred between wallets
  • βœ… Metadata visible on blockchain
  • βœ… Transaction confirmed in blocks

πŸ”§ Troubleshooting

"Wallet not connected"

β†’ Click "Connect Wallet" and approve

"Insufficient funds"

β†’ Get more testnet ADA from faucet

"Invalid project token"

β†’ Check Blockfrost API key in frontend/.env

"Lucid library not available"

β†’ Make sure you're running npm run dev (not production build)

Transaction pending forever

β†’ Check Cardano network status β†’ Verify on explorer β†’ May take up to 2 minutes during high load

πŸ“ˆ Next Steps

After successful testing:

  1. βœ… Test with different amounts
  2. βœ… Test with multiple milestones
  3. βœ… Test with different wallets
  4. βœ… Verify all transactions on explorer
  5. βœ… Check metadata is correct
  6. βœ… Confirm funds arrive in recipient wallet

🌐 Mainnet Deployment

To use real ADA on mainnet:

  1. Change network to mainnet in .env
  2. Get mainnet Blockfrost API key
  3. Use real ADA (not testnet)
  4. Test thoroughly on testnet first!

Status: βœ… Real blockchain transactions only - No simulations Network: Cardano Preprod Testnet Last Updated: December 15, 2024