Admin — Harvest batches
Approving runs TopCrop.anchorBatch with this row’s batch ID, final GPS (current row),
farmer address (address(0) unless farmer_address is set on the row), and an ordered list of every
ipfs_cid and data_hash from harvest_batch_history for that batch (or the current row only if the history table is empty / missing).
Your wallet must be the Contract Admin on Polygon Amoy (chain ID 80002). On-chain this is DEFAULT_ADMIN_ROLE.
Supabase status is set to anchored only after the transaction has 1 confirmation.
Pending rows with the same TC-XXXXXXXX-* prefix are grouped: use Approve & anchor chain to run anchors for every leg in order (one MetaMask transaction per leg).
You can select multiple pending batches and run Anchor selected; each batch still gets its own on-chain transaction (MetaMask prompts in order).
Row lists still come from Supabase filters (pending vs anchored/denied). The Status column in both tables is only from the contract getBatch() (on-chain enum: Created → Received). Use Audit chain ↔ Supabase to confirm on-chain batches are marked anchored in the database.
For a full custody trail in the pending table, add a harvest_batch_history table (same batch_id, assigned_role, ipfs_cid, gps, data_hash, updated_timestamp) populated on each capture update; otherwise the UI falls back to the current harvest_batches row only.
Pending approval
Anchored & denied
Batches already anchored on-chain (approved) or denied in Supabase — for audit and cross-check with Polygonscan.
This list is only rows where Supabase status is anchored or denied (queue for this view). The Status column is still from getBatch() after you connect.
A denied batch can be approved and anchored here if you change your mind: the same on-chain step runs first, then Supabase is updated to anchored.
Use Select all (anchorable denied) and Anchor selected to run several denied batches in sequence (one MetaMask transaction each).
Anchored rows are final — status cannot be changed from the UI.
Chain ↔ Supabase audit
Lists every batch_id from getAllBatchIds(), shows getBatch() state, and checks whether Supabase has been updated for admin anchor workflows: each on-chain batch should have harvest_batches.status = anchored.
If getBatch() shows the batch exists but Supabase is pending or denied, use Fix DB (PATCH only). No Supabase row → create/fix the row outside this PATCH.
Rows marked anchored in Supabase but missing from getAllBatchIds() are flagged (wrong contract, typo, or different deployment). Also verify RLS on reads.
Connect your wallet, then click Audit chain ↔ Supabase in the toolbar.