<aside> 💡

API

Internal Services use API Keys, external (fetching Claymaker states) use Bearer

Check Claymaker state

This Api will be used by external services, therefore it uses the Bearer token

curl -X POST \\
  <http://localhost:3000/api/claymaker/metadata> \\
  -H 'Authorization: Bearer BEARER_TOKEN' \\
  -H 'Content-Type: application/json' \\
  -d '{
    "data": {
      "game": "clayno-class-selection",
      "action": "clayno-clay-maker-details",
      "data": {
        "claymakerMint": "4RkBcNmYyLcjBWLgWJNHVxJjq3vv8Er9YNahdr9uzXk5"
      }
    }
  }'

Check for characters with failed class selection

If the class selection fails, you probably don't want to let the user do an upgrade again because the cron job will retry. You can check for mints that did the class selection but ran into error with this api call:

curl -X POST \\
  '<http://localhost:3000/api/character/check>' \\
  -H 'Content-Type: application/json' \\
  -H 'Authorization: ApiKey INTERNAL_API_KEY' \\
  -d '{
    "data": {
      "game": "clayno-class-selection",
      "action": "CHECK_CLASS_SELECTION",
      "data": {
        "claynoMint": "mnQZgdtYzZsRPAT2v7YL5X83WVcsa1VveTR2JoFf6nu"
      }
    }
  }'
  
  // Returns: {"hasFailedSelection":true,"selectedClass":"Tracker","state":"METADATA_UPLOAD_FAILED"}

Bearer tokens for external services

Cron Job

Add this to vercel.json - it will run every two minutes

{
  "crons": [{
    "path": "/api/cron/retry-class-selection",
    "schedule": "*/2 * * * *"
  }]
}

You can test your cron expression here: https://vercel.com/docs/cron-jobs#validate-cron-expressions

Vercel will add the environment variable CRON_SECRET to all cron job invocations as part of the Authorization header, allowing you to specify any value you'd like for authorization.

Solana Program

The Program only burns clays and updates or burns claymakers. The class slection itself is handled with an extra txn using UMI. That's why we added the db for tracking - since it's another txn that follows after the burn, it is not atomic.