Skip to main content

Client for Nakamoto's Dice — provably-fair Bitcoin Lightning coin flip / dice. MCP-discoverable, agent-friendly.

Project description

nakamoto-dice (Python)

pip install requests
from nakamoto_dice import NakamotoDiceClient
import uuid

client = NakamotoDiceClient(session_id=str(uuid.uuid4()))

# Create a game on heads, 5k stake
resp = client.create_game(stake_tier=5000, position="heads")
print(resp["invoice"])  # bolt11 — pay with your wallet of choice

# Wait for someone to join, then poll resolution
import time
while True:
    g = client.get_game(resp["game_id"])
    if g.status == "complete":
        print("result:", g.result)
        break
    time.sleep(3)

# Sweep winnings
balance = client.get_winnings()
if balance.get("max_withdrawable_sats", 0) > 0:
    # Generate a bolt11 from your wallet for that amount, then:
    client.withdraw_winnings("lnbc...")

See examples/play_one_flip.py for a complete worked example.

With an affiliate code

Pass referrer_code at create-time and you (the agent) earn 25% of the dice house cut on any games started under your code:

client.create_game(stake_tier=5000, position="heads", referrer_code=client.get_referral()["code"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nakamoto_dice-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nakamoto_dice-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file nakamoto_dice-0.1.0.tar.gz.

File metadata

  • Download URL: nakamoto_dice-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nakamoto_dice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2097edcdf6cd7f1274c1875c94059569ed2d325e336bc144fb405a8ae457fa72
MD5 ebfb4d4f369393d7eef266b79430408e
BLAKE2b-256 cd1b714a3d956cda27ca5be13ba88b6251ffcbb563599b80f541497855f3b820

See more details on using hashes here.

File details

Details for the file nakamoto_dice-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nakamoto_dice-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nakamoto_dice-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c5e3aaa35114092ceb36fbd684513b9130d02e772d9e73614b9baca4f7e6064
MD5 0e676c04fba1c5c70675a88fc52f11a8
BLAKE2b-256 71b3ca4e7e0e98729ef00f7ff8fb7f6d92573ac0f0569998016c30471d24b8b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page