Constructing and inspecting a Shelley payment address Addresses are used as locations where assets live. The address determines the rights needed to spend assets at the address: in particular holding some signing key or being able to satisfy the conditions of a script.
The address type is subtly from the ledger era in which each address type is valid: while Byron addresses are the only choice in the Byron era, the Shelley era and all subsequent eras support both Byron and Shelley addresses. The Address type param only says the type of the address (either Byron or Shelley). The AddressInEra type connects the address type with the era in which it is supported.
There are currently two types of address:
ShelleyAddr, Shelley addresses, which use the type tag ShelleyAddr. Notably, Shelley addresses support scripts and stake delegation.
data Address addrtype where
-- | Byron addresses were the only supported address type in the original
-- Byron era.
--
ByronAddress
:: Byron.Address
-> Address ByronAddr
-- | Shelley addresses allow delegation. Shelley addresses were introduced
-- in Shelley era and are thus supported from the Shelley era onwards
--
ShelleyAddress
:: Shelley.Network
-> Shelley.PaymentCredential StandardCrypto
-> Shelley.StakeReference StandardCrypto
-> Address ShelleyAddr
-- Note that the two ledger credential types here are parametrised by
-- the era, but in fact this is a phantom type parameter and they are
-- the same for all eras. See 'toShelleyAddr' below.
deriving instance Eq (Address addrtype)
deriving instance Ord (Address addrtype)
deriving instance Show (Address addrtype)
ByronAddress ∷ Address → Address ByronAddr ShelleyAddress ∷ Network → PaymentCredential StandardCrypto → StakeReference StandardCrypto → Address ShelleyAddr
26-35 alphanumeric characters that is used to receive bitcoin. There are several address formats:
a Bech32m address, the most recent. supports
- multi-key transactions
- more advanced scripting
- increased privacy example: `bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e
`bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e`
Also known as SegWit or Bech32 address.
Note that the address start `bc1q` `bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq`
A pay-to-script-hash (P2SH), or script address, can have additional rules and functionality attached to the address. Script addresses are commonly used for multi-sig addresses, which can specify that signatures from several keys are required to authorize the transaction.
Note that the address start `3` `3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy`
Pay to Public Key Hash, P2PKH. Legacy addresses start with `1`
Note that address starts with `1` `1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2`
And address is a sequence of bytes that confroms to a particular format. In cardano Bech32 and are Bech58 encoding used to encode addresses. these encoding have to be distinguishable from the byte sequence that they encode.
A payment address is sha256 hash followd by another sha256 hash of the utxo output’s validator script. this correspond to BC pay-to-witness-script-hash
Defines a set of common prefixes, so called human readable of Bech32.
Many tools used within the Cardano eco-system are manipulating binary data. Binary data are typically encoded as hexadecimal text strings when shown in a user interface (might it be a console, a url or a structured document from a server). From the user perspective, it can be difficult to distinguish between various encoded data. From the tools developer perspective, it can also be difficult to validate inputs based only on raw bytes (in particular when encoded data often have the same length).
Therefore, we can leverage bech32 for binary data encoding, with a set of common prefixes that can be used across tools and software to disambiguate payloads.
By convention, Shelley and stake address are encoded int Bech32.
- cardaono does not impose no length limit.
- prefixes are defined in CIP0005;
- the most common prefix is addr, representing an address in main net
- by convention Byron address are encoded in Base58
- Exmaples
- Shelley addr1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5eg0yu80w
- Byron 37btjrVyb4KDXBNC4haBVPCrro8AQPHwvCMp3RFhhSVWwfFmZ6wwzSK6JK1hY6wHNmtrpTf1kdbva8TCneM2YsiXT7mrzT21EacHnPpz5YyUdj64na
Addresses are compramised of two parts
- header, 1 byte
- p`ayload, several bytes
The payload length varies, depending on the header
there are currently 8 types of shelley addresses outlined in CIP19
Header type(ttttt…) | Payment Part | Delegation Part |
---|---|---|
0000.... | PaymenlltKeyHash | StakeKeyHash |
0001.... | ScriptHash | StakeKeyHash |
0010.... | PaymentKeyHash | ScriptHash |
0011.... | ScriptHash | ScriptHash |
0100.... | PaymentKeyHash | Pointer |
0101.... | ScriptHash | Pointer |
0110.... | PaymentKeyHash | 0 |
0111.... | ScriptHash | 0 |
refers to blake2b-224 hash digests of Ed25519
refers to blake2b-224 hash digests of Ed25519
refer to blake2b-224 hash digests of serialized monetary scripts.
- the first par of Shelley address indicates ownership of the funds associated with the address
- in order to spend from address, one must provide witness attesting the address can be spent
- in case of PublicHash it means provide a signature of the transaction body made with the signing key corresponding to the hashed public key
the second part fo the Shelley address indicate the owner of the stake tights associated with the address, called the delegation part
- most often the payment part & the delegation part owned by the same party
- mangled address or hybrid address when payment part and delegation part are manged by different parties
In an address, a chain pointer refers to point of the chain containing a stake key registration certificate. A point is defined by 3 coordinates
- absolute slot number
- transaction index (within that slot)
- a (delegation) certificate index (within that transaction)
like Shelley-Addresses, stake addresses start with a single header byte identifying their type and the network, followed by 28 bytes of payload identifying either a stake key hash or a script hash.
Header type(ttttt…) | Stake Reference |
---|---|
1110.... | StakeKeyHash |
1111.... | ScriptHash |