Confirm a stat sync transaction
const url = 'https://foxleague.ai/api/sync/confirm';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"nonces":[1],"tx_hash":"example","wallet_address":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://foxleague.ai/api/sync/confirm \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "nonces": [ 1 ], "tx_hash": "example", "wallet_address": "example" }'Checks your sync transaction on chain and, when it succeeded, records the synced values of the listed cards. The server waits a short time for the transaction to become final. Confirming the same hash again answers success without changing anything.
Who: a signed-in player; wallet_address must be the session’s wallet.
Refusals:
Wallet address mismatch:wallet_addressis not the session’s wallet.The chain cannot be read right now. Please try again in a moment.: the chain cannot be read right now.Chain is temporarily unavailable. Please retry shortly.: the chain cannot be reached right now.Could not check your transaction on chain. Please try again in a moment.: the transaction could not be read.Transaction reverted on chain: <reason>: the contract rejected the sync.nonces list is required and cannot be empty:noncesis empty.Transaction sender does not match your wallet: the transaction was sent by another wallet.Transaction was not sent to the sync contract: the transaction was not sent to your own address.Transaction is not a stat-sync call to the game contract. Refresh your team and sync again. If your wallet was debited, contact support with this tx hash.: the transaction is not a sync built byGET /api/sync/prepare.Transaction paid <paid> but syncing <count> player(s) costs <expected> FOXSY. Refresh your team and sync again. If your wallet was debited, contact support with this tx hash.: the fee paid is lower than the sync of the listed cards costs;<paid>reads like20 FOXSY.Could not record the sync confirmation. Refresh and retry.: the confirmation could not be saved. Try again.Transaction still pending. Try again in a few seconds: the transaction is not final yet.Transaction failed: <reason>: the transaction failed on chain.Unexpected TX status: <status>: the chain reports an unknown status.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”The sync transaction to confirm.
object
The card nonces from the prepare answer.
The sync transaction hash: 64 hexadecimal characters.
Your wallet address. It must be the session’s wallet.
Example generated
{ "nonces": [ 1 ], "tx_hash": "example", "wallet_address": "example"}Responses
Section titled “ Responses ”Success or a refusal: read success (the refusals are in the description).
object
A machine-readable reason next to error, set only where the caller must act differently. tx_pending: the payment was not refused but could not be verified yet; keep the transaction hash and confirm again with the same hash, never pay twice.
The answer. Present when success is true.
object
true when the sync transaction is confirmed.
How many of the listed cards now have no unsynced changes.
Why the request was refused, in plain words. Present when success is false.
true when the request did what it asked. false is a refusal: read error.
Example
{ "data": { "confirmed": true, "players_synced": 2 }, "success": true}No valid session. The body is plain text: Missing Authorization header, Invalid Authorization format, Invalid session token or Session expired or invalid. Sign in again.
Example
Session expired or invalid