npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2026 โ€“ย Pkg Stats / Ryan Hefner

thru-coin-flip-cli

v1.0.3

Published

๐Ÿช™ A polished CLI for interacting with coin flip programs on the Thru blockchain

Readme

๐Ÿช™ Thru Coin Flip CLI

A polished command-line interface for interacting with coin flip programs on the Thru blockchain.

โœจ Features

  • ๐Ÿช™ Flip coins using blockchain entropy for randomness
  • ๐ŸŽฎ Interactive mode for easy coin flipping
  • โš™๏ธ Configuration for custom program IDs
  • ๐Ÿš€ Works instantly with pre-deployed program

๐Ÿ›  Setup

Prerequisites

  • Node.js 16+
  • Thru CLI installed and configured

Installation & Usage

# One-time use (no installation)
npx thru-coin-flip-cli@latest flip

# Interactive mode
npx thru-coin-flip-cli@latest interactive

# Or install globally
npm install -g thru-coin-flip-cli
coin-flip flip

๐Ÿ“‹ Commands

coin-flip check

Verify that thru-cli is installed and system is ready.

coin-flip flip [--program <programId>]

Execute a coin flip. Uses built-in default program or custom program ID.

coin-flip config [--show] [--set <programId>]

Manage default program ID configuration.

coin-flip interactive

Start interactive mode for easy coin flipping.

๐ŸŽฒ How It Works

The coin flip program uses blockchain entropy for randomness:

  1. Entropy Sources: Combines parent block hash, state root, block time, slot, transaction signature, and nonce
  2. SHA256 Hashing: Creates deterministic hash from multiple entropy sources
  3. Fair Result: Uses least significant bit for 50/50 probability
  4. Event Emission: Results are permanently recorded on-chain
  5. Verification: All entropy sources are publicly verifiable

๐Ÿ“ Project Structure

thru-programs/
โ”œโ”€โ”€ src/                    # TypeScript CLI source
โ”‚   โ”œโ”€โ”€ cli.ts             # Main CLI interface
โ”‚   โ”œโ”€โ”€ utils.ts           # Thru CLI wrapper utilities
โ”‚   โ””โ”€โ”€ types.ts           # TypeScript definitions
โ”œโ”€โ”€ coin_flip.c            # C program source
โ”œโ”€โ”€ coin_flip.h            # C program header
โ”œโ”€โ”€ GNUmakefile           # Tutorial-style makefile
โ”œโ”€โ”€ Local.mk              # SDK build configuration
โ””โ”€โ”€ build/                # Compiled artifacts
    โ””โ”€โ”€ thruvm/bin/       # Program binaries

๐Ÿ”ง Development

# Run in development mode
npm run dev

# Build TypeScript
npm run build

# Build C program
npm run build-program

# Clean all builds
npm run clean

๐Ÿ’ก Examples

Basic Usage

# Quick flip with default program
coin-flip flip

# Flip using specific program
coin-flip flip --program ta8xK9mNcP2wQ5...

# Interactive mode
coin-flip interactive

Configuration

# View current config
coin-flip config --show

# Set custom default program
coin-flip config --set ta8xK9mNcP2wQ5...

๐Ÿš€ Technical Details

  • Language: C program compiled to RISC-V bytecode
  • Blockchain: Thru testnet with zero-fee transactions
  • Randomness: Cryptographically secure blockchain entropy
  • CLI: TypeScript with Commander.js framework
  • Build System: Thru SDK makefile with proper linking

๐ŸŽฏ Result Format

๐ŸŽฒ COIN FLIP RESULT ๐ŸŽฒ
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
Result: HEADS
Slot: 756
Signature: tsJDG61YPxWfmKQj...
Compute Units: 44,445
Events: 1 emitted
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ›ก Randomness

The coin flip uses blockchain-based randomness:

  • Entropy comes from blockchain data (not user-controllable)
  • SHA256 ensures deterministic but unpredictable results
  • All data sources are publicly verifiable on-chain
  • Program logic is open source and auditable

๐Ÿ“ License

MIT - Feel free to use and modify for your projects.


Built with โค๏ธ for the Thru blockchain ecosystem