This directory contains a series of small examples apps that illustrate how
to code up common use cases for a Wormhole wallet and managing tokens.

## Installation

Install dependencies by running `npm install` in the parent directory.

## Running Examples

You can run each example script by entering its directory and executing `npm start`

## General BCH Functions

- [create-wallet](create-wallet) Create a Wormhole compatible HD Node wallet on
  the BCH testnet. Send test BCH using a testnet faucet (like
  [this one](https://testnet.manu.backend.hamburg/bitcoin-cash-faucet),
  [this one](http://www.wormhole.cash/test/), or
  [this one](https://coinfaucet.eu/en/bch-testnet/))
  to the address saved in the `wallet.json` file generated by this app.
  All other example apps read this `wallet.json` file.

- [check-balance](check-balance) Check the balance of your BCH wallet. This
  displays both BCH information as well as Wormhole token information.

- [send-bch](send-bch) Send BCH to another address. (_Great for sending balances
  back to the testnet faucet._)

- [token-info-from-tx](data-retrieval/token-info-from-tx) Most examples in this
  directory output a TXID. Once the transaction has been stored to the blockchain
  (one confirmation), you can retrieve information on the token using this TXID.
  This is particularly useful for discovering the `propertyId` assigned to a managed
  token or getting information on a crowd-sale token.

## Wormhole Token Functions

- [burn-bch](burn-bch)
  Burn 1 BCH to generate 100 WHC tokens. These WHC tokens
  are needed for creating your own tokens. Before seeing the WHC tokens appear
  in the `check-balance` example, you'll have to wait 4 confirmations on testnet
  and 1000 confirmations (7 days) on mainnet.

  This is just an example, _not intended for real burning!_. One side effect of
  this early example is that it will consume all the BCH in a UTXO. _Be sure
  to use a new wallet with a 1.00001000 tBCH (1 BCH + TX fee). Anything in
  addition to this will be burned._

- [lookup-token](data-retrieval/lookup-token) Lookup token information based on
  the `primaryid` value assigned to it.

- [send-tokens](send-tokens) Send existing tokens or WHC tokens to another address.

- [list-all-tokens](data-retrieval/list-all-tokens) List every token in existence.

### Fixed Tokens

Fixed tokens are created with fixed supply, which can never be expanded or revoked.

- [create-fixed-token](create-fixed-token) - Create a fixed token class and generate
  all the tokens, costs 1 WHC.

### Managed Tokens

Token managers can issue new tokens at any time. And existing tokens can
be revoked.

- [create-managed-token](create-managed-token) Create a managed token class.
  Costs 1 WHC. Creates the class, but no actual tokens. Use
  [token-info-from-tx](data-retrieval/token-info-from-tx) to lookup the
  `primaryId` of your newly created token, to then issue new tokens. Address
  in `create-wallet/wallet.json` becomes the 'Token Manager'.

- [issue-managed-tokens](issue-managed-tokens) Issue new tokens and send them
  to the token manager address. You'll need to wait for 1 confirmation
  before seeing the new tokens with [check-balance](check-balance).

- [change-managed-token-issuer](change-managed-token-issuer) Change the address
  capable of issuing new tokens, the 'Token Manager'.

- [revoke-managed-tokens](revoke-managed-tokens) Revoke existing tokens.

### Crowd Sale

- [create-crowdsale](create-crowdsale) Create and open a new crowdsale. Other
  users send WHC to this address in exchange for a set number of tokens.

- [participate-in-crowdsale](participate-in-crowdsale) Send WHC in exchange for
  tokens from a crowdsale.

- [close-crowdsale](close-crowdsale) Close the crowdsale and issue tokens.

## Additional Data Retrieval Examples

- [balances-hash](data-retrieval/balances-hash)

- [block-transactions](data-retrieval/block-transactions)

- [check-balances-for-id](data-retrieval/check-balances-for-id)

- [check-single-balance](data-retrieval/check-single-balance)

- [check-total-balance](data-retrieval/check-total-balance)

- [current-consensus-hash](data-retrieval/current-consensus-hash)

- [grants](data-retrieval/grants)

- [info](data-retrieval/info)

- [payload](data-retrieval/payload)

- [pending-transactions](data-retrieval/pending-transactions)

- [seed-blocks](data-retrieval/seed-blocks)

- [sto](data-retrieval/sto)
