Track Parachain auction winners using Substrate API Sidecar
Useful tools that do useful things.
#
GoalFind the winner of a completed parachain auction using sidecar
.
#
Use casesInteract with a Substrate blockchain node using a REST service.
#
OverviewTo find the winner of a completed auction we will need to know the block number the auction ended at. Since Sidecar is a stateless API and the auction info is stored at the final block of an auction, once the auction is over we need the block number to make historic queries to retrieve the event and data stored in it (keep reading for details).
#
Steps/experimental/paras/auctions/current
endpoint#
1. Leverage the We will track and store finishEnd
, auctionIndex
, and leasePeriods
in a Database.
finishEnd
: This is the last block of the auction. Storing it allows you to query the block at which the auction ended. From that block you can extract the lease winning related events. (To query the block: GET /blocks/{finishEnd}.)
auctionIndex
: The unique identifier for the auction.
leasePeriods
: The available lease period indexes that may be bid on for the specific auctionIndex.
#
2. Using Sidecar to find the auction winnersBy storing the finishEnd
block and looking at the Leased
events within it, we can see who the auction winners are and what lease periods they were rewarded.
Format the data however is necessary, for example:
/blocks/:blockId
endpoint#
3. Query the This step queries all blocks at the block height specified in the finishEnd
field and retrieves all events inside of on_initialize
. An example response would be:
#
4. Compare your dataNow that you have all the paraIds
that won slots for that auction, you can compare it with the data relevant to the auctionIndex
.
Comparing the leasePeriods
that are available during the active auction to the leasePeriods
that have been won and denoted in the
Leased
events (there may be multiple if there are multiple winners) will give you all the winners for that auction.
#
Examples- More guides here.