Skip to content
DonateБГ

Keys and addresses

Address

The bitcoin address format is a short, checksummed code for a locking script. Compare the five types, 1, 3, bc1q and bc1p, and see how each is built.

By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.

A Bitcoin address is a short code that stands for a locking script. Most addresses carry a 20-byte hash of a public key or a script, wrapped in a type prefix and a checksum. You give an address to someone so they can pay you. Their wallet turns it back into the locking script that puts the coins under your control.

Addresses are a convenience for people. They never appear inside a transaction or a block, because the chain stores the locking script itself. The address matters only when you send or receive, and it is the form you copy, paste and read aloud. For the short definition, see address.

Why do we use addresses instead of scripts?

A locking script is precise, but it is awkward to share. This P2PKH script is 25 bytes, or 50 hex digits:

76a91404a621a724b8e064809d8fb22a65c2d37d01a01888ac

The address for the same script is 33 characters, and it reads as one word:

1RainRzqJtJxHTngafpCejDLfYq2y4KBc

Both lock coins to the same 20-byte hash. The address adds three things on top. It has a checksum, which catches almost every typing mistake. It uses Base58 for most types, which leaves out 0, O, I and l so that characters are harder to confuse. And its first character tells you which kind of lock it stands for.

What are the five address types?

Each type matches one standard locking script. Only the common scripts have their own address format. Scripts such as bare multisig have no address, so a payer must send to them as raw script.

Starts with Type Encoding Length Locking script
1 Pay to public key hash (P2PKH) Base58Check 33 or 34 P2PKH
3 Pay to script hash (P2SH) Base58Check 34 P2SH
bc1q Pay to witness public key hash (P2WPKH) Bech32 42 P2WPKH
bc1q Pay to witness script hash (P2WSH) Bech32 62 P2WSH
bc1p Pay to Taproot (P2TR) Bech32m 62 P2TR

Every address in this page is an example. The P2TR example is one whose private key is published, so anyone can spend coins sent to it. Do not send coins to any of them.

How is a P2PKH address made?

A 1 address holds a public key hash and matches a P2PKH script. This example is 14ZKbhYsSLms6mh6t2QnhAqHApUNfrCJFi. Its locking script is:

OP_DUP
OP_HASH160
OP_PUSHBYTES_20
27053692a16ee881fd9fc0478f86e0c8721bd2ee
OP_EQUALVERIFY
OP_CHECKSIG

In hex, that is 76a91427053692a16ee881fd9fc0478f86e0c8721bd2ee88ac. To build the address, you run four steps.

  1. Take the 20-byte public key hash, which is the HASH160 of the public key.
  2. Put a version byte of 00 in front. This forces the first character to be 1.
  3. Add a 4-byte checksum. It is the first 4 bytes of the double SHA-256 of steps 1 and 2 together, here 3d6fc001.
  4. Base58 encode the 25 bytes, which gives the address.
Four steps turn a 20-byte public key hash into a P2PKH address: add a version byte, add a checksum, then Base58 encode. 1. public key hash, 20 bytes 27053692a16ee881fd9f c0478f86e0c8721bd2ee add version byte 00 2. version byte, then the hash 00 27053692a16ee881fd9f c0478f86e0c8721bd2ee add checksum 3. 4-byte checksum appended 00 27053692a16ee881fd9f c0478f86e0c8721bd2ee 3d6fc001 Base58 encode 4. the P2PKH address 14ZKbhYsSLms6mh6t 2QnhAqHApUNfrCJFi
The example from this section. Its private key is unknown, so do not send coins to it.

Each leading 00 byte in the raw data becomes a 1 in Base58. That is why the version byte gives a 1 prefix.

What is a P2SH address?

A 3 address holds a script hash and matches a P2SH script. The example 3Pxiq6fzWxbiS52L7xhWEtLcGuAkDoqdRY carries the 20-byte hash f44b2743c5c24127ee03674d07941fa04cf52c97. That hash is the HASH160 of a redeem script, not of a public key. The locking script is a914f44b2743c5c24127ee03674d07941fa04cf52c9787.

The version byte here is 05, and the checksum is 3ffd9bbf. P2SH was introduced in 2012 by BIP 16. It lets a payer lock coins to any script, such as a multisig rule, while sending to a short address. The spender reveals the redeem script when they spend.

What are bc1q addresses?

The bc1q addresses use Bech32, defined in BIP 173. Bech32 is all lowercase, uses a 32-character alphabet, and carries a checksum at the end. The character after the 1 separator is the witness version. A q means version 0, and a p means version 1.

There are two bc1q types, and their length tells them apart.

  • P2WPKH, 42 characters. The example bc1q8vds4x58zhan6v820yu7zewslkwqsv5puxp5u3 encodes the 20-byte hash 3b1b0a9a8715fb3d30ea7939e165d0fd9c083281. Its locking script is 0014 followed by that hash.
  • P2WSH, 62 characters. The example bc1qcd3mpagdmpnkmvknmtp2w89h69c39kwtvct9v6a5mt7wpjqr35rqfvqmnj encodes the 32-byte SHA-256 of a witness script. Its locking script is 0020 followed by that hash.

SegWit addresses went live with the SegWit upgrade at block 481,824 in August 2017. Spending from a SegWit output costs less in fees, because the signature sits in the witness, which counts at a discount.

What are bc1p addresses?

A bc1p address matches a P2TR script, the Taproot output. It is encoded with Bech32m, which BIP 350 defines as a small fix to Bech32. Taproot addresses are 62 characters long, like P2WSH.

This example comes from BIP 86, so its private key is public: bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr. Its locking script is:

5120a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c

The 51 is OP_1, the witness version. The 20 is a push of 32 bytes, and those 32 bytes are the x-only output key. This is not a plain public key. It is a key already tweaked by the Taproot rules, so the address does not reveal the key you started from. Taproot activated at block 709,632 in November 2021. See Taproot for how the output key is made.

How does a wallet read an address?

When you pay an address, your wallet does three things. It decodes the address and checks the checksum. It reads the prefix or the witness version to find the type. Then it builds the matching locking script from the hash inside. A 1 address becomes a P2PKH script, and a bc1p address becomes a P2TR script.

The wallet never needs your public key, only the hash or key inside the address. That is why a payer can lock coins to you before you have ever used the address.

Wallets pick the type for you. Many current wallets default to bc1 addresses, and most can still show or pay a legacy 1 or 3 address. The address type affects the fee you pay when you spend the coins later, so check it before you copy an address. See wallets for how wallets choose.

Are testnet addresses different?

Yes. Testnet has its own prefixes, so a testnet address cannot be paid on mainnet by mistake. A testnet P2PKH address starts with m or n (version byte 6f). A testnet P2SH address starts with 2 (version byte c4). Bech32 testnet addresses use the prefix tb1 in place of bc1.

Is an address the same as a public key?

Not quite. An address encodes a hash of a public key in most cases, and a script hash or a Taproot output key in others. It is better to think of it as an instruction. It tells the wallet which type of lock to place and what data to put inside it.

This matters when you build transactions by hand. The raw transaction carries the locking script, so you never need an address to make one. You need the address only to write down a destination for a person or a wallet. For the key behind an address, read public key and public key hash.

Where can you see an address on the chain?

Our explorer has a page for every address on the chain, at /address/ followed by the address. The page lists the outputs locked to that address and the transactions that spent them. Use it to check a payment before you rely on it.

What should you remember about addresses?

  • An address is a short, checksummed encoding of a locking script.
  • The first character or the witness version shows the type.
  • Only the locking script goes on the chain, never the address.
  • Keep the example addresses on this page for learning. Never send coins to them.

Next, read signature to see how a key proves it can spend the lock that an address stands for.

In this section: Keys and addresses

All of Bitcoin from zero

Something look wrong? Tell us