What is Blockbin?
Blockbin was built with exploration and curiosity in mind. Originally developed to satisfy a private curiosity with Bitcoin trends, Blockbin is now encouraging others to play with this wonderful experiment known as Bitcoin. Blockbin permits you to query the Bitcoin blockchain in-memory (SQLite) via Python.
The Bitcoin blockchain is public in nature. However, reading it is often computationally expensive and requires a specific skill set. Bitcoin is not magic, but rather the result of brilliantly applied computer science concepts. Blockbin is attempting to simplify the study of Bitcoin.
How does Blockbin work?
Your Python code snippets are submitted to Blockbin's servers and run server-side. Your code has access to most of the Bitcoin blockchain in SQLite format (see schema for more details). This database (approx 90GB) is cached entirely in memory. You have the ability to parse standard input (stdin) to your code. Standard output (stdout) is returned to your browser.
Blockbin uses ZeroVM for the server-side sandbox. ZeroVM uses Google's Native Client software fault isolation technology, which was originally built for the web browser. ZeroVM has adapted NaCl to permit safe execution of code on the server-end. This allows you to gain access to significant computing and memory resources from Blockbin's servers, and have your code very close to the blockchain database (compute and storage on same node).
The Bitcoin blockchain has a strict data schema. A relational database lends itself well to such a dataset and fits in well with ad-hoc queries. Relational databases perform well on trend analysis over large datasets. This may be of value to those interested in analysing the scalability and economics of the network.
Besides, everyone knows SQL!
What does it cost to use Blockbin?
Blockbin is free to use within a limited scope (free tier). Free tier code snippets are limited to 1 second of compute time, and 256MB of memory. One full processor core is reserved for your process during execution. This may not sound like a lot, however your code also has access to the in-memory Bitcoin blockchain in SQLite format. This read-only database (approx 90GB) is cached entirely in memory and resides on the same node in which your code runs. You can do a lot in 1 second! The performance of the Python virtual machine within the Blockbin sandbox may vary depending on the task.
Free tier code snippets are limited to 256KB outputs. There is also an upper limit on the number of queries you can freely run per minute.
Heavy users can opt to pay for increased resource privileges. Blockbin bills by the second in bitcoin of course! (5 bits per second at standard rate). Paying users gain access to 2048MB of memory, with code snippets permissible to run for up to 180 seconds.
Paid code snippets are limited to 10MB outputs.
The above limits may change at any time.
How are snippet outputs cached?
Blockbin will cache snippet outputs for paid tier (also free tier in some cases). Due to the deterministic properties of the server-side sandbox, outputs can sometimes be retrieved from an earlier computation. You will not be billed in this scenario. This generally occurs when you run the same snippet multiple times at the same block height. Newly generated outputs will overwrite any previously cached outputs. Parsing different input (stdin) will also affect the cached output. Output will not be cached if the output generated is disproportional to the time consumed. Under most circumstances these limits will not be a problem.
This is calculated as follows: permitted cached output (uncompressed) = 1MB x time (seconds) consumed.
Examples (paid tier):
* Note that paid tier is always permitted to generate and serve up to 10MB of output to your browser at run time, regardless of time consumed (even for 1 second), however the output will only be cached in the above scenarios
* Free tier (max 1 second) has a 256KB cache limit regardless
Cached outputs might not be stored indefinitely. Blockbin reserves the right to delete paid cached outputs after 30 days, or even sooner for free-tier outputs. In practice, however, cached outputs will likely be stored for much longer. Blockbin will endeavour to save cached outputs for as long as possible. This policy is subject to change at any time. This policy does not apply to the code snippet themselves.
It is recommended that you save your code snippet prior to executing a very long query (this would allow you to reload the snippet, e.g., if your browser timed-out, displaying the output once it completed, subject to above scenarios).
The above limits may change at any time.
Why is the block height delayed?
The available block height is delayed 4 - 8 hours. Blockbin takes a conservative approach towards database consistency. This delay will be reduced in the future.
Can I find Satoshi with Blockbin?
Probably not. Blockbin does not harvest meta data broadcast over the Bitcoin network or from other sources. All available data is sourced from one of the most interesting and transparent public dataset of recent times - the Bitcoin blockchain. The only additional piece of data included is historical bitcoin value (US dollar, in cents). This may be of value to those interested in the evolution and phenomenon of bitcoin price discovery.
A graph database may be more suitable for your task (analysis between nodes, or Bitcoin addresses). Such databases can become very large. You also often need to know what you are looking for prior to building your indexes.
Relationship analysis with Bitcoin often leads to false positives. Some researchers have famously fallen down this rabbit hole, resulting in wild (and often false) conclusions. Contrary to popular belief, consumption of unspent bitcoin outputs does not always equal ownership.
Such analysis is computationally expensive and may not be suited for SQL.
What are unlisted, public and private snippets?
Unlisted Blockbin snippets can be shared via URLs. People will only be made aware of unlisted snippets if you choose to disclose the URL.
Public snippets operate in the same manner as unlisted snippets, however you give permission to Blockbin to post the snippet on Blockbin's public gallery (should Blockbin choose to do so).
Private snippets can only be viewed by the original creator, and only when logged into the system. Saved private snippets cannot be accelerated by the caching proxy and therefore do not pass through the CDN. Blockbin uses a third-party CDN for some requested static content (GET requests, such as unlisted and public snippets).
Where is the Python random module? Why does os.urandom() fail?
The random module has been renamed to deterministic_random and is always repeatable given the default seed (time). Time within the server-side sandbox advances in a deterministic way and resets to Jan 1, 1970 for each code snippet. The sandbox is completely deterministic. The sandbox has no sources of entropy. Consequently, all pseudorandom number generators (including SystemRandom from deterministic_random) run within the sandbox are deterministic and repeatable unless you provide an external random seed every time you run your code, e.g., via deterministic_random.seed().
os.urandom() will fail as the urandom device is not available in the Blockbin sandbox.
deterministic_random may be useful in modelling and simulation scenarios. Use of any number generators are at your own risk. Blockbin should not be used for any security-sensitive work. Random number generation on any system you do not fully control should not be trusted.
How about NumPy?
My code snippet is running out of memory?
Be careful of using fetchall() with Blockbin. Remember that the Blockbin blockchain database is already cached in-memory and resides on the same node in which your code runs. Consider the following -
cur.execute("SELECT hash FROM block") for row in cur.fetchall():
cur.execute("SELECT hash FROM block") for row in cur:
The first will allocate memory for all rows, instead of reading one row at a time. Free tier snippets are limited to 256MB of memory (which also includes the POSIX-like environment). You may run out of memory depending on the size of your query. Using fetchall() may be of little benefit as the read-only blockchain database is already cached in memory. Consider reading one row at a time. You may experience little to no impact.
That all said, if you require more memory, consider upgrading to a paid account.