Build a stat sync transaction
const url = 'https://foxleague.ai/api/sync/prepare?wallet_address=example';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://foxleague.ai/api/sync/prepare?wallet_address=example' \ --header 'Authorization: Bearer <token>'Builds the transaction that writes your cards’ changed stats to chain, for all your cards with unsynced changes or for the one card in nonce. The transaction pays the sync fee (sync_cost_foxsy per card) and carries the cards with their signed new values to the players contract.
Sign it as a transaction from your wallet to your own address, with sc_call_data as data, value 0 and gas_limit. Wait wait_seconds before you sign. When it is final, send its hash and nonces to POST /api/sync/confirm. A card you have listed on the marketplace is left out: the marketplace holds it until the listing ends, so it cannot be synced. Cards your wallet no longer holds on chain are left out too.
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.Stat sync is temporarily disabled: the chain and the contract disagree about time. Your stats are safe and nothing was charged. Please try again later.: syncing is paused.This player is listed on the marketplace, which holds the card until the listing ends, so its stats cannot be synced. Cancel the listing to sync it.: the card innonceis listed on the marketplace.Player not found, not yours or has nothing to sync: the card innonceis not yours or has nothing to sync.Every player with changes to sync is listed on the marketplace, which holds the cards until the listings end. Nothing to sync. Cancel a listing to sync that player.: every card with changes is listed on the marketplace.No players have changes to sync: none of your cards has unsynced changes.The players with changes to sync are no longer in your wallet on chain (transferred, fused or burned). Nothing to sync. Try refreshing your team.: the cards with changes are no longer in your wallet.Sync is not available right now. Please try again later.: syncing is not available.Invalid wallet address.: the session’s wallet cannot be encoded.Signing service unavailable, try again: the new values could not be signed. Nothing was charged.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Query Parameters
Section titled “Query Parameters ”Your wallet address. It must be the session’s wallet.
Sync only this card, which must be yours and have unsynced changes. Omit it to sync every card with unsynced changes.
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
The total fee in FOXSY wei, as a decimal string. It is already in sc_call_data.
The FOXSY token identifier.
The gas limit to sign the transaction with.
The cards this sync covers. Send them to the confirm call.
How many cards this sync covers.
The players contract the call data pays and calls. The transaction itself goes from your wallet to your own address.
The transaction data to sign, as text.
Seconds to wait before signing, so a card that just arrived is settled on chain; 0 means sign now.
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": { "foxsy_cost": "20000000000000000000", "foxsy_token_id": "FOXSY-5d5f3e", "gas_limit": 21000000, "nonces": [ 1234, 1301 ], "player_count": 2, "receiver": "erd1qqqqqqqqqqqqqpgqfl593rtmy3p9s9wys8aq463gz082srtvnndjut3kps", "sc_call_data": "MultiESDTNFTTransfer@000000000000000005004f8a1c27b6d3e0951a2c8f7e6d4b3a2918c7f6e5d4c3@03@464f5853592d356435663365@00@01158e460913d00000@46584c502d366632386535@04d2@01@46584c502d366632386535@0515@01@73796e634d795374617473@0000000068dd4a3f@7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e7c1e@00000000000004d2@0a3d39392c3f42063b0000001ce4@0000000000000515@1b161e19181c1d04000000000d16", "wait_seconds": 0 }, "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