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
3 changes: 3 additions & 0 deletions packages/docs/Lib/next.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# next

Documentation coming soon.
3 changes: 3 additions & 0 deletions packages/docs/Lib/prev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# prev

Documentation coming soon.
File renamed without changes.
166 changes: 114 additions & 52 deletions packages/docs/Node/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,58 +106,6 @@ npm run clean

</font>

### Client Side Library

The [Bitcoin Computer Library](https://github.com/bitcoin-computer/monorepo/tree/main/packages/lib#readme) can connect to a Bitcoin Computer Node to provides access to its functionality.

<font size=1>

```js
// Import client side library
import { Computer } from '@bitcoin-computer/lib'

// Configuration to connect to node on localhost
const conf = {
chain: 'LTC',
network: 'regtest',
url: 'http://localhost:1031',
}

// Create instance of client side library
const computer = new Computer(conf)
const address = computer.getAddress()

// Fund client side library
const { txId, vout } = await computer.faucet(1e4)

// Return the utxos
expect(await new Computer(conf).getUtxos(address)).deep.eq([`${txId}:${vout}`])

// Return the balance
expect(await new Computer(conf).getBalance(address).balance).eq(1e4)

// Return the transactions
expect(await new Computer(conf).listTxs(address)).deep.eq({
sentTxs: [],
receivedTxs: [
{
txId,
inputsSatoshis: 0,
outputsSatoshis: 1e4,
satoshis: 1e4,
},
],
})
```

</font>

If you do not specify a `url` property it will default to the url below. The node at that url runs Litecoin on regtest network mode and uses the latest version of the Bitcoin Computer Node software.

```
https://rltc.node.bitcoincomputer.io
```

## Configuration

You can configure several options by editing the `.env` file.
Expand Down Expand Up @@ -255,6 +203,120 @@ BCN_OFFCHAIN_PROTOCOL=

</font>

## Client Side Library

The [Bitcoin Computer Library](https://github.com/bitcoin-computer/monorepo/tree/main/packages/lib#readme) can connect to a Bitcoin Computer Node to provides access to its functionality.

<font size=1>

```js
// Import client side library
import { Computer } from '@bitcoin-computer/lib'

// Configuration to connect to node on localhost
const conf = {
chain: 'LTC',
network: 'regtest',
url: 'http://localhost:1031',
}

// Create instance of client side library
const computer = new Computer(conf)
const address = computer.getAddress()

// Fund client side library
const { txId, vout } = await computer.faucet(1e4)

// Return the utxos
expect(await new Computer(conf).getUtxos(address)).deep.eq([`${txId}:${vout}`])

// Return the balance
expect(await new Computer(conf).getBalance(address).balance).eq(1e4)

// Return the transactions
expect(await new Computer(conf).listTxs(address)).deep.eq({
sentTxs: [],
receivedTxs: [
{
txId,
inputsSatoshis: 0,
outputsSatoshis: 1e4,
satoshis: 1e4,
},
],
})
```

</font>

If you do not specify a `url` property it will default to the url below. The node at that url runs Litecoin on regtest network mode and uses the latest version of the Bitcoin Computer Node software.

```
https://rltc.node.bitcoincomputer.io
```

## Api

The Bitcoin Computer Node exposes an API that can be used to interact with the node.
The variables `CHAIN` and `NETWORK` are used to define the chain and network that the node is running on.

#### Wallet

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [balance](./wallet/balance.md) | Get the balance of a wallet. |
| [list-txs](./Wallet/list-txs.md) | List sent and received transactions for a given address. |
| [sent-outputs](./Wallet/sent-outputs.md) | List sent outputs of a wallet. |
| [received-outputs](./Wallet/received-outputs.md) | List received outputs of a wallet. |
| [utxos](./Wallet/utxos.md) | List unspent outputs of a wallet. |

#### Transactions

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [ancestors](./Transaction/ancestors.md) | Get the ancestors of a transaction. |
| [bulk](./Transaction/bulk.md) | Get raw transactions for a list of transaction ids. |
| [json](./Transaction/json.md) | Get a transaction in json format. |
| [post](./Transaction/post.md) | Post a transaction to the Bitcoin network. |

#### Blockchain

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [height](./Blockchain/height.md) | Get the height of an specific block. |
| [mine](./Blockchain/mine.md) | Mine an specific number of blocks to a random address. |
| [rpc](./Blockchain/height.md) | Call a Bitcoin RPC method. |

#### Regtest Faucet

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [faucet](./Regtest-faucet/faucet.md) | Get coins from the faucet. |
| [faucetScript](./Regtest-faucet/faucetScript.md) | Get coins from the faucet using a script. |

#### Query revisions

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [next](./Query-revisions/next.md) | Get the next revision of a given revision. |
| [prev](./Query-revisions/prev.md) | Get the previous revision of a given revision. |
| [non-standard-utxos](./Query-revisions/non-standard-utxos.md) | Query revisions by module specifier, public key, limit, order, offset and list of transaction ids. |
| [revs](./Query-revisions/revs.md) | Get the revisions of a list of transactions. |
| [revToId](./Query-revisions/revtoid.md) | Given a revision, get the id of the smart contract. |

#### OffChain

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [id](./Regtest-faucet/faucet.md) | Get the data stored in the offchain storage. |
| [store](./Regtest-faucet/faucetScript.md) | Stores the hex of the data in the offchain storage. |

<!-- ### Configure Parallelism

By default the synchronization runs in parallel and uses all cores of your machine. You can use the `-cpus` flag to limit the number of cores used.
Expand Down
26 changes: 17 additions & 9 deletions packages/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,28 @@ layout: page

# Introduction

The Bitcoin Computer is a Turing-complete metaprotocol for UTXO-Based Blockchains, designed for creating decentralized applications in Bitcoin, Litecoin and compatible blockchains like Dogecoin and Pepecoin (Bitcoin Cash coming soon). You can create tokens, exchanges, games, social networks, and more.
_The Bitcoin Computer is a Turing-complete metaprotocol for UTXO-based blockchains. You can build of games, social networks, tokens, decentralized exchanges, enterprise applications and much more._

**Free Computation.** A key feature of the Bitcoin Computer 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, the Bitcoin Computer maintains a fixed cost for an unlimited number of computational steps.
**Free Computation.** Execution costs are fixed and independent of the number of computational steps of a smart contract.

**JavaScript and TypeScript Support.** Smart contracts 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.
**Metaprotocol.** There is no trusted intermediaries and no extra blockchain or token. It works just like Ordinals or Runes, just that it's Turing complete, meaning that you can build applications that are as decentralized and secure as the underlying blockchain is.

**How it works.** To deploy a smart contract, 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.
**Multicoin**. We supports Bitcoin, Litecoin, Dogecoin, and Pepecoin, with Bitcoin Cash support coming soon. You can launch into all of these communities simultaneously because the same code works across all of these chains.

**Data Ownership.** 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.
**JavaScript.** Smart contracts are written in JavaScript or TypeScript, leveraging vast ecosystems and enabling seamless integration with web applications.

**Historical States.** Every transaction on the Bitcoin Computer 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.
**Data Ownership.** An on-chain object is stored in a UTXO (Unspent Transaction Output) and can only be updated by spending the UTXO. Thus the owner of the UTXO is the owner of the data and data ownership is as secure as cryptocurrency ownership.

**Encryption and Off Chain Storage.** By default, every user can read the states of smart objects on the Bitcoin Computer. 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.
**Compatible.** You can build application that use assets from other protocols - for example a game with ordinals or a DEX for Runes. Other protocols like BitVM are orthogonal and can be "plugged in" to enforce complex data ownership conditions.

**Pure Bitcoin.** Finally, this framework 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.
**Simple.** To deploy a smart contract, inscribe a JavaScript class, to create an on-chain object, inscribe a constructor call and to update an on-chain object, inscribe a function call.

**Contact.** The Bitcoin Computer 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.
**Fast**. Built-in optimizations avoid any redundant computation. Apps are fast out of the box.

**History.** As every state update is recorded in a transaction, each historical state is recoverable. Additionally, all updates are timestamped and digitally signed, making it easy to audit applications.

**Privacy.** On-chain objects are public by default, but the protocol has support for end-to-end encryption and off-chain data storage. This enables CCPA and GDPR compliant enterprise applications.

---

The Bitcoin Computer is 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.
35 changes: 15 additions & 20 deletions packages/docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ icon: rocket

## Use in the Browser

The easiest way to try the Bitcoin Computer is to create a file as below and open it in your browser.
Create the following file and open it in a browser.

```html
```html index.html
<html>
<head>
<script type="module">
// Import the library
import {
Computer,
Contract,
Expand All @@ -30,29 +29,27 @@ The easiest way to try the Bitcoin Computer is to create a file as below and ope
}
}

// Create a wallet
// Create and fund a wallet
const computer = new Computer()

// Fund the wallet
await computer.faucet(1e5)

// Create a smart object
// Create an on-chain object
const counter = await computer.new(Counter)
document.getElementById('count').innerHTML = counter.n

// Update the smart object
// Update the on-chain object
await counter.inc()
document.getElementById('count').innerHTML = counter.n
</script>
</head>

<body>
Value: <span id="count">*</span>
<span id="count">*</span>
</body>
</html>
```

When the website is first rendered you will see `Value: *`. When the smart object is created with `computer.new` you will see `Value: 0`. The `inc` function is called you will see `Value: 1`.
The browser will initially show `*`. When the on-chain object is created it will show `0` an when the object is updated it will show `1`.

## Use in Node.js

Expand Down Expand Up @@ -88,19 +85,17 @@ class Counter extends Contract {
}
}

// Create a wallet
// Create and fund a wallet
const computer = new Computer()

// Fund the wallet
await computer.faucet(1e5)

// Create a smart object
// Create an on-chain object
const counter = await computer.new(Counter)

// Update the smart object
// Update the on-chain object
await counter.inc()

// Log the smart object
// Log the on-chain object
console.log(counter)
```

Expand Down Expand Up @@ -133,11 +128,11 @@ Counter {

</font>

In the setup above you are using a node that we provide at `rltc.node.bitcoincomputer.io` (Litecoin Regtest). You can use this node for free but it is rate limited. For serious development we recommend to clone the monorepo so you can run your own, unlimited, node.
In both examples above you are using a Bitcoin Computer Node that we provide at `rltc.node.bitcoincomputer.io` configured to Litecoin Regtest. You can use this node for free but it is rate limited. For serious development we recommend to clone the monorepo so you can run your own, unlimited, node.

## Run a Node

To run a node we recommend to clone the [monorepo](https://github.com/bitcoin-computer/monorepo#readme) with all Bitcoin Computer related materials, including the [Bitcoin Computer library](https://github.com/bitcoin-computer/monorepo/tree/main/packages/lib#readme), the [node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node#readme), the [docs](https://github.com/bitcoin-computer/monorepo/tree/main/packages/docs#readme), and [example applications](https://github.com/bitcoin-computer/monorepo/blob/main/packages/docs/apps.md).
To run a node we recommend to clone the [monorepo](https://github.com/bitcoin-computer/monorepo#readme) with all Bitcoin Computer related materials, including the [Bitcoin Computer library](https://github.com/bitcoin-computer/monorepo/tree/main/packages/lib#readme), the [node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node#readme), these [docs](https://github.com/bitcoin-computer/monorepo/tree/main/packages/docs#readme), and [example applications](https://github.com/bitcoin-computer/monorepo/blob/main/packages/docs/apps.md).

### Install

Expand All @@ -152,7 +147,7 @@ npm install

### Start the node

To start your node at `http://localhost:1031` run the commands below. The node is ready once the log activity subsides. On regtest this will take a few minutes, on mainnet and testnet it can take days or even weeks, depending on your hardware.
To start your node at `http://localhost:1031` run the commands below. The node is ready once the log activity subsides. On regtest this will take a few minutes, on mainnet and testnet it can take hours or even days, depending on your hardware and network connection.

```shell
# Run the node
Expand Down Expand Up @@ -181,7 +176,7 @@ npm run lint
npm run types
```

The commands will be run in each package. You can also navigate the a package and run the same scripts there.
The commands will be executed in each package. You can also navigate the a package and run the same scripts there.

### Start your own Project

Expand Down
Loading