Were you wondering how it is possible to delegate ADA coins to the pool of your choice and be able to spend them at the same time? We will explain it to you.
Payment Addresses and Staking
You can have multiple addresses with ADA coins in your wallet. If you create a staking certificate and submit it to the Cardano blockchain, all coins are delegated to your chosen pool. This also applies to newly created addresses to which you send ADA from the exchange, for example. As soon as the next snapshot occurs in the Cardano network, the new ADA coins will also be actively used in staking.
In order to achieve the possibilities described above, it was necessary to separate the movements of ADA coins and their delegation. Cardano has a unique address structure and distinguishes between payment addresses and stake addresses (sometimes called a reward address). Payment addresses are intended to hold funds that can be spent. Stake addresses define if and how funds from payment addresses are used in staking.
In the image below you can see the Shelley payment address, which consists of a part for funds (payment credentials) and a reference to the stake address (staking key).
ADA coins always belong to a payment address (never a stake address). Each payment address can optionally refer to a stake address. The staking rights of all ADA coins at the payment address are associated with the stake address.
Funds at the payment address represent staking rights. The stake address defines how this right will be handled. Delegation of ADA coins to a pool is done in two steps. Firstly, the payment address must refer to the stake address. Then the stake address must be delegated to the pool.
In the wallet, the user chooses the pool to which he wants to delegate and confirms the transaction, which is sent to the blockchain. A staking certificate is created in the background, which delegates coins to the chosen pool through the stake address. During the delegation process, a reward account is created in which the system accumulates staking rewards.
Note that the stake address is registered, not the payment address(es). Therefore, it is possible to perform a single registration for all payment addresses created in the future. Also, note that funds are still on payment addresses (fully controlled by the owner) and can be spent.
You can easily distinguish addresses from each other by the prefix. Payment addresses have the prefix “addr”. Stake addresses have the prefix “stake”. Let's add that the Byron addresses had no prefix and were encoded by Base58. The Shelley payment addresses and stake addresses are both encoded by bech32.
Stake Address Reference
There are three options for the content that can be present in the stake address reference of the Shelley payment address. Based on the content of the reference, we can divide the Shelley payment addresses into several types.
The reference (stake address reference) can contain a so-called Value, i.e. just the hash of a verification key (staking key) or validator script. These addresses are called base addresses.
Let's add that instead of the staking key, the reference can refer to the script hash (that is, the hash of the script that will be used for spending).
The staking key is used to control staking rights for all associated payment addresses. The staking key is usually owned by the same entity that owns the payment addresses, but this is not always the case. It is possible that someone other than the owner of the payment address has control over the staking rights (for example, a smart contract). These addresses are called hybrid ones. Notice that a different key is required to spend funds on payment addresses.
Further, the reference can contain a so-called Pointer. These addresses are called pointer addresses.
In this case, the staking key is referenced indirectly via a pointer. The reference points to the place in the blockchain where a staking certificate is stored. The staking key is stored in the certificate. The pointer occupies a smaller size than the staking key. Only 3 numbers are needed to find it: slot index, transaction index within the block, and certificate index within the transaction.
Finally, the reference might not contain anything, just the value called Null. These addresses are called enterprise addresses.
In this case, funds in payment addresses cannot be associated with staking rights. In other words, ADA coins cannot be used for staking. This option is suitable, for example, for exchanges or other organizations that want to make it clear that they will not stake ADA coins.
There is one more type of address you should know about. This is not based on the content in the reference. It is a rewards account address.
Reward addresses are hashes of the public staking key of the address. They are used to distribute staking rewards. Unlike payment addresses, which are based on the UTxO model, rewards accounts are based on an account-based model. Regular payment of rewards will only increase the account balance. As soon as the user withdraws the reward through a transaction, a new UTxO will be created from the balance.
Cardano wallets work with addresses very simply, as they only need to look at the payment credentials to find out which ones belong to the user. Once the payment addresses are identified, it is easy to read the associated stake addresses and find out all the necessary staking information.