How to get rid of the “Public key cannot be exposed” error
Activate and reveal your Tezos test key to make it work with your dapp
I started writing tutorials about Tezos development because I wanted more self-taught and/or beginner developers like me to join this amazing ecosystem. Since the beginning of 2020, it looks like this is happening and new developers try to teach themselves how to write smart contracts and dapps for the Tezos blockchain 😊
This also creates a huge amount of questions. Among them, I have seen the same one multiple times in one single month and I decided to write a short tutorial to explain how to solve it.
A lot of developers creating dapps for Tezos get a test key from faucet.tzalpha.net. The front page of the website mentions:
Faucet ꜩ can be used on all testnets and zeronet
So you get your key, you save it in TezBridge, you try to use it and you get the following error in the console: Public key cannot be exposed ⛔️. In most cases, this happens because your key hasn’t been revealed on the network you are using. It seems like the problem comes from TezBridge, but it has nothing to do with it.
If you want to make sure your key is revealed, you can go to tzkt.io, click on the three dots at the top-right corner of the page, select the test network you are using and search for your key. You will probably see the screen below:
If that’s the case, you can be sure the error message comes from the fact that the key hasn’t been revealed. But fear not, it will only take you 2 minutes to solve this little mishap and get back to developing your dapp!
We are going to use SmartPy faucet importer. This is an incredible tool that will help you reveal your account in no time. Go to the website and you should see something like this:
Now copy the whole JSON object you got from the faucet on tzalpha and paste it in the textarea of the second step:
Next, click on Compute your private key. If everything works fine, you should get the following information in the Return box at the bottom of the page:
If everything works fine, you should now have your private key, public key and public key hash. Now let’s continue and activate the account!
In the fourth step, select the network where you want to activate your key. If you want to test your dapp, it is recommended to use Carthagenet, as more and more nodes remove their support for Babylonnet.
Next step, click on the Activate account button. After a few seconds, check the Result box at the bottom:
Now that the account has been activated, it is time for the last step: the revealing!
Click on the Reveal account button:
If you see “Revelation of account OK” in the Return box, it worked. And that’s it, your account has been revealed and is ready to be used in your dapp 🥳
You can go back to tzkt.io and check if the account exists now:
Let me know in the comments if that worked for you or if you experience other errors!
If you liked this tutorial, consider sending some tezzies to tz1SjrNeUE4zyPGSZpogDZd5tvryixNDsD2v and don’t hesitate to leave your opinions or suggestions!