Bitcoin Computer

A Javascript smart contract library for Bitcoin

Javascript Smart Contracts on Bitcoin

The Bitcoin Computer is a Turing complete layer-1 smart contract system for Bitcoin. It enables NFTs, fungible tokens, auctions, exchange, stable coins, chat, games, business applications, social networks on Bitcoin.

Simplified Application Development

Smart contract development on the Bitcoin Computer is (almost) as easy as web development because smart contracts can be written in Javascript and Typescript. Javascript objects can be stored on the blockchain instead of in a database so that applications can be developed without a backend. Most importantly, multiple users can interact with the same object which enables smart contracts secured by the byzantine fault tolerant consensus of Bitcoin.

Secure and Efficient Execution

Smart contracts on the Bitcoin Computer are evaluated by users as opposed to miners. Both techniques are equally secure but there is a big difference in cost: miner validated smart contracts are charged per computational step whereas user validated smart contracts are charged by the size of the parameters in the constructor and function calls. This is much cheaper and makes it possible to run compute-intensive smart contracts on Bitcoin.

Freedom and Flexibility

Bitcoin Computer works on Bitcoin Cash and BitcoinSV and we are working on supporting more blockchains.

How it works

The Bitcoin Computer is a Javascript Bitcoin wallet that can generate special Javascript objects called smart objects. The difference between a normal object and a smart object is that the former is stored in local memory whereas the latter is stored the Bitcoin blockchain.

The Bitcoin Computer library can create a new smart object from a Javascript class and parameters to its constructor. The creation of a smart object is recorded in unspent outputs on the blockchain. Each unspent output created corresponds to a cell that is allocated when the same object is created in local memory

A smart object can be updated by calling one of its functions. Updates are recorded in transactions that spend the outputs representing the old state and create outputs that represent the new state. This is reminiscent of updating the cells of local memory. The difference is that the history of a smart object is preserved in an audit trail on the blockchain. This makes it possible to see every previous state of a smart object.

The advantages of storing Javascript objects on the blockchain are:

  • Blockchains are persistent storage devices. Objects created on the blockchain remain available after the computation terminates. This makes it easy to build serverless applications.

  • Bitcoin provides strong consensus. This allows multiple users to sync to the same smart object. If a user updates a smart object then the change propagates to all other synced users within a few seconds.

  • Unlike databases, blockchains are immutable. This does not mean that data cannot be updated, to the contrary, it means that smart objects are persistent data structures that preserve all previous states.

  • Bitcoin script provides fine-grained control over who may update which part of the blockchain. This introduces a natural notion of data ownership where only a distinguished user, called the owner, can update a smart object. The owner is not fixed and a new owner can be assigned when a smart object is updated.

  • Blockchains can store money in addition to data. Thus every smart object can store an amount of satoshi that are kept just as secure as the cryptocurrency in your Bitcoin wallet.

Download from NPM