Skip to main content

Cointime economics framework implementation for the Ergo blockchain.

Project description

boxtime

Cointime economics framework implementation for the Ergo blockchain.

Description

Boxtime is a Python library that implements the Cointime Economics framework for Ergo. It connects to an Ergo node to compute coinblocks created, destroyed, and stored — and optionally enriches the data with ERG/USD prices from CoinGecko for plotting and analysis.

Installation

pip install boxtime

Prerequisites

  • Ergo Node — a running node with the extra blockchain indexer enabled (ergo.node.extraIndex = true).
  • CoinGecko API key (optional) — a free Demo API key from coingecko.com/en/api. Required only for price-related methods.

Quickstart

Basic cointime metrics

from boxtime import Cointime

ct = Cointime(node_url="http://127.0.0.1:9053")

# Coinblocks created at a single height (= circulating supply in nanoERGs)
cbc = ct.coinblocks_created(500_000)

# Coinblocks destroyed at a single height
cbd = ct.coinblocks_destroyed(500_000)

# Coinblocks stored (CBC - CBD)
cbs = ct.coinblocks_stored(500_000)

# Totals over a range
total_cbc = ct.total_coinblocks_created(500_000, 500_100)

Price-enriched data (for plotting)

Pass a CoinGecko API key to unlock price methods:

ct = Cointime(
    node_url="http://127.0.0.1:9053",
    coingecko_api_key="CG-your-demo-key",
)

# Current ERG/USD spot price
price = ct.get_price()

# Price history between two block heights
history = ct.get_price_history(500_000, 510_000)

# Coinblocks created with matched price data — ready to plot
data_points = ct.get_coinblocks_created(500_000, 510_000)
for dp in data_points:
    print(dp.height, dp.timestamp, dp.value, dp.price)

Each CointimeDataPoint bundles height, timestamp, value (cointime metric in nanoERG-blocks), and price (ERG/USD). Only block timestamps that exactly match a CoinGecko price timestamp are included.

API Overview

Cointime — main entry point

Primitive metrics (single height):

  • coinblocks_created(height) — circulating supply at height
  • coinblocks_destroyed(height) — sum of input.value × lifespan for all inputs
  • coinblocks_stored(height) — CBC − CBD

Aggregate metrics (height range, inclusive):

  • total_coinblocks_created(start_height, end_height)
  • total_coinblocks_destroyed(start_height, end_height)
  • total_coinblocks_stored(start_height, end_height)

Price methods (require CoinGecko API key):

  • get_price() — current ERG/USD spot price
  • get_price_history(start_height, end_height)List[PricePoint]

Convenience methods (require CoinGecko API key):

  • get_coinblocks_created(start_height, end_height)List[CointimeDataPoint]
  • get_coinblocks_destroyed(start_height, end_height)List[CointimeDataPoint]
  • get_coinblocks_stored(start_height, end_height)List[CointimeDataPoint]

Underlying clients

For advanced use, the individual clients are also exported:

  • ErgoNodeClient(node_url, api_key) — Ergo node REST API (transactions, boxes, blocks, emission, balances)
  • CoinGeckoClient(api_key) — CoinGecko price data (current price, history, history by date)
from boxtime import ErgoNodeClient

node = ErgoNodeClient("http://127.0.0.1:9053")
info = node.get_node_info()
tx = node.get_transaction("tx_id_here")

License

This project is licensed under the MIT License.

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

boxtime-0.1.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

boxtime-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for boxtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2edcf23ee41b73224e69259d86202571fc61c8c976a716e4961a1bf60fd9f9e5
MD5 75a2fc08f9af64ed1c48131952ca49ed
BLAKE2b-256 933a56013a4a4905749e37e7e33a4c7d3f4d82afd9ea6457b573e5cbba27f795

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for boxtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f4cec120d6afa852b2986d0282545af2ab20246ab9a8c4df1ba876236e1bbf0
MD5 63842f8ef3a6cd729a78f7f026b7ae70
BLAKE2b-256 c81d61eb685ae80fc13215b873d22baadf076f09cf8d44bc1dda3b7254905c7c

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