Overview
Staking is a process of delegating Cardano (ADA) tokens to a pool. All delegators in the pool may then share in the risk and reward of the validating pool.
All Cardano wallets can be associated with both payment keys and staking keys without any additional configuration. Cardano wallets can also create delegation certificates for associating a staking key with a staking pool. Delegating your stake with a certificate requires a blockchain transaction, which incurs transaction fees. A small deposit is also required the first time any staking key is used to delegate tokens. Submitting a new delegation certificate for a previously used staking key only requires a transaction fee and no deposit.
Delegating ADA automatically creates an address in your wallet from the payment key and staking key. All funds held at the address are automatically delegated to the pool once the delegation transaction is complete. At the beginning of each epoch, the Cardano protocol records the amount of ADA tokens held at the delegated address and includes them in the total staking amount. ADA may be sent to or from the address at any time. Any difference in the balance of the address is recorded at the beginning of the next epoch and accounted for over the course of the staking cycle.
Reward distribution
An epoch is a period of time used for calculating staking rewards. Each epoch lasts about five days. Tokens may be transferred or delegated to a different staking pool at any time. At the end of an epoch, a record of all staking pools is recorded. The recorded staking amounts are then applied after a one-epoch delay, calculated in the following epoch, and then distributed in the epoch after.
Effectively, rewards are distributed after three full epochs have passed and staking pool balances have been recorded. In practice, this occurs between 15 and 20 days after an initial stake. Staked tokens are automatically included in subsequent epochs until they are unstaked.
Staking ADA in Fireblocks
To set up Cardano staking from Fireblocks, confirm you have completed all prerequisites for staking. Then, follow the steps below to stake ADA from your Fireblocks workspace. A reference ADA staking Python Command-Line Interface (CLI) is described below.
Configuring the staking environment
- Create an API key in Blockfrost. Blockfrost provides API access to the Cardano blockchain ecosystem. The CLI uses Blockfrost for submitting staking transactions to the network. You can use Blockfrost's free service or any other tier.
- Copy the Blockfrost API key (choose either testnet or Mainnet).
- Create a new, dedicated vault account for staking with an ADA asset wallet. The account name should be ADA Staking.
- Deposit the ADA tokens you would like to stake to the new vault account. Note that no other transactions should be done with this vault prior to the start of staking.
- Download and open the Fireblocks ADA staking CLI from Github: https://github.com/fireblocks/ada_staking
- Install the Python requirements including the Blockfrost SDK and other packages by running:
pip3 install -r requirements.txt
- Update the staking.py file with the following parameters:
- apiKey: Your Fireblocks API Key.
- apiSecret: This is your private RSA key. Learn more about retrieving your RSA key by creating a CSR file.
Executing staking scripts
Staking on Cardano requires two main phases:
- Create a staking certificate and register it on the blockchain.
- Delegate your staking wallet to a staking pool.
All funds in the dedicated vault account are automatically delegated, including new deposits to this account after the delegation script has been executed. Funds can be withdrawn and transferred from the account without any prior unlocking or staking action. Rewards are shown and available in the balance only after calling a withdraw-rewards command.
Staking and unstaking commands are part of the reference Python CLI provided by Fireblocks to help interact with Fireblocks APIs and with the Cardano blockchain (via Blockfrost).
Learn more about script parameter definitions.
Note
In the example commands below, use your own values for parameters.
Creating and registering a staking certificate
Create an ADA staking certificate and register it to the blockchain by calling the register function using the command below. This will also lock a small deposit of two ADA until the account is deregistered.
./staking.py -v <vault account id> -k <blockfrost api key> -n mainnet register
Delegating ADA to a staking pool
This call should only be performed after a register call is successfully completed. Stake the desired assets with the registered staking certificate by calling the delegate function using the following command:
./staking.py -v <vault account id> -k <blockfrost api key> -n mainnet
delegate -p <stake pool id>
Unstaking
Use the command below only if you want to remove the delegation and stop staking entirely. This will also unlock and release the initial two ADA deposit made during the register call.
Note
Unstaking will automatically withdraw all rewards to the payment key wallet. There is no need to withdraw the rewards before the unstaking operation.
Funds in the staked account are always available for transfers and do not require explicit withdrawal or unstaking.
./staking.py -v <vault account id> -k <blockfrost api key> -n mainnet deregister
Querying rewards
Use the command below to view the currently credited rewards, which have not been withdrawn:
./staking.py -v <vault account id> -k <blockfrost api key> -n mainnet query-rewards
Withdrawing rewards
The command below withdraws all available rewards. To withdraw a specific amount include -I <amount> with the specific value.
./staking.py -v <vault account id> -k <blockfrost api key> -n mainnet withdraw-rewards
Script parameters
Parameter | Definition |
v |
The dedicated Fireblocks vault account ID which contains the ADA wallet that you created in step 3 of Configuring the staking environment. The vault account ID can be obtained via the Fireblocks API or the Fireblocks console. |
k | The Blockfrost API key required for submitting the staking transactions to the network via Blockfrost. This parameter is required in all calls. |
n | Network (mainnet or testnet). This parameter is required in all calls |
p |
The stake pool ID identifies where funds are delegated and is provided by the staking partner. This parameter is only relevant for the delegate call. |
l |
Optional. This sets a specific withdrawal amount less than the total rewards available. If not set, all rewards are withdrawn by default. This parameter is only relevant for the withdraw-rewards call. |
register | Registration of a staking certificate is required before delegating. |
delegate | Delegation of a vault account to a staking pool |
deregister | Deregister the staking certificate to stop staking entirely |
query-rewards | Print the accumulated account rewards. Only rewards that aren't withdrawn will be shown. |
withdraw-rewards | Withdraw staking rewards to include them in the ADA balance of the dedicated vault account and make them available for transfers. |