Bitcoin Computer

A Javascript smart contract library for Bitcoin

Simple Smart Contracts

Bitcoin Computer is a tool for maintaining the state of a Javascript object on the Bitcoin blockchain. It can be used to build smart contract applications like tokens on Bitcoin. As smart contracts are just Javascript classes it makes smart contract development as easy as web development. Bitcoin Computer also makes features such as object-identity, provenance, and cryptocurrency available in Javascript.

Efficient Execution

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

Secure and Economic

Bitcoin Computer works on BitcoinSV and Bitcoin Cash. Both coins have strong mining networks, low transaction fees, and vibrant communities. These chains make it possible to securely execute most smart contracts for as little as a tenth of a cent.

How it works

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 the cells of local memory whereas the latter is stored in unspent outputs of Bitcoin transactions.

A new smart object is created from a Javascript class and parameters to the 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 memory

A smart object can be updated by calling one of its functions. Such an update is recorded in a transaction that spends the unspent outputs storing the old state and creating new outputs that represent the new state. This is reminiscent of updating the cells of local memory. The difference is that the provenance of smart objects is preserved in an audit trail on the blockchain. This makes it possible to see every previous state of smart objects.

Summing up, a smart object is exactly like a normal object but it is stored on the blockchain. The advantages of being stored on the blockchain are:

  • The blockchain is a persistent storage device. The 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 a smart object is a persistent data structure that preserves all its previous states.

  • Bitcoin script provides fine-grained control over who may update which part of the blockchain. This makes it possible to guarantee that 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