Computer

The Computer class has the methods listed below.

Basic

You can build almost all smart contracts with these.

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

Modules

Deploy JavaScript modules (preferably via taproot) to avoid redundant on-chain storage for smart contracts, keep using expressions tiny, and minimize on-chain technical dust / hygiene dust costs. See Fees for details and best practices.

Method Description
deploy Deploys a JavaScript module on the blockchain
load Loads a JavaScript module from the blockchain

Advanced

For advanced applications that require control over how the transaction is signed, the UTXOs to be spent, custom scripts, or collaborative transaction building.

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

History

Access historical versions of on-chain objects.

Method Description
first Return the first revision
prev Return the previous revision
next Return the next revision
latest Return the latest revision

Wallet

Access the client side wallet.

Method Description
sign Signs a Bitcoin transaction
broadcast Broadcasts a Bitcoin transaction
send Sends satoshis to an address
rpc 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