Addresses are commonly used identifiers that act as a shorthand for who can spend a given output.
Since Bitcoin Cash transactions do not inherently have a concept of accounts with balances, it is not always easy (or even possible) to determine which unspent outputs are spendable by a given person.
However, the standard scripts were designed to provide a straightforward structure that can be used to identify transactions that spendable in similar ways.
In most cases, the address contains all of the information necessary to create a transaction output that is spendable by the owner of the address.
Due to this and their compactness, addresses are the most common way to specify to others how (“where”) they can receive funds.

Raw addresses are rarely used outside of scripts, though, as they lack context and redundancy.
These encodings include checksums as well as information about the type of address being encoded.
CashAddr was created after Base58Check (also referred to as legacy encoding) to avoid conflicts with pre-existing BTC address.

## Pay to Public Key Hash (P2PKH) Addresses

P2PKH addresses encode the hash of the public key that is locking the output (i.e. RIPEMD-160(SHA-256(publicKey))).
Mainnet P2PKH addresses always start with 1 in Base58Check encoding and q in CashAddr encoding:

Base58Check:  1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa


The following diagram show the full creation process for a P2PKH address:

## Pay to Script Hash (P2SH) Addresses

P2SH addresses encode the redeem script hash (i.e. RIPEMD-160(redeemScript)).
Mainnet P2SH addresses always start with 3 in Base58Check encoding and p in CashAddr encoding.

Base58Check:  3N5i3Vs9UMyjYbBCFNQqU3ybSuDepX7oT3