Obtaining Identity Keys from the Browser


How do I my reveal my private owner and private payment keys in the Blockstack Browser?

In the CLI I can do this through ‘sudo blockstack wallet’. Is there a way to display wallet information for an .id through the Browser interface?

I am asking because I would like to amend my config.json file for Subdomain Registrar purposes to allow for sponsored names to be registered against a (domain)name that has been registered through the Browser.

Not from the Browser, but I think @aaron has a way for turning your 12-word phrase into your owner private key on the command-line, with node.js. I’ll let him answer.

1 Like

Thanks @jude for that

The “trick” I use to get the identity key out of the browser is to open the javascript console and enter the following:

var ix = 0
var reduxState = JSON.parse(localStorage.redux)
var state = reduxState.committedState[reduxState.currentStateIndex]
// get the 0th identity address
// get the 0th identity key
state.state.account.identityAccount.keypairs[ix].key + '01'

That gives you the ownerKey of the 0th-index account in the browser. To get a different index, use a different value for ix.

To get a payment key, I always just generate a new one for a subdomain registrar. There’s many different ways to generate a private key and bitcoin address, but I usually just use node and bitcoinjs-lib. So, from a directory with bitcoinjs installed (just create a new directory and run npm install bitcoinjs-lib), run node and then these commands will make a bitcoin address and private key string:

var btc = require('bitcoinjs-lib')
var paymentPair = btc.ECPair.makeRandom()
var paymentAddress = paymentPair.getAddress()
var paymentKey = paymentPair.d.toHex() + '01'

To fund that paymentKey, you can just send bitcoin to the paymentAddress.


@aaron Will there be a way to reveal these through the Blockstack Browser at some point? I am asking because it would make it a lot easier to reveal keys for the purpose of running a Subdomain Registrar. Thank you.

1 Like

That’s a good potential feature — you can add it as feature-request issue on our browser repo: https://github.com/blockstack/blockstack-browser/issues/new

1 Like

Added here: https://github.com/blockstack/blockstack-browser/issues/1261

@aaron when running this in Google Chrome Console while having the Blockstack Browser open (in Windows 10) I get the following response:

// get the 0th identity address
// get the 0th identity key
state.state.account.identityAccount.keypairs[ix].key + ‘01’

VM151:1 Uncaught TypeError: Cannot read property ‘state’ of undefined
at :1:7
(anonymous) @ VM151:1

Edit: have tried this in the Blockstack Browser App and browser.blockstack.org both in Chrome. Getting the same error message.

@aaron generating the payment key with Node works great, thank you.

Hi, we were able to do this in a slightly different way.

@blockpac can you post how you did this? (I have the same need, as well :slight_smile: )

@chris-asl, have you tried using the experimental Blockstack CLI? It works quite well and is easy to use if you need your owner and payment keys. I did a video where I go over the install (it was more for the Stacks Testnet, but I covered how to install the new CLI after I talked about blockstack.js) and then you can use the following command:

blockstack-cli make-keychain [“12 word mnemonic phrase”]

Make sure you wrap the 12 word phrase in “quotes” otherwise it’ll come back with the wrong ID address and keys.

You can get the CLI here.

And here’s the link to the install video.

Let me know if this works or if you need any help.

1 Like

Thank you very much for the helpful video @Kitsana!

I was able to set it up, with an extra step in the end.
After npm install in the cli-blockstack directory, I had to run npm link in order to get the CLI as an executable.

From that point, I was able to run blockstack-cli, otherwise I was getting command not found errors from my shell.

Awesome! Glad it worked for you @chris-asl.

Hi @chris-asl

Running the following commands in Chrome’s developer console (while on your Blockstack Browser’s Identity page) should return the information you need:

var ix = 0
var reduxState = JSON.parse(localStorage.redux)
var state = reduxState.computedStates[reduxState.currentStateIndex]
state.state.account.identityAccount.keypairs[ix].key + ‘01’

Opening the console and running this worked for me at https://browser.blockstack.org.

To get the owner private key:

var privKeyWith01 = JSON.parse(localStorage.getItem('redux')).account.identityAccount.keypairs[0].key + '01'

Then to import this to another wallet you can get the WIF (wallet import format) like this:


1 Like

I’m trying to get my privKey from this method but I’m getting “undefined” after

var privKeyWith01 = JSON.parse(localStorage.getItem('redux')).account.identityAccount.keypairs[0].key + '01'

blockstack.loadUserData().appPrivateKey + '01'

getting a

Uncaught ReferenceError: blockstack is not defined at <anonymous>:1:1

I’m assuming I should be running this in http://browser.blockstack.org, correct?

Sorry I think I misunderstood, but that code is running in an application, and if you are running from dev tools you need blockstack.js in the global scope.

I am not sure how to do it from the blockstack browser if you are trying to get the private key for your Bitcoin wallet. It might not be possible for security reasons.