<aside> 💡
Internal Services use API Keys, external (fetching Claymaker states) use Bearer
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"
}
}
}'
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"}
Create new tokens
curl -X POST \\
'<http://localhost:3000/api/creds>' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: ApiKey INTERNAL_API_KEY' \\
-d '{
"service": "some marketplace",
"description": "Some marketplace integration"
}'
Deactivated tokens
curl -X PATCH \\
'<http://localhost:3000/api/creds>' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: ApiKey INTERNAL_API_KEY' \\
-d '{
"id": "service_id",
"isActive": false
}'
Fetch all tokens
curl -X GET \\
'<http://localhost:3000/api/creds>' \\
-H 'Authorization: ApiKey INTERNAL_API_KEY'
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.
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.