The fix changes getCurrentLeader() to call getCurrentLeaders():
- Old: Called non-existent
getCurrentLeaderfunction - New: Calls
getCurrentLeadersand returns first leader
# Check that getCurrentLeaders exists in the ABI
grep -A 10 "getCurrentLeaders" lib/abi/TheSeeds.jsonExpected output should show:
"name": "getCurrentLeaders",
"outputs": [
{
"internalType": "uint256[]",
"name": "leadingSeedIds",
"type": "uint256[]"
},
{
"internalType": "uint256",
"name": "score",
"type": "uint256"
}
]# Verify the contract source has getCurrentLeaders
grep -n "function getCurrentLeaders" contracts/TheSeeds.solExpected: Line 584 or similar showing the function exists
# TypeScript compilation
npm run build
# Deploy to Vercel
git add .
git commit -m "fix: update select-winner API for new Seeds contract"
git push origin main
# Or manual deploy
vercel --prodcurl -X GET "https://your-api.vercel.app/api/admin/winner-diagnostics" \
-H "X-Admin-Key: YOUR_ADMIN_KEY" \
| jq .Expected Response:
{
"success": true,
"ready": false,
"diagnostics": {
"currentRound": 1,
"seedsInRound": 5,
"timeRemaining": 3600,
"currentLeader": {
"seedId": 123,
"score": "1414213",
"blessings": "2"
}
}
}If this works, getCurrentLeader() is working!
curl -X POST "https://your-api.vercel.app/api/admin/select-winner" \
-H "X-Admin-Key: YOUR_ADMIN_KEY" \
| jq .Expected Success Response:
{
"success": true,
"data": {
"winningSeedId": 123,
"round": 1,
"txHash": "0x...",
"blockExplorer": "https://basescan.org/tx/0x...",
"seed": {
"id": 123,
"creator": "0x...",
"ipfsHash": "Qm...",
"blessings": 5,
"isWinner": true,
"winnerInRound": 1
},
"nft": {
"tokenId": 1,
"tokenURI": "ipfs://Qm...",
"openseaUrl": "https://opensea.io/assets/base/0x.../1",
"contractAddress": "0x..."
},
"message": "Winner selected successfully. New blessing period started."
}
}vercel logs --prodLook for:
- ✅ No errors about "getCurrentLeader not found"
- ✅ Successful winner selection
- ✅ NFT data logged to console
Check on blockchain explorer:
# Get the contract address from response
CONTRACT_ADDRESS="0xaea1cfd09da8f226a2ff2590d6b748563cf517f0"
# View on BaseScan
open "https://basescan.org/address/${CONTRACT_ADDRESS}#readContract"
# Or Base Sepolia
open "https://sepolia.basescan.org/address/${CONTRACT_ADDRESS}#readContract"Call getTokenIdBySeedId(winningSeedId) to verify NFT was minted.
The API response includes an openseaUrl. Visit it to see the minted NFT:
# From the response
open "https://opensea.io/assets/base/CONTRACT_ADDRESS/TOKEN_ID"- ❌ Fix not deployed yet
- ❌ Using old cached version
- ✅ Clear browser cache / hard refresh
- ✅ Check you're hitting the prod deployment
- ✅ This is expected! Wait for the voting period to end
- ✅ Or check
winner-diagnosticsto see time remaining
- ✅ This means no seeds have blessings with score > 0
- ✅ Check
winner-diagnosticsto see current leader
- Check if the contract actually minted the NFT
- Call
getTokenIdBySeedId()directly on the contract - Verify the seed
isWinner = true
When everything works correctly, you should see:
- ✅
/api/admin/winner-diagnosticsreturns valid leader info - ✅
/api/admin/select-winnersuccessfully completes - ✅ Response includes
nftobject with tokenId, tokenURI, and OpenSea link - ✅ Transaction appears on block explorer
- ✅ NFT appears in contract on BaseScan
- ✅ NFT eventually appears on OpenSea (may take a few minutes)
- ✅ Daily cron job succeeds without errors
Run this one-liner to test if the fix is deployed:
# Test diagnostics endpoint
curl -s "https://your-api.vercel.app/api/admin/winner-diagnostics" \
-H "X-Admin-Key: YOUR_KEY" \
| jq -r '.diagnostics.currentLeader.seedId' && echo "✅ Fix is working!"If you get a seed ID number, the fix is working! If you get an error, check the logs.