# Lib

The Bitcoin Computer Library (available on Github and Npm) provides all the functionality needed to write smart contracts with the Bitcoin Computer.

To interface with the blockchain, the Bitcoin Computer Lib connects to a Bitcoin Computer node. By default the Bitcoin Computer Lib connects to a node in regtest node that we provide. You can find more information about configuration options in the section constructor.

# Api

# Basic

You can build almost all smart contracts with following methods.

Method Description
constructor Creates an instance of class Computer
new Creates a smart object from a smart contract
query Finds the latest revisions of smart object
sync Computes the state of a smart object from a given revision

# Advanced

To build advanced applications like swaps have a look at the following.

Method Description
encode Encodes a Javascript expression into a Bitcoin transaction
encodeNew Encodes a constructor call into a Bitcoin transaction
encodeCall Encodes a function call into a Bitcoin transaction
decode Parses a Bitcoin transaction and returns Javascript expression
faucet Fund a computer object on Regtest

# Modules

You can save transaction fees by using our ES6 module system.

Method Description
deploy Deploys an ES6 module on the blockchain
load Loads an ES6 module from the blockchain

# Wallet

The wallet functionality within a Computer instance can be accessed using the following.

Method Description
sign Signs a Bitcoin transaction
broadcast Broadcasts a Bitcoin transaction
send Sends satoshis to an address
rpcCall Access Bitcoin's RPC interface
getAddress Returns the Bitcoin address of the computer wallet
getBalance Confirmed, unconfirmed and total balance in sats
getChain Returns the blockchain
getNetwork Returns the network
getMnemonic Returns a BIP39 mnemonic sentence
getPassphrase Returns the passphrase
getPrivateKey Returns the private key
getPublicKey Returns the public key
getUtxos Returns an array of unspent transaction outputs