Try ALEX Bitcoin DeFi Now →
Blog
/
Main
ALEX Launchpad v1.1: How does the hybrid lottery system work?
March 17, 2022

The ALEX IDO, which launched on January 18th, 2022, was done through our Launchpad v1.0. It was an entirely on-chain lottery, meaning that each ticket had to be opened individually in a separate transaction. Every ticket claimed was a unique lottery event with required on-chain fees.

There was a combination of unforeseen factors that led to network congestion:

  1. Our IDO was 30 times oversubscribed which, combined with multiple tickets being claimed within a short amount of time, produced a high volume of network traffic.
  2. Mempool congestion however, was not simply due to IDO tickets being claimed. The Stacks 2.0 blockchain software was updated on Jan 18, the day of our launch, to release 2.05.0.1.0-rc2. With this latest release, the fix was “significantly increase the speed of most RPC endpoints.” Some miners however, had not yet upgraded their software. As a result, during the first days of our IDO, block utilization rate (current fullness vs. theoretical fullness) was only ~15%. Had the timing of the upgrade been different, overall throughput would have been 6–7x greater.

ALEX Launchpad v1.1

Having learned from the experience of our own IDO, we’ve redesigned the launchpad to provide a more streamlined experience by using a transparent hybrid on-chain/off-chain model. We’ll first provide a brief overview before going into technical details:

  • Only a single transaction, that is to validate the tickets, is required from users regardless of the number of tickets being validated. Validation can be done only once per wallet and requires submitting $ALEX as well as $APower. Only submit when you have come to a final decision on the number of tickets you wish to validate. After validation no further user action is needed.
  • By “on-chain” we mean the submission of validated tickets as well as the call contract that claims IDO tokens or refunds submitted $ALEX, will be done on-chain.
  • The off-chain portion is the lottery drawing itself; the ticket does not require a separate on-chain transaction. The lottery drawing will be transparent and verifiable as it will be based on the seed available from the latest block-height. This means the winners’ table will be verifiable by the community.

Take $BANANA LAUNCH AS AN EXAMPLE

Registration

At block-height 52,900, that is around March 20th, registration will open for the Bitcoin Monkeys IDO on our launchpad. Tickets (each eligible for 100 $BANANA) registered will require 33 $ALEX and numbers of $APower dependent on the number of tickets validated:

  • 1–5 Tickets = 10 $APower each
  • 6–15 Tickets = 50 $APower each
  • 16–35 Tickets = 100 $APower each
  • 36–50 Tickets = 150 $APower each

When a user registers, the contract generates and assigns to the user a block. The block height is proportional to the number of tickets registered and the starting position begins at the ending position of the previous block.

At the end of the registration period, we have a chain of blocks representing all the lottery tickets registered.

Each block is subdivided into a number of walk resolution. For example, if a user registered 5 tickets, his/her block will be a length of 5 walk resolutions.

Off-chain lottery system

At blockheight 53,950, that is around March 27, the registration closes and the lottery drawing will occur. The lottery system is based on a random number generator called “linear congruential generator”, which is one of the oldest and best-known pseudorandom number generator algorithms.

It starts by first drawing a verifiable random function seed (“seed”) from the Stacks block following the registration end. The seed is then

  1. multiplied by a constant (134775813),
  2. added to another constant (1), and, finally,
  3. the modulus of its outcome by another constant (4294967296) is calculated to serve as the next random number.

This random number is then scaled by the maximum step size, the ratio of the total number of registered tickets over the total number of tickets to be won (i.e. oversubscription ratio), multiplied by 1.5 times walk resolution.

This maximum step size helps ensure the fairness of the lottery system.

If a random number drawn falls between a particular walk resolution within a block that corresponds to a ticket held by a user, the ticket is determined to have won the lottery.

To generate the next random number, we move to the end of the walk resolution of the current random number, and draw another random number using the above linear congruential generator with the current random number as its seed.

The process is repeated until we reach the end of the chain, with the tickets upon whose corresponding walk resolution random numbers fell having won the lottery.

These “winners” are first determined off-chain, without the need for any on-chain events, thereby greatly increasing the overall efficiency of the lottery system.

On-chain verification

In order to ensure these “winners” are not tempered with or generated in error, upon submission of the list to process claim (whereby the “winners” receive the IDO tokens) and refund, the contract verifies independently that the list is correct using the same process outlined above, before triggering on-chain events (i.e. processing claims and refunds).

This hybrid on-chain/off-chain lottery system therefore allows ALEX Bitcoin DeFi to create a Launchpad that combines the efficiency/speed of off-chain processing, while maintaining verifiability/immutability of on-chain processing.

Related
See All