Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions packages/docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ icon: light-bulb

## Intuition

A Bitcoin Computer transaction is a Bitcoin transaction with a Javascript expression inscribed. The value of the expression is associated with the first output of the transaction. If the value is an object or array that has sub-objects, then each sub-object is associated with a distinct output of the transaction.
In a Bitcoin Computer transaction, a JavaScript expression is embedded within a standard Bitcoin transaction. The result of evaluating this expression is linked to an output. If the result contains objects, each of these objects is assigned to a separate output.

If the expression contains a free variable (for example the variable `x` is free in the expression `x + 1`), then that free variable has to be associated with an input of the transaction. To determine the values of the outputs, the Bitcoin Computer recursively determines the values of each output spent. The free variable is then substituted with the value before the expression is evaluated.
For expressions with an undefined variable (for example, the variable `x` is undefined in the expression `x + 1`), the smart contract developer can associate that variables with an input of the transaction. The Bitcoin Computer then recursively calculates the values of these outputs, and replaces the undefined variables with their computed values from previous transactions to evaluate the expression.

### Basic Example

![](/static/legend@1x.png)-
In the examples below, white boxes represent transactions and grey boxes represent expressions inscribed. Inputs and outputs are displayed as circles and spending relations are shown as arrows.
<div style="clear: right;"></div>


-![](/static/int-example@1x.png)
Consider a transaction with the expression `1+2` inscribed. As this expression evaluates to `3`, the Bitcoin Computer will associate the first output with the value `3`.

If this output is spent by a transaction with an inscription `x+4` and the first input is associated with `x`, the Bitcoin Computer determines the value of the output spent by that input. In the example that output has the value `3`. Hence, the output of the second transaction has the value `7`.
In this example, the transaction is inscribed with the arithmetic expression `1+2`, which evaluates to `3`. This value is then associated with the transaction’s first output. In a subsequent transaction, an expression `x+4` uses this output's value as its variable `x`. Given that the output from the first transaction was `3`, the expression in the second transaction evaluates to `7`, and this new value is assigned to its output. This demonstrates how values can be propagated and transformed across transactions in the Bitcoin Computer system.

<div style="clear: left;"></div>

## Detailed Description
Expand All @@ -29,23 +28,25 @@ If this output is spent by a transaction with an inscription `x+4` and the first

We will refer to a Javascript expression that is inscribed in a transaction as a *smart contract*. The value that such an expression evaluates to is called a *smart value*. If a smart value is of object type we refer to it as a *smart object*.

### Data Ownership
In the Bitcoin Computer system, JavaScript expressions embedded within transactions are called smart contracts. The values of these expressions is known as a smart values. When a smart value is of an object type, it is referred to as a smart object. This terminology is borrowed from object oriented programming and helps distinguish between a class and the objects created from such a class.

The method of associating data values to outputs described above gives rise to a natural notion of data ownership: A smart value that is *owned* by the users that can spend that output. This is analogous to how satoshis in an output are owned by the users that can spend the output.
### Data Ownership

The Bitcoin Computer adds a property `_owners` to every smart object. It is set to the array of the public keys of the owners. Conversely, if an object is created with a property `_owners` that is set to an array of *n* string encoded public keys, then the output that represents the object has a *1*-of-*n* multisig script with these public keys.
In the TBC system, data ownership is linked to the ability to spend an output, similar to the ownership of Bitcoin. A “smart object embedded in a transaction is the property of the user(s) who can spend that output. For enhanced security and ownership clarity, every “smart object” includes an `_owners` property, listing the public keys of its owners. Conversely, if an object is created with a property `_owners` that is set to an array of $n$ string encoded public keys, then the output that represents the object has a $1$-of-$n$ multisig script with these public keys.

### Creating Objects and Object Identity

One advantage of associating values with transaction outputs is that the transaction id and output number can be used as an *identity* for the object. Whenever a smart object is created the Bitcoin Computer assigns the identity to a property `_id` of the object. The object identity cannot be reassigned and remains fixed throughout the lifetime of the object.
Associating values with transaction outputs facilitates the use of the transaction ID and output number as a unique identifier for each smart object. This identifier is assigned to the _id property of the smart object upon its creation and remains unchanged for the object’s entire lifespan.

### Updating Objects and Object Revisions

Whenever a smart object is updated a transaction is broadcast that spends the outputs representing the object's old state. The outputs of the transaction are associated with the new state of the object. The transaction id and output number that is associated with the new state of an object is referred to as it's *revision*. The revision is assigned to a property `_rev` of the object.
When a smart object is updated, a transaction is broadcast that spends the old state’s utxo with new one, reflecting the object’s updated state. This transaction ID and output number are designated as the object’s revision and stored in the `_rev` property of the object. This mechanism ensures that each update is traceable and securely linked to the specific transaction.

### Ancestors and Roots of Objects

If an object is created in a function call of the form `x.f(...)` we say that `x` is its parent. We say that an object `x1` is the ancestor of an object `xn` if there is a sequence of objects `z2 ... zn-1` such that `xi` is the parent of `xi_1` for all `i`. The *root* of an object is its (unique) ancestor that does not have a parent. The Bitcoin Computer assigns the root of an smart object to the property `_root`. The root can be used to create fungible tokens with the Bitcoin Computer.
If an object is created in a function call of the form $x.f(\ldots)$ we say that $x$ is its parent. We say that an object $x_1$ is the ancestor of an object $x_n$ if there is a sequence of objects $x_2 \ldots x_{n-1}$ such that $x_i$ is the parent of $x_{i+1}$ for all $i$. The root of an object is its (unique) ancestor that does not have a parent. The Bitcoin Computer assigns the root of a smart object to the property `_root`. The root can be used to create fungible tokens with the Bitcoin Computer.

In other words, an object’s lineage is defined by its function calls. If an object is created within a function, the object calling the function is deemed the parent. An ancestor of an object is defined by a lineage of parent-child relationships leading back to a unique ancestor with no parent, which is called the root. The root identity is critical for creating fungible tokens, as it provides a stable reference point for all transactions and interactions related to that object.

## Examples

Expand Down
17 changes: 9 additions & 8 deletions packages/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ layout: page

# Introduction

The Bitcoin Computer (TBC) is a Turing-complete smart contract system for Bitcoin and Litecoin. You can build decentralized applications, such as tokens, exchanges, games, social networks, and more.
The Bitcoin Computer (TBC) is a Turing-complete smart contract system for Bitcoin and Litecoin, designed for creating decentralized applications. With TBC, you can create tokens, exchanges, games, social networks, and more.

**Free Computation.** The most important feature of TBC is that the execution cost is independent of the computational complexity of the smart contract. For most other smart contract systems, the execution cost increases with each computational step. Instead, the cost on TBC is fixed for an unlimited number of computational steps.
**Free Computation.** A key feature of TBC is that execution costs do not depend on the computational complexity of the smart contract itself. Unlike other systems where costs escalate with computational intensity, TBC maintains a fixed cost for an unlimited number of computational steps.

**JavaScript.** Smart contracts are JavaScript or TypeScript classes. This makes it seamless to integrate smart contracts into web applications and makes development easy due to the existing JavaScript ecosystem.
**JavaScript and TypeScript Support.** Smart contracts on TBC are built using JavaScript or TypeScript classes, ensuring fluid integration with web applications. This compatibility leverages the robust JavaScript ecosystem, simplifying development and enhancing functionality.

**How it works.** You can inscribe a JavaScript class to deploy a smart contract. Then, you can inscribe a constructor call to create a smart object and a function call to update a smart object.
**How it works.** To deploy a smart contract on TBC, simply inscribe a JavaScript class. You can then instantiate your smart contract by inscribing a constructor call, creating a “smart object”. Updates to this object are managed through subsequent inscribed function calls, enabling dynamic interactions within your application.

**Data Ownership.** Conceptually, a smart object is stored in a UTXO, and only the owner of the UTXO can update its state. This captures a natural notion of data ownership that is as secure as ownership of Bitcoin.

**Historical States.** As every update is recorded in a separate transaction, every historical state of a smart object can be recovered, together with information about who updated it and when.
**Data Ownership.** In TBC, each smart object resides within a UTXO (Unspent Transaction Output). The owner of the UTXO is the only entity authorized to modify the object’s state, reflecting a natural approach to data ownership that mirrors the security associated with Bitcoin transactions.

**Encryption and Off Chain Storage.** By default, every user can read all states of all smart objects. However, TBC has support for end-to-end encryption and storing data off-chain built-in. These properties make it easy to build applications that comply with consumer protection laws such as CCPA and GDPR.
**Historical States.** Every transaction on TBC records an update, allowing for the recovery of every historical state of a smart object. This history includes details on who made updates and when, providing a comprehensive audit trail for each object.

**Pure Bitcoin.** Finally, TBC relies only on Bitcoin. It does not require a side-chain or an extra token. This makes it possible to build applications that are as stable as Bitcoin.
**Encryption and Off Chain Storage.** By default, every user can read the states of smart objects on TBC. However, the platform includes built-in support for end-to-end encryption and off-chain data storage. These features facilitate the development of applications that adhere to consumer protection regulations such as the CCPA and GDPR, ensuring both security and compliance.

**Pure Bitcoin.** Finally, TBC relies only on Bitcoin. It does not require a side-chain or an extra token. This makes it possible to build applications that are as trustless as Bitcoin.

**Contact.** TBC is being developed by BCDB Inc. If you have any questions, please let us know in our [Telegram group](https://t.me/thebitcoincomputer), on [Twitter](https://twitter.com/TheBitcoinToken), or by email at clemens@bitcoincomputer.io.
8 changes: 8 additions & 0 deletions packages/website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@

## Usage

### Run Locally

```
npm start
```

### Deploy

To deploy a new version merge a pull request into main.
15 changes: 7 additions & 8 deletions packages/website/src/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,43 @@ function Features() {
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Easy to Use"
text="Smart contracts are written in Javascript. If you know Javascript you can write smart contracts."
text="Smart contracts on the Bitcoin Computer are written in JavaScript. If you are familiar with JavaScript, you can easily develop your own smart contracts using our platform."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Free computation"
text="On other blockchains almost all algorithms are prohibitively expensive. On Bitcoin all algorithms have the same cost: the cost of a payment.
This makes it possible, for the first time, to run compute intense algorithms as smart contracts."
text="Unlike other platforms where computation is prohibitively expensive, Bitcoin Computer standardizes costs: every algorithm incurs only the cost of a payment. This unique cost structure opens up new possibilities for deploying compute-intensive algorithms within smart contracts."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Pure Bitcoin"
text="Smart contracts on Bitcoin are as decentralized as Bitcoin itself. The Bitcoin Computer does not depend on a side-chain, this means that smart contracts will continue to work as long as Bitcoin is available."
text="Smart contracts on Bitcoin boast the same level of decentralization as Bitcoin itself. The Bitcoin Computer operates without relying on a side-chain, ensuring that smart contracts remain functional as long as Bitcoin exists."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Off-Chain storage"
text="Which data needs to be stored on-chain vs securely hashed and off-chain is application dependent. We make it easy for the programmer to store data off-chain."
text="The choice between storing data on-chain or securely hashing it off-chain depends on the application. Our platform simplifies the process for programmers to store data off-chain efficiently, allowing for tailored data management strategies."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Encryption"
text="Built to balance privacy with compliance: all smart contract data can be encrypted but flows of money are un-encrypted to enable anti-money laundering efforts."
text="Designed to balance privacy with compliance, our platform ensures that while all smart contract data can be encrypted for privacy, monetary transactions remain transparent to support anti-money laundering initiatives."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Cross-Chain"
text="We want the Bitcoin Computer to work on all Bitcoin-like currencies. We are launching on Litecoin and will add support for other currencies over time."
text="Our goal is for the Bitcoin Computer to be compatible with all Bitcoin-like currencies. Initially launching with support for Litecoin, we plan to progressively include additional currencies to enhance accessibility and versatility."
/>
</Grid>
<Grid item xs={4} className="feature featuresGridItem">
<Feature
heading="Trustless"
text="You can run your own Bitcoin Computer Node to gain trustless access to the blockchain. You can deploy a node locally with one line of code."
text="Operate your own Bitcoin Computer Node for trustless blockchain access. Deploy a node locally with just a single line of code, ensuring full control and direct interaction with the blockchain."
/>
</Grid>
</Grid>
Expand Down
11 changes: 5 additions & 6 deletions packages/website/src/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ function Introduction() {
<Box className="features" id="features">Features</Box>
<Box className="headingWrapper">
<Box className="headline">
<p>Turing Complete Smart Contracts</p>
<p>for Bitcoin.</p>
<p>Enabling Turing-complete smart contracts</p>
<p>on Bitcoin.</p>
</Box>
<Box className="subHeading">
<p>Bitcoin Computer is an easy to use smart contract system for Bitcoin.</p>
<p>You can build fungible and non-fungible tokens (NFTs), games, social</p>
<p>networks, exchanges, auctions, voting, office applications, artificial</p>
<p>intelligence ... anything really.</p>
<p>Bitcoin Computer is an easy-to-use smart contract platform for Bitcoin,</p>
<p>enabling the creation of fungible tokens, NFTs, games, social networks,</p>
<p>or complex systems like exchanges, auctions, and even artificial intelligence.</p>
</Box>
</Box>
</Box>
Expand Down