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
2 changes: 1 addition & 1 deletion packages/docs/Examples/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Chat extends Contract {

## Usage

A new chat can be created using the [`new`](./API/new.md) function. Note that Bob can initially post to the chat and read it's state as Bob's public key was added by Alice to the `_owners` array and to the `_readers` array upon creation of the chat.
A new chat can be created using the [`new`](../Lib/Computer/new.md) function. Note that Bob can initially post to the chat and read it's state as Bob's public key was added by Alice to the `_owners` array and to the `_readers` array upon creation of the chat.

Later, Alice called the `remove` function removing Bob's public key from these arrays. After this point Bob cannot read or write anymore.

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/Examples/non-fungible-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class NFT extends Contract {

## Usage

To create an on-chain object of class `NFT`, you can use the [`new`](./API/new.md) function of the `Computer` class. The [`faucet`](./API/faucet.md) function funds the `sender` object on `regtest`. The `sender.new` function mints a new NFT and the `transfer` function send the NFT to another user.
To create an on-chain object of class `NFT`, you can use the [`new`](../Lib/Computer/new.md) function of the `Computer` class. The [`faucet`](../Lib/Computer/faucet.md) function funds the `sender` object on `regtest`. The `sender.new` function mints a new NFT and the `transfer` function send the NFT to another user.

```ts
import { Computer } from '@bitcoin-computer/lib'
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/broadcast.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ If the broadcast is successful, it returns the transaction id. Otherwise, an err
## Example

:::code source="../../../lib/test/lib/computer/broadcast.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/broadcast.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ An instance of the `Computer` class
## Examples

:::code source="../../../lib/test/lib/computer/constructor.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/constructor.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/decode.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ The function `decode` is the inverse of `encode` when the latter is called with
## Example

:::code source="../../../lib/test/lib/computer/decode.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/decode.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ import { c2 } from '5530cfcc89fde62c2cfab4eea56e3aa2d41071480b7b094d7a0131677671
import { c3 } from 'dc63fbf200595012b239d69936ac63e4155040042ef7d2e6dff4ca49dec3f51e:0' // stores '0'
export const s = c0 + c1 + c2 + c3
```

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/deploy.test.ts" target=_blank>Sources</a>
6 changes: 4 additions & 2 deletions packages/docs/Lib/Computer/encode.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ An object with a specification to build a transaction according to the Bitcoin C

### Return Value

It returns an object `{ tx, effect }` where `tx` is a [NakamotJS](../../NakamotoJs/) transaction and `effect` is an object with keys `res` and `env`. The `res` object contains the result of the evaluation. The `env` object has the same keys as the blockchain environment. However, whereas the values of the blockchain environment are revision strings, the values of `env` and the smart object at these revisions _after_ evaluating the expression.
It returns an object `{ tx, effect }` where `tx` is a [NakamotoJS](../../NakamotoJs/) transaction and `effect` is an object with keys `res` and `env`. The `res` object contains the result of the evaluation. The `env` object has the same keys as the blockchain environment. However, whereas the values of the blockchain environment are revision strings, the values of `env` and the smart object at these revisions _after_ evaluating the expression.

## Description

The `encode` function builds a Bitcoin transaction from a JavaScript expression. It returns a transaction and an object `effect` containing the result of the evaluation in a property `res`. If the expression contains undefined variables a blockchain environment `env` must be passed into `encode`. A _blockchain environment_ maps the named of the undefined variable to UTXOs containing on-chain objects. A [module specifier](#modules) can be provided in order to make the exports of that module are available to the evaluation. Other options can customize the funding and signing process. It is also to pass in an object specifying [mocked](../../tutorial.md#mocking) objects.
The `encode` function builds a Bitcoin transaction from a JavaScript expression. It returns a transaction and an object `effect` containing the result of the evaluation in a property `res`. If the expression contains undefined variables a blockchain environment `env` must be passed into `encode`. A _blockchain environment_ maps the named of the undefined variable to UTXOs containing on-chain objects. A [module specifier](../../tutorial.md#module-system) can be provided in order to make the exports of that module are available to the evaluation. Other options can customize the funding and signing process. It is also to pass in an object specifying [mocked](../../tutorial.md#mocking) objects.

It is important to note that `encode` does not broadcast the transaction. Nonetheless the `effect` object reflects the on-chain state that will emerge once the transaction is broadcast.

Expand All @@ -75,3 +75,5 @@ The state update effected by a Bitcoin Computer transaction is completely predic
## Example

:::code source="../../../lib/test/lib/computer/encode.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/encode.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/encodeCall.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ See [`encode`](./encode.md).
## Example

:::code source="../../../lib/test/lib/computer/encode-call.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/encode-call.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/encodeNew.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ See [`encode`](./encode.md).
## Example

:::code source="../../../lib/test/lib/computer/encode-new.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/encode-new.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/faucet.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ Funds a `Computer` object on regtest. A second parameter can provide an address
## Example

:::code source="../../../lib/test/lib/computer/faucet.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/faucet.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/fund.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ If the wallet does not have sufficient funds, an error is thrown.
## Example

:::code source="../../../lib/test/lib/computer/fund.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/fund.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getAddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ computer.getAddress()
## Example

:::code source="../../../lib/test/lib/computer/get-address.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-address.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getBalance.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ Returns the confirmed balance in Satoshi, the unconfirmed balance, and the total
## Example

:::code source="../../../lib/test/lib/computer/get-balance.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-balance.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getChain.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Returns a string encoding the chain.
## Example

:::code source="../../../lib/test/lib/computer/get-chain.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-chain.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getMnemonic.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ You can set the mnemonic in the constructor of the `Computer` class. The mnemoni
## Example

:::code source="../../../lib/test/lib/computer/get-mnemonic.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-mnemonic.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getNetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Returns a string encoding the network.
## Example

:::code source="../../../lib/test/lib/computer/get-network.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-network.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getPassphrase.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ The passphrase can be set in the `Computer` constructor. It defaults to an empty
## Example

:::code source="../../../lib/test/lib/computer/get-passphrase.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-passphrase.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getPrivateKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Returns a string encoded BIP32 private key.
## Example

:::code source="../../../lib/test/lib/computer/get-private-key.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-private-key.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getPublicKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ A string encoding BIP32 public key.
## Example

:::code source="../../../lib/test/lib/computer/get-public-key.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-public-key.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getUtxos.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ The UTXOs returned are guaranteed to not contain any on-chain objects. This make
## Example

:::code source="../../../lib/test/lib/computer/get-utxos.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-utxos.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/getVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ The current version
## Example

:::code source="../../../lib/test/lib/computer/get-version.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/get-version.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/load.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ A JavaScript module.
## Example

:::code source="../../../lib/test/lib/computer/load.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/load.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ On-chain objects can be freely combines: you can pass an on-chain object as a pa
## Example

:::code source="../../../lib/test/lib/computer/new.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/new.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Given the revision of an on-chain object, the function returns the next revision
## Example

:::code source="../../../lib/test/lib/computer/next.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/next.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/prev.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ Given the revision of an on-chain object, the function returns the previous revi
## Example

:::code source="../../../lib/test/lib/computer/prev.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/prev.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ Conditions can be passed in to determine the on-chain objects. When multiple con
## Example

:::code source="../../../lib/test/lib/computer/query.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/query.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/rpcCall.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ A JSON object with the result of the rpc method call.
## Example

:::code source="../../../lib/test/lib/computer/rpc-call.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/rpc-call.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/send.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ If successful, it returns the id of the transaction broadcast.
## Example

:::code source="../../../lib/test/lib/computer/send.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/send.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/sign.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ This is useful in the case of partially signed transactions, where a user can en
## Example

:::code source="../../../lib/test/lib/computer/sign.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/sign.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ The function enables real-time updates via Server-Sent Events (SSEs). The functi
## Example

:::code source="../../../lib/test/lib/computer/subscribe.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/subscribe.test.ts" target=_blank>Sources</a>
2 changes: 2 additions & 0 deletions packages/docs/Lib/Computer/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ If the function is called with a transaction id, it returns an object of type `{
## Example

:::code source="../../../lib/test/lib/computer/sync.test.ts" :::

<a href="https://github.com/bitcoin-computer/monorepo/blob/main/packages/lib/test/lib/computer/sync.test.ts" target=_blank>Sources</a>
3 changes: 2 additions & 1 deletion packages/docs/Lib/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
order: -40
icon: book
expanded: false
---

# Lib
Expand All @@ -10,7 +11,7 @@ The Bitcoin Computer Library has the exports below.
{.compact}
| Class | Description |
|-----------------------|-----------------------------------------|
| [Computer](./Computer) | Read and write smart contracts |
| [Computer](./Computer/) | Read and write smart contracts |
| [Transaction](./Transaction/) | Parse Bitcoin Computer transactions |
| [Contract](./Contract//) | Extend from this class to create smart contracts |
| [Mock](./Mock/) | Mock on-chain objects |
3 changes: 0 additions & 3 deletions packages/docs/Lib/index.yml

This file was deleted.

20 changes: 1 addition & 19 deletions packages/docs/Node/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,7 @@ The variables `CHAIN` and `NETWORK` are used to define the chain and network tha
{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [height](./height.md) | Get the height of an specific block. |
| [mine](./mine.md) | Mine an specific number of blocks to a random address. |
| [rpc](./height.md) | Call a Bitcoin RPC method. |

#### Regtest Faucet

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [faucet](./faucet.md) | Get coins from the faucet. |
| [faucetScript](./faucetScript.md) | Get coins from the faucet using a script. |
| [rpc](./rpc.md) | Call a Bitcoin RPC method. |

#### Query revisions

Expand All @@ -310,14 +300,6 @@ The variables `CHAIN` and `NETWORK` are used to define the chain and network tha
| [revs](./revs.md) | Get the revisions of a list of transactions. |
| [revToId](./revtoid.md) | Given a revision, get the id of the smart contract. |

#### OffChain

{.compact}
| Method | Description |
|-------------------------------------|----------------------------------------------------|
| [id](./faucet.md) | Get the data stored in the offchain storage. |
| [store](./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
11 changes: 4 additions & 7 deletions packages/docs/ordinals.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ Ordinal support is still experimental.

[Ordinals](https://github.com/casey/ord/blob/master/bip.mediawiki) is a scheme for assigning names to satoshis. These names can be linked to digital assets to make them transferrable.

The [Global Share Memory](/protocol.md#the-global-shared-memory) protocol is closely related to the ordinals protocol. It is based on a scheme for assigning names to outputs instead of to satoshis. The purpose is the same, an asset can be linked to a name, thereby making the asset transferrable.
There is an important special case where the two protocol coincide: Recall that an output is a "memory update" if its index is smaller than the number of inputs of the transaction. We call a memory update _conservative_ if it stores the same amount of satoshis as the output that it spends. Conservative updates preserve ordinal ranges.

There is an important special case where the two protocol coincide: Recall that an output is a "memory update" if its index is smaller than the number of inputs of the transaction. We call a memory update *conservative* if it stores the same amount of satoshis as the output that it spends. Conservative updates preserve ordinal ranges.

A Bitcoin Computer smart contract that does not use the ``_amount`` keyword only produces conservative updates. Therefore a smart objects defined by such smart contracts preserve ordinal ranges.
A Bitcoin Computer smart contract that does not use the `_amount` keyword only produces conservative updates. Therefore a smart objects defined by such smart contracts preserve ordinal ranges.

## Example

Expand All @@ -33,7 +31,7 @@ class NFT extends Contract {
}
```

If you create an NFT it will be stored in an output and that output is identified by the revision of the smart object. Say that output contains ordinals 5-10 (we are assuming some ``OrdinalsApi`` that can return the ordinals stores in a specified output).
If you create an NFT it will be stored in an output and that output is identified by the revision of the smart object. Say that output contains ordinals 5-10 (we are assuming some `OrdinalsApi` that can return the ordinals stores in a specified output).

```js
const nft = await computer.new(NFT)
Expand All @@ -51,7 +49,6 @@ expect(newOrdinals).to.deep.eq([5, 6, 7, 8, 9, 10])

Therefore you can build smart contracts like swaps that cannot be built with ordinals alone. You can store ordinals inside a smart object, pass them around in smart contracts and safely recover them, for example after they have been exchanged.


!!!
It is important to note that ordinal ranges are only preserved in smart contracts that do not use the ``_amount`` keyword.
It is important to note that ordinal ranges are only preserved in smart contracts that do not use the `_amount` keyword.
!!!
Loading