# API

This API describes the functionality of the Computer class, exported from @bitcoin-computer/lib.

# 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 Returns the balance in satoshi
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