Get the signed terms again to pay an authorized challenge
const url = 'https://foxleague.ai/api/tournaments/challenges/1/authorization';const options = {method: 'POST', 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 POST \ --url https://foxleague.ai/api/tournaments/challenges/1/authorization \ --header 'Authorization: Bearer <token>'“Pay now” for a challenge or tournament you authorized and have not paid yet. While a wallet can still meet its expiry, it answers the SAME signed terms POST /api/tournaments/challenges/authorize answered for it, with the seconds left in expires_in_seconds: build the createAndJoin transaction from them exactly as answered, pay, then call POST /api/tournaments/challenges/{id}/confirm. Nothing is signed or written by this call.
When it is already paid and open (or moved on in any other way), the answer has its state (open, cancelled, …) and its tournament_id, with nothing to sign: read the challenge again. Once a wallet can no longer meet the expiry, the chain is read first, as POST /api/tournaments/challenges/{id}/confirm without a hash reads it: a payment of yours that landed opens it: the answer is then open.
Who: the player who authorized it. Anyone else is answered Tournament not found.
Refusals:
The time to pay this challenge has run out. Unless a payment of yours lands, nothing is charged and it is removed on its own within about <minutes> minutes. A payment that lands opens it instead. You can create a new challenge now.(orin <N>s;tournamentfor a tournament), withcodechallenge_payment_window_closed: a wallet can no longer meet the expiry and the chain holds no payment of yours. The minutes follow the check that removes an unpaid one: two clean reads of the chain, one interval apart.The chain could not be read; nothing was charged twice. Please retry in a moment.: once the time to pay has run out the chain is read first: it could not be read.Tournament not found: no authorized challenge or tournament of yours has this id.The one-signature challenge flow is not available right now. Create the challenge the usual way./The one-signature flow is not available for tournaments right now. Create the tournament the usual way.: the flow is switched off. Asked only while it can still be paid; the chain is read first, so a payment of yours that landed is answeredopeninstead.Challenges are paused on chain right now. Nothing was charged; please try again later./Paid tournaments are paused on chain right now. Nothing was charged; please try again later.: the tournaments contract is paused. Asked the same way: only while it can still be paid, after the chain read.Chain is temporarily unavailable. Please retry shortly.: the server cannot reach the chain right now.The chain clock could not be read. Please retry in a moment.: the expiry is chain time and the chain time could not be read.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The challenge id answered by the authorize call.
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 allowed wallets, in the exact order to send them: you first, then the challenged player for a targeted challenge. For a tournament: none when it is public, you and your invited teams (in account order) when it is private.
The exact amount the transaction must carry, in FOXSY atomic units, as a decimal string.
The entry fee in whole FOXSY.
Seconds left on expiry at the time of this answer, by chain time. In a pending refusal: the seconds to wait before a different challenge or tournament can start.
Chain time in seconds up to and including which the contract accepts the signature.
The FOXSY token to pay with.
The gas limit to send the transaction with. One figure for a challenge; for a tournament it grows with the allowed wallets.
The seat cap to send: 2 for a challenge, the tournament’s max_teams for a tournament.
The tournaments contract to send the transaction to.
The server’s 64-byte signature of the terms, as hexadecimal.
authorized: sign and pay with the fields below. pending (inside a refusal with code challenge_authorization_pending): a previous authorization of yours can still land; tournament_id is that challenge or tournament and expires_in_seconds the seconds to wait before a different one can start. Any other value is the status of a previous challenge or tournament of yours that turned out paid (open): nothing to sign, go to tournament_id.
The id of the challenge or tournament: the first argument of the transaction and the id to confirm.
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
{ "success": true, "data": { "state": "authorized", "tournament_id": 1908, "entry_fee_atomic": "1000000000000000000000", "entry_fee_foxsy": 1000, "max_entries": 2, "allowed_wallets": [ "erd1creator000000000000000000000000000000000000000000000000000", "erd1target0000000000000000000000000000000000000000000000000000" ], "expiry": 1792300600, "signature_hex": "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab", "sc_address": "erd1qqqqqqqqqqqqqpgqfw3nadv3z7hj6c2x7alndtw03y5ang43utesz8nmg9", "foxsy_token_id": "FOXSY-abc123", "gas_limit": 15200000, "expires_in_seconds": 412 }}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.
The answer of a request that returns no data. POST /api/tournaments/{id}/delete answers its refusals with it: success is false and error says why.
object
A machine-readable reason next to error, set only where the caller must act differently.
Always null on success: the route returns no data.
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 generated
{ "code": "example", "data": "example", "error": "example", "success": true}