On-chain Taiwan Receipt Lottery: auto rewards, transparent draws, no more missed claims.
Stapal transforms Taiwan’s decades-old Uniform Invoice Lottery — one of the world’s most successful civic financial systems — into a fully automated, transparent, and borderless on-chain version.
In Taiwan, every government-issued sales receipt carries a unique 8-digit number. Every two months, the Ministry of Finance publicly draws winning numbers, and citizens whose receipts match can win between NT$200 and NT$10 million. The system’s core purpose is to combat tax evasion and promote transaction transparency by encouraging consumers to always request official receipts.
Stapal replicates this system exactly as it works today, but with two key blockchain-driven improvements:
Instant PYUSD Payouts: Users pay approved merchants using PYUSD. Each transaction automatically generates a receipt entry tied to their wallet. When the official draw occurs, prizes are automatically converted from TWD to PYUSD and distributed instantly on-chain — solving the real-world pain point where users forget to claim winnings or miss deadlines.
Provable Fairness and Price Transparency: Stapal uses Pyth Entropy to generate a verifiable random draw, ensuring fairness without any centralized control. The Pyth USD/TWD pull price feed dynamically converts prize amounts (denominated in TWD per Taiwan’s official rules) into the equivalent PYUSD value, allowing prize distribution to remain stable and pegged to real-world currency.
Stapal demonstrates how PYUSD can power real-world, large-scale payment experiences beyond Web3 — modernizing proven public systems with programmable transparency.
In short, Stapal doesn’t reinvent the wheel — it puts a proven wheel on rails, combining the trust of a national system with the efficiency and global reach of PYUSD payments.
Stapal is the most faithful real-world replication of a proven national finance system ever brought on-chain. It demonstrates how PYUSD and Pyth together can create an autonomous, transparent, and programmable payments network — bridging fiat systems and Web3 infrastructure at national scale.
It’s not a new idea. It’s the right idea, made real with PYUSD precision and Pyth truth.
Architecture Overview: Stapal is built entirely on smart contracts deployed on Arbitrum Sepolia, integrating PYUSD, Pyth Entropy, and Pyth Pull Price Feeds.
Stapal.sol — the main contract managing merchants, receipts, and prize draws:
buy(sender, receiver, amount): Processes PYUSD payments from buyers to approved merchants and stores receipt data (address + pseudo-random 8-digit number).requestRandomNumber(): Requests entropy from Pyth Entropy to generate verifiable randomness for each draw.entropyCallback(...): Receives callback with the random value and stores the current 8-digit winning seed (currentVrf).drawWinners(): Derives the 4–7 digit winning patterns from currentVrf and maps them to stored receipts to determine eligible winners.updatePriceAndDistribute(bytes[] priceUpdate): Fetches the latest Pyth USD/TWD price from Hermes, converts each TWD prize tier into its PYUSD equivalent, and sends rewards directly to winning wallets.MockPYUSD.sol — minimal ERC20 token for local testing and demonstration.
Prize Rules Implemented (1:1 official structure):
All prizes are converted to PYUSD based on the latest Pyth USD/TWD exchange rate, ensuring accuracy and real-world parity.
Frontend: A minimal Next.js interface where users can:
Backend (API Route):
/api/draw: Executes a full draw sequence:
drawWinners() and updatePriceAndDistribute() after pulling FX data.Contracts Deployed:
Stapal: 0x6e6ba8c9960b6B94dFDafB3EB31D4BC7398e34A5MockPYUSD: 0x6bfC592fB6779BE62346C76347f8aed209D28346| Technology | Purpose | Benefit | | ---------------------------------- | ---------------------------- | ------------------------------------------------------------------------------- | | PYUSD | Medium of payment and payout | Real, stable, and composable digital dollar for programmable civic rewards | | Pyth Entropy | Random draw generation | Fully decentralized, verifiable randomness replacing centralized draw officials | | Pyth Pull Price Feed (USD/TWD) | FX conversion | Real-time on-chain conversion from TWD prizes to PYUSD |

