// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract EdgeSwarm is ERC20 { address public owner; // This stores the number of tasks completed by each wallet. // Your Android App uses this for the raw integer balance. mapping(address => uint256) public ubiEarned; struct WorkTask { uint256 taskId; int256 predictionScore; // The confidence from your LoRA logic address worker; uint256 timestamp; string fileHash; // <-- ADDED: Stores the JSON fingerprint on-chain } // Maps Task ID to the result submitted by the phone mapping(uint256 => WorkTask) public ledger; // <-- ADDED string fileHash: This allows the Dashboard to generate the URL event WorkVerified(address indexed worker, uint256 taskId, int256 score, string fileHash); constructor() ERC20("Swarm Token", "SWM") { owner = msg.sender; } /** * @dev This is the function your Pixel 10 calls. * <-- ADDED string memory _fileHash to the required parameters */ function submitWork(uint256 _taskId, int256 _score, string memory _fileHash) public { require(ledger[_taskId].worker == address(0), "Task already completed"); // 1. Record the "Real Work" in the ledger ledger[_taskId] = WorkTask({ taskId: _taskId, predictionScore: _score, worker: msg.sender, timestamp: block.timestamp, fileHash: _fileHash // Save the hash to the ledger }); // 2. INCREMENT THE COUNTER: This ensures your app sees the new balance. ubiEarned[msg.sender] += 1; // 3. Reward the device with 1 full ERC20 token (18 decimals) _mint(msg.sender, 1 * 10**18); // 4. Emit the event with the hash so the Dashboard can read it emit WorkVerified(msg.sender, _taskId, _score, _fileHash); } }