<p>The beech32 representation is a bit tricky, but you can do it like this:</p>
<pre><code>const stakeKey = StakeCredential.from_bytes(from_hex('7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc'));
const networkId = 1; // testnet = 1, mainnet = 0
const beech32StakeKey = RewardAddress.new(networkId, stakeKey).to_address().to_bech32();
console.log(beech32StakeKey);
</code></pre>
<p>Hope this helps. The &quot;from_hex&quot; function is just a simple js function to convert the Hex string into an UInt8Array that is needed for the from_bytes function of StakeCredentials.</p>

CC BY-SA 4.0
2022-03-03T20:58:57.387Z
2022-03-03T20:58:57.387Z
Jan B.
<p>I have this Stake Key:</p>
<p><a href="https://testnet.cardanoscan.io/stakekey/7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc?tab=stakehistory" rel="nofollow noreferrer">https://testnet.cardanoscan.io/stakekey/7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc?tab=stakehistory</a></p>
<p>I want to convert from <code>7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc</code> to <code>stake_test1upmz9drprv25g8n7zh96z28lnxddwgug46ex0twxuuxvn0qp3cptz</code> format.</p>
<p>How do I do it using this library <a href="https://github.com/Emurgo/cardano-serialization-lib" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib</a>?</p>
<p>Thanks</p>

<staking><address><cardano-serialization-lib><cardano-address><public-key>
How to convert a Stake Key Address from hash to BECH32?
# How to convert a Stake Key Address from hash to BECH32?

(Asked by: username_0 on 2022-03-03)

I have this Stake Key:

<https://testnet.cardanoscan.io/stakekey/7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc?tab=stakehistory>

I want to convert from `7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc` to `stake_test1upmz9drprv25g8n7zh96z28lnxddwgug46ex0twxuuxvn0qp3cptz` format.

How do I do it using this library <https://github.com/Emurgo/cardano-serialization-lib>?

Thanks

**Tags:** staking, address, cardano-serialization-lib, cardano-address, public-key

---

## 1 answers

### Answer by username_1 on 2022-03-03. Score: 6 | Accepted answer

The beech32 representation is a bit tricky, but you can do it like this:
const stakeKey = StakeCredential.from_bytes(from_hex('7622b4611b15441e7e15cba128ff999ad72388aeb267adc6e70cc9bc'));
const networkId = 1; // testnet = 1, mainnet = 0
const beech32StakeKey = RewardAddress.new(networkId, stakeKey).to_address().to_bech32();
console.log(beech32StakeKey);

Hope this helps. The "from_hex" function is just a simple js function to convert the Hex string into an UInt8Array that is needed for the from_bytes function of StakeCredentials.


---

