<p>You have 500 ADA rewards at that stake address. First you need to withdraw the 500 ADA, only after that you should deregister your stake key.
You cannot send funds to a stake address, so you cannot use the stake-address in a <code>--tx-out</code> or <code>--change-address</code> line. And if you want to send all the funds to a single address, you just use <code>--change-address</code>, without any <code>--tx-out</code> line. You need to have your payment address in the <code>payment.addr</code> file, but I believe you already have it, since you are signing with <code>payment.skey</code>.</p>
<pre><code>cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --withdrawal &quot;$(stake.addr)+500000000&quot; \
    --change-address $(cat payment.addr) \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2
</code></pre>
<p>Then sign it and submit it with the commands you had in your message.
After the transactions completes, you can do another transaction to deregister the stake key, just like you did before. You will need to use a different UTxO as input for the new transaction (because the one from the first transaction will be consumed). You will be able to use the output of your previous transaction.</p>
<pre><code>cardano-cli transaction build \
    --tx-in &lt;new UTxO&gt;#0 \
    --change-address $(cat payment.addr) \
    --certificate-file stake-deregistration.cert \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2
</code></pre>
<p>You can sign and submit this transaction with the same commands as before.</p>
<p>It might work to withdraw the 500 ADA and deregister in a single transaction, but I did not test it, so I cannot recommend it. I will test it on testnet when I have the chance to do it (but not very soon). To test it, I will add the <code>--certificate-file stake-deregistration.cert </code> line after the <code>--change-address $(cat payment.addr)</code> line in the first transaction.
I am not sure if you are able to deregister the stake address without first withdrawing the rewards. This is probably the reason why you have that error.</p>

CC BY-SA 4.0
2022-11-12T06:35:14.653Z
Thank you so much it worked. Really appreciate. I think Cardano should at least create a section for this it's very important.
Raphaël Etang-Salé
CC BY-SA 4.0
2022-11-12T05:55:30.530Z
2022-11-12T05:55:30.530Z
George - APEX Stake Pool
<p>I'm trying to get back my funds from my <code>stake.addr</code> from Cardano but I have this error message:</p>
<pre><code>Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [DelegsFailure (DelplFailure (DelegFailure (StakeKeyNonZeroAccountBalanceDELEG (Just (Coin 500000000)))))])
</code></pre>
<p>This error message appears when I run these scripts below:</p>
<pre><code>cardano-cli stake-address deregistration-certificate \
--stake-verification-key-file stake.vkey \
--out-file stake-deregistration.cert

cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --tx-out $(cat stake.addr)+500000000 \
    --change-address $(cat stake.addr) \
    --mainnet  \
    --out-file tx.raw \
    --certificate-file stake-deregistration.cert \
    --witness-override 2

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet
</code></pre>
<p>I can see I have the funds on the explorer <a href="https://cardanoscan.io/stakekey/084cf0adf9fe75b3e479e6c837676bb85016ae891c624cf59004a009" rel="nofollow noreferrer">here</a>. Thank you if you can help me.</p>

<cardano-cli><cardano-node><ada>
Transaction error from staking account on cardano
# Transaction error from staking account on cardano

(Asked by: username_0 on 2022-11-12)

I'm trying to get back my funds from my stake.addr from Cardano but I have this error message:
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [DelegsFailure (DelplFailure (DelegFailure (StakeKeyNonZeroAccountBalanceDELEG (Just (Coin 500000000)))))])

This error message appears when I run these scripts below:
cardano-cli stake-address deregistration-certificate \
--stake-verification-key-file stake.vkey \
--out-file stake-deregistration.cert

cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --tx-out $(cat stake.addr)+500000000 \
    --change-address $(cat stake.addr) \
    --mainnet  \
    --out-file tx.raw \
    --certificate-file stake-deregistration.cert \
    --witness-override 2

cardano-cli transaction sign \
    --tx-body-file tx.raw \
    --signing-key-file payment.skey \
    --signing-key-file stake.skey \
    --mainnet \
    --out-file tx.signed

cardano-cli transaction submit \
    --tx-file tx.signed \
    --mainnet

I can see I have the funds on the explorer here. Thank you if you can help me.

**Tags:** cardano-cli, cardano-node, ada

---

## 1 answers

### Answer by username_1 on 2022-11-12. Score: 2 | Accepted answer

You have 500 ADA rewards at that stake address. First you need to withdraw the 500 ADA, only after that you should deregister your stake key.
You cannot send funds to a stake address, so you cannot use the stake-address in a --tx-out or --change-address line. And if you want to send all the funds to a single address, you just use --change-address, without any --tx-out line. You need to have your payment address in the payment.addr file, but I believe you already have it, since you are signing with payment.skey.
cardano-cli transaction build \
    --tx-in 75e262eb49ba1237b1ee00a4854935d67bd05988baed5472a7ff97b49551d386#0 \
    --withdrawal "$(stake.addr)+500000000" \
    --change-address $(cat payment.addr) \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2

Then sign it and submit it with the commands you had in your message.
After the transactions completes, you can do another transaction to deregister the stake key, just like you did before. You will need to use a different UTxO as input for the new transaction (because the one from the first transaction will be consumed). You will be able to use the output of your previous transaction.
cardano-cli transaction build \
    --tx-in #0 \
    --change-address $(cat payment.addr) \
    --certificate-file stake-deregistration.cert \
    --mainnet  \
    --out-file tx.raw \
    --witness-override 2

You can sign and submit this transaction with the same commands as before.
It might work to withdraw the 500 ADA and deregister in a single transaction, but I did not test it, so I cannot recommend it. I will test it on testnet when I have the chance to do it (but not very soon). To test it, I will add the --certificate-file stake-deregistration.cert  line after the --change-address $(cat payment.addr) line in the first transaction.
I am not sure if you are able to deregister the stake address without first withdrawing the rewards. This is probably the reason why you have that error.

> **Comments:**
> **username_0**: Thank you so much it worked. Really appreciate. I think Cardano should at least create a section for this it's very important.  

---

