Tournament

API endpoints for creating and managing tournaments for Forge Digital Ventures

Tournament Creation

Endpoint: POST /tournaments

Creates a new tournament with the specified configuration parameters.

Request Parameters:

  • name (string): Tournament display name

  • adminAddress (string): Address with administrative control

  • changeAddress (string, optional): Address to receive change UTXOs (defaults to adminAddress)

  • bracketSize (number): Number of participants in the tournament

  • entryFee (string|number|bigint, optional): Fee for participants (in lovelace)

  • payoutStructure (string[]|number[]|bigint[]): Array defining prize distribution (in lovelace)

    circle-exclamation
  • fixedPayouts ([string, string|number|bigint][], optional): Optional specific reward allocations to addresses

  • utxos (string[], min 1): Array of UTXO strings to use for the transaction

  • contractTitle (string, optional): Contract title for custom deployments

  • contractVersion (string, optional): Contract version for custom deployments

Response:

  • complete: Hex-encoded transaction for signing

circle-info

The returned transaction must be signed and submitted through the /tournaments/submit-tx endpoint before it takes effect on the blockchain.

Technical Notes:

  • The tournament ID is derived from the first UTXO in the transaction

  • An NFT is minted representing the tournament

  • The tournament datum contains both configuration and current state

Example (Node.js with fetch):

Adding Participants to Tournament

Endpoint: POST /tournaments/{tournamentId}/participants

Enables tournament administrators to collect valid registrations and officially add participants to the tournament.

Request Parameters:

  • adminAddress (string): Tournament administrator address

  • tournamentId (string): Tournament identifier

  • changeAddress (string, optional): Address to receive change UTXOs (defaults to adminAddress)

  • registrations (object[], min 1): Array of registration objects, each containing:

    • address (string): Participant address

    • outputRef (string): Registration UTXO reference in format txHash#index

  • utxos (string[], min 1): Array of UTXO strings to use for the transaction

  • contractTitle (string, optional): Contract title for custom deployments

  • contractVersion (string, optional): Contract version for custom deployments

Response:

  • complete: Hex-encoded transaction for signing

circle-info

The returned transaction must be signed and submitted through the /tournaments/submit-tx endpoint before it takes effect on the blockchain.

Technical Notes:

  • Only the tournament admin can add registered participants to the tournament

  • Multiple participants can be added in a single transaction

  • The transaction updates the tournament datum with new participants

  • Registration UTXOs are consumed in the process

Example (Node.js with fetch):

Retrieving Tournaments

Endpoint: GET /tournaments

Returns a list of all available tournaments.

Request Parameters:

  • limit (number, optional): Number of tournaments to retrieve (default: 100, max: 100)

  • pageState (string, optional): Pagination token for fetching additional results

  • cursor (string, optional): Alias for pageState, enables TRPC infinite queries

  • contractTitle (string, optional): Contract title for custom deployments

  • contractVersion (string, optional): Contract version for custom deployments

Response:

  • results: Array of tournament objects with their configuration and state

  • pageState: Optional pagination token for fetching the next page of results

Technical Notes:

  • Results are paginated with a default limit of 100 tournaments

  • The response includes both tournament configuration and current state

  • Tournament information is retrieved from the on-chain NFT records

  • Invalid registrations may be added to a tournament, but any missing fees will be covered by the tournament administrator when confirming the registration

Example (Node.js with fetch):

Tournament Settlement

Endpoint: PATCH /tournaments/{tournamentId}/settle

Completes a tournament by distributing prizes according to the specified results.

Request Parameters:

  • adminAddress (string): Administrator address (must match tournament creator)

  • changeAddress (string, optional): Address to receive change UTXOs (defaults to adminAddress)

  • tournamentId (string): Tournament identifier

  • results (string[]): Array of participant addresses in order of their placement (1st place first, 2nd place second, etc.)

circle-info

This results list doesn't have to be exhaustive, but at least all winning participants (configured in the original payoutStructure) must be specified.

  • utxos (string[], min 1): Array of UTXO strings to use for the transaction

  • contractTitle (string, optional): Contract title for custom deployments

  • contractVersion (string, optional): Contract version for custom deployments

Response:

  • complete: Hex-encoded transaction for signing

circle-info

The returned transaction must be signed and submitted through the /tournaments/submit-tx endpoint before it takes effect on the blockchain.

Technical Notes:

  • Only the tournament admin can settle a tournament

  • Tournament must be fully filled (all participant slots must be occupied)

  • Prizes are distributed according to the tournament's payout structure

  • The tournament NFT is burned during settlement

  • Prize UTXOs include tournament ID as a unique tag in the datum to implement the unique outputs patternarrow-up-right, preventing double-satisfaction vulnerabilities

Example (Node.js with fetch):

Last updated

Was this helpful?