Skip to main content

PrizeApi

PoolTogether Prize API. Provides easy access to PoolTogether Prize APIs.

Table of contents

Constructors

Methods

Constructors

constructor

new PrizeApi()

Methods

checkPrizeApiStatus

Static checkPrizeApiStatus(chainId, prizeDistributorAddress, drawId): Promise<boolean>

Checks the status of a particular draw and returns true if the data is available for the requested draw.

Parameters

NameType
chainIdnumber
prizeDistributorAddressstring
drawIdnumber

Returns

Promise<boolean>

Defined in

src/PrizeApi.ts:294


computeDrawResults

Static computeDrawResults(chainId, usersAddress, prizeDistributorAddress, drawId): Promise<DrawResults>

Computes the users prizes locally. NOTE: This is a heavy calculation and not recommended on users devices.

Parameters

NameType
chainIdnumber
usersAddressstring
prizeDistributorAddressstring
drawIdnumber

Returns

Promise<DrawResults>

Defined in

src/PrizeApi.ts:190


computeDrawResultsOnCloudFlareWorker

Static computeDrawResultsOnCloudFlareWorker(chainId, usersAddress, prizeDistributorAddress, drawId): Promise<DrawResults>

Computes the users prizes in a CloudFlare worker.

Parameters

NameType
chainIdnumber
usersAddressstring
prizeDistributorAddressstring
drawIdnumber

Returns

Promise<DrawResults>

Defined in

src/PrizeApi.ts:163


getCloudFlareDrawResultsUrl

Static getCloudFlareDrawResultsUrl(chainId, prizeDistributorAddress, usersAddress, drawId): string

Returns the URL that the prizes can be calculated at on CloudFlare

Parameters

NameType
chainIdnumber
prizeDistributorAddressstring
usersAddressstring
drawIdnumber

Returns

string

Defined in

src/PrizeApi.ts:362


getDrawResultsFromPrizeApi

Static getDrawResultsFromPrizeApi(chainId, usersAddress, prizeDistributorAddress, drawId, maxPicksPerUser): Promise<DrawResults>

Fetches precomputed prizes from the Prize API. The Prize API only supports a limited set of networks, see https://dev.pooltogether.com/protocol/api/prize-api for more info.

Parameters

NameType
chainIdnumber
usersAddressstring
prizeDistributorAddressstring
drawIdnumber
maxPicksPerUsernumber

Returns

Promise<DrawResults>

Defined in

src/PrizeApi.ts:131


getDrawResultsStatusUrl

Static getDrawResultsStatusUrl(chainId, prizeDistributorAddress, drawId): string

Returns the URL for the status of the calculations for the draw requested from the Prize API

Parameters

NameType
chainIdnumber
prizeDistributorAddressstring
drawIdnumber

Returns

string

Defined in

src/PrizeApi.ts:346


getDrawResultsUrl

Static getDrawResultsUrl(chainId, prizeDistributorAddress, usersAddress, drawId): string

Returns the URL for pre-calculated prizes from the Prize API TODO: Fix the casing functions once Kames fixes the bug

Parameters

NameType
chainIdnumber
prizeDistributorAddressstring
usersAddressstring
drawIdnumber

Returns

string

Defined in

src/PrizeApi.ts:329


getUsersDrawResultsByDraw

Static getUsersDrawResultsByDraw(chainId, usersAddress, prizeDistributorAddress, drawId, maxPicksPerUser): Promise<DrawResults>

Fetches a users DrawResults for the provided draw id

Parameters

NameTypeDescription
chainIdnumberthe chain id the PrizeDistributor is deployed on
usersAddressstringthe address of the user to fetch draw results for
prizeDistributorAddressstringthe address of the PrizeDistributor to fetch prizes for
drawIdnumberthe id of the draw to check
maxPicksPerUsernumberthe maximum number of picks per user

Returns

Promise<DrawResults>

Defined in

src/PrizeApi.ts:38


getUsersDrawResultsByDraws

Static getUsersDrawResultsByDraws(chainId, usersAddress, prizeDistributorAddress, drawIds, maxPicksPerUserPerDraw): Promise<{ [drawId: number]: DrawResults; }>

Fetches a users DrawResults for the provided draw ids. Checks the status of the Prize API, falls back to the CloudFlare worker if Prize API status is invalid.

Parameters

NameTypeDescription
chainIdnumberthe chain id the PrizeDistributor is deployed on
usersAddressstringthe address of the user to fetch draw results for
prizeDistributorAddressstringthe address of the PrizeDistributor to fetch prizes for
drawIdsnumber[]a list of draw ids to check for prizes
maxPicksPerUserPerDrawnumber[]the maximum number of picks per user for each drwa

Returns

Promise<{ [drawId: number]: DrawResults; }>

Defined in

src/PrizeApi.ts:64