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 heightcoinblocks_destroyed(height)— sum ofinput.value × lifespanfor all inputscoinblocks_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 priceget_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boxtime-1.0.0.tar.gz.
File metadata
- Download URL: boxtime-1.0.0.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
173917f6892f4e7ff56f333c46226a4994c4a369433647641fbcbc921ee047a2
|
|
| MD5 |
5a6e1f6037d8df2dd662e5f57ef6925f
|
|
| BLAKE2b-256 |
444e96285e912ead30e6db7e9ab424f972525ec7e99044bcaff9de6a6a0edc77
|
File details
Details for the file boxtime-1.0.0-py3-none-any.whl.
File metadata
- Download URL: boxtime-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31216eed9331d4b97c175ba16bc3b009c1b2dbf0eae123f849ebbb9a1b4a325
|
|
| MD5 |
44b0cdb35bc9173f2dda96461fd0a566
|
|
| BLAKE2b-256 |
8991bda0f8d225468ca4b615c9742c49177b3e24fb0b08baf75534cea4754119
|