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
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ packages/node/scripts/__pycache__
packages/BRC20
packages/BRC721
packages/chat
packages/components
packages/create-react-app-template
packages/docs
packages/explorer
packages/fungible-token
packages/node-js-boilerplate
packages/non-fungible-token
packages/react-app-ts-template
packages/wallet
packages/blockchain-explorer
packages/website

Dockerfile
.dockerignore
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# We are using the latest Node.js distribution with Long Term Support (LTS) as of 11/04/2020.
FROM node:16.14
# We are using the alpine distribution with Long Term Support (LTS) as of 11/04/2020.
FROM node:20-alpine

RUN apk add --no-cache cmake make gcc g++ python3
# insall dependencies to run cmake
RUN apk add --no-cache libstdc++ libgcc curl

# Set the working directory inside the container
WORKDIR /dist
Expand All @@ -8,16 +12,17 @@ WORKDIR /dist
COPY . /dist

# Install dependencies for the monorepo using yarn
RUN yarn install --cwd /dist
RUN yarn install

# Set the working directory to "monorepo/packages/node"
WORKDIR /dist/packages/node

# Install dependencies for the node using yarn
RUN yarn install

# Print package.json version
RUN echo "Version: $(head ../lib/package.json)"

# Run lerna bootstrap
RUN npx lerna@5.2.0 bootstrap

EXPOSE 1031
# Define the command to run when the container starts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitcoin-computer",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"description": "Lightweight Smart Contracts for Bitcoin and Litecoin",
"contributors": [
"Clemens Ley",
Expand Down
4 changes: 2 additions & 2 deletions packages/BRC20/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitcoin-computer/BRC20",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"description": "Minimalistic boilerplate to quick-start Bitcoin Computer development.",
"private": true,
"type": "module",
Expand Down Expand Up @@ -38,7 +38,7 @@
"author": "Clemens Ley <clemens@bitcoincomputer.io>",
"license": "Apache-2.0",
"dependencies": {
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"eslint-plugin-prettier": "^4.0.0",
"ts-node": "^10.8.1",
"tslib": "~2.4.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/BRC721/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitcoin-computer/BRC721",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"description": "Standard for non-fungible tokens on Bitcoin",
"private": true,
"type": "module",
Expand All @@ -19,7 +19,7 @@
"build"
],
"dependencies": {
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"eslint-plugin-prettier": "^4.0.0",
"ts-node": "^10.8.1",
"tslib": "~2.4.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/chat/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@bitcoin-computer/chat",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"private": true,
"dependencies": {
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitcoin-computer/components",
"version": "1.0.0",
"version": "0.17.0-beta.0",
"description": "",
"main": "built/index.js",
"types": "built/index.d.ts",
Expand All @@ -13,7 +13,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"flowbite": "^2.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/create-react-app-template/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "test-app",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"private": true,
"dependencies": {
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "explorer",
"version": "0.1.0",
"version": "0.17.0-beta.0",
"private": true,
"dependencies": {
"@bitcoin-computer/components": "1.0.0",
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/components": "0.17.0-beta.0",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/fungible-token/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@bitcoin-computer/fungible-token",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"private": true,
"dependencies": {
"@bitcoin-computer/lib": "^0.16.0-beta.1",
"@bitcoin-computer/lib": "^0.17.0-beta.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.0",
Expand Down
105 changes: 58 additions & 47 deletions packages/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,45 @@
<h1>Bitcoin Computer Library</h1>
</div>

A non-custodial Javascript wallet that can read and write smart contract data from and to UTXO based blockchains. The client side component of the [Bitcoin Computer](http://bitcoincomputer.io/). You can
[A smart contract system for Bitcoin and Litecoin.](http://bitcoincomputer.io/)
* Inscribe a Javascript class to create a smart contract
* Inscribe a constructor call to create a smart object from a smart contract
* Inscribe a function call to update a smart object
* Smart objects live in UTXOs, the owner of the UTXO iss the owner of the object
* Only the owner can update a smart object by spending the UTXO
* All historical states are recorded in spent UTXOs
* Read access can be restricted via end-to-end encryption
* Data can be stored off-chain on a [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node)
* Smart contracts can be decomposed using ES6 modules

- Deploy Javascript classes as smart contracts on UTXO-based blockchains
- Create objects from these smart contracts and store them on the blockchain
- Update and combine smart objects using function calls
- Track updates in digitally signed and timestamped transactions
- Check the validity and read the state of smart objects
- Recover all historical states of an object
- Encrypt data in the browser for end-to-end encrypted applications
- Store data off-chain on a [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node)
- Use ES6 modules to decompose smart contracts
- Currently support for Litecoin, support for Bitcoin and Dogecoin coming soon

## Prerequisites

It depends on the setup you are aiming for

- Testnet: This is the easiest way to get started. You need to have [node.js](https://nodejs.org/en/) installed.
- Regtest: This is the recommended setup for serious development. You need [node.js](https://nodejs.org/en/) installed and you need to run a [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node).
- Mainnet: This is the setup for production. You need [node.js](https://nodejs.org/en/) installed, you need to run a [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node), and you need mainnet coins.

Below we explain how to use testnet. Have a look at the readme file for the [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node) for how to run an app on regtest or mainnet.

## Use with Node.js

Below we explain how to use testnet (recommended to try it out). Have a look at the readme file for the [Bitcoin Computer Node](https://github.com/bitcoin-computer/monorepo/tree/main/packages/node) for how to run an app on regtest or mainnet.

### Install

In an empty directory run.

```
<font size=1>

```bash
npm init -y
npm add @bitcoin-computer/lib
```

</font>

### Write a Smart Contract

Create file `index.mjs`

```
<font size=1>

```js
import { Computer, Contract } from '@bitcoin-computer/lib'

// Define a smart object
// Define a smart contract
class Counter extends Contract {
constructor() {
super({ n: 0 })
Expand All @@ -56,57 +53,63 @@ class Counter extends Contract {
}


// Create a smart object on the blockchain
;(async () => {
// Create a Bitcoin Computer wallet
const computer = new Computer({ mnemonic: 'replace this seed' })
const computer = new Computer({ mnemonic: 'old lake fun' })

// Deploy a smart object
// Deploy a smart contract and create a smart object
const counter = await computer.new(Counter)

// Update a smart object
// Update the smart object
await counter.inc()

// Log the state
console.log(counter)
})()
```

</font>

### Fund the Wallet

In order to execute the smart contract, you must first send an amount of testnet coins to the address associated with the mnemonic seed used to create the Computer object. You can use a Litecoin testnet faucet, for example [here](https://testnet-faucet.com/ltc-testnet/), [here](https://tltc.bitaps.com/), or [here](https://testnet.help/en/ltcfaucet/testnet).
In order to execute the smart contract, you must send an amount of testnet coins to the address associated with the mnemonic seed of the Computer object. The easiest way to find out which address you need to fund is to run the smart contract (see below) and use the address from the error message.

```
// Address generated from the mnemonic seed 'replace this seed'
ms2Nd47NDmqqtNuajthkjh7p1b328XhVU8
```
You can get free testnet Litecoin from a faucet, for example [here](https://testnet.help/en/ltcfaucet/testnet) or [here](https://tltc.bitaps.com/).

### Run the Smart Contract

<font size=1>

```
node index.mjs
```

</font>

The expected output is:

```
<font size=1>

```js
Counter {
n: 1,
_id: '83553f27c9e4651323f1ebb...',
_rev: '290923708ca56ea448dd67...',
_root: '8136e4bceaf528ef6a8ff...'
_id: '8136e4 ... d67:0',
_rev: '290923 ... 48d:0',
_root: '8136e4 ... d67:0'
}
```

You can use smart objects to build decentralized applications. For more information see our docs [Docs](https://docs.bitcoincomputer.io/).
</font>

## Use in a Browser

### Write a Smart contract

Create file `index.js`.

```
<font size=1>

```js
import { Computer, Contract } from "https://unpkg.com/@bitcoin-computer/lib/dist/bc-lib.browser.min.mjs";

class Counter extends Contract {
Expand All @@ -131,11 +134,15 @@ class Counter extends Contract {
})()
```

</font>

### Embed in a Website

Create file `index.html`

```
<font size=1>

```html
<html>
<body>
<div id='el'></div>
Expand All @@ -144,21 +151,27 @@ Create file `index.html`
</html>
```

### Start a Local Server
</font>

```
### Start a Local Web Server

<font size=1>

```bash
npm init -y
npm i http-server
http-server
```

</font>

### Fund Wallet

See this [Section](#fund-the-wallet).
See [above](#fund-the-wallet).

### View Website

To create and update a smart object and see the counter update open [http://localhost:8080](http://localhost:8080) in your browser.
Open [http://localhost:8080](http://localhost:8080) in your browser.

## Price

Expand All @@ -172,9 +185,7 @@ We have completed two internal audits and addressed any discovered issues. Curre

## Documentation and Help

Have a look at the [Docs](https://docs.bitcoincomputer.io/).

If you have any questions, please let us know in our <a href="https://t.me/thebitcoincomputer">Telegram group</a>, on <a href="https://twitter.com/TheBitcoinToken">Twitter</a>, or by email clemens@bitcoincomputer.io.
Have a look at the [Docs](https://docs.bitcoincomputer.io/). If you have any questions, please let us know in our <a href="https://t.me/thebitcoincomputer">Telegram group</a>, on <a href="https://twitter.com/TheBitcoinToken">Twitter</a>, or by email clemens@bitcoincomputer.io.

## License

Expand Down
4 changes: 2 additions & 2 deletions packages/lib/dist/bc-lib.browser.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/lib/dist/bc-lib.main.es.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/lib/dist/bc-lib.module.es.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bitcoin-computer/lib",
"version": "0.16.0-beta.1",
"version": "0.17.0-beta.0",
"private": false,
"description": "Smart Contracts for Bitcoin",
"license": "CC-BY-ND-4.0",
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@babel/parser": "^7.20.7",
"@bitcoin-computer/nakamotojs-lib": "^6.1.5",
"@bitcoin-computer/nakamotojs-lib": "^6.2.1",
"@bitcoin-computer/tiny-secp256k1": "^2.2.1",
"@endo/static-module-record": "^0.7.4",
"axios": "^0.27.2",
Expand Down
Loading