come0x
March 8, 2022, 1:25am
#1
I have a private key from a phantom wallet (not the seed phrase). How do I convert it to the format the CLI expects? (array of numbers)
From Private Key from phantom = kahu3h1988178…
To keypair.json = [121,18,10…
I can’t believe this is not in the documentation
Hi @come0x and welcome to the forum!
You are right, it is very annoying that Phantom doesn’t just allow exporting the private key as a JSON array like the commandline expects. I created a script to convert it. See this comment and the surrounding thread:
Thanks @blockchainlover2019 !
I don’t think you need to do the separate step to create the Keypair from the secret key.
Here’s something that worked for me, and with Deno you can test it without needing to npm install or anything.
script_url=https://gist.githubusercontent.com/zicklag/feb30b217b07c013641dbfce16a754eb/raw/471f27ba6dcda188cfbd83f44299637653bfc56a/base58-to-array.ts
deno run $script_url [exported private key string from Phantom]