Created
April 3, 2022 15:12
-
-
Save whiteneon/40a11a2937b53c3d980f34ac9f185f09 to your computer and use it in GitHub Desktop.
Convert Solana CLI Keypair file to Base58 Encoded Private Key for use in Phantom Wallet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#I believe will only work on python3. You need base58 (pip install base58) | |
#Please note: I'm not a programmer and there are probably more elegant ways to accomplish this, but this does work. | |
#Usage: Call the script with the keypair file as the first argument. | |
import base58 | |
import sys | |
keyfile = sys.argv[1] | |
file = open(keyfile, 'r') | |
data = file.read().replace('\n', '').replace('[', '').replace(']', '') | |
file.close | |
key = b'' | |
for x in data.split(','): | |
w = int(x).to_bytes(1,'big') | |
key = b"".join([key, w]) | |
enc_key = base58.b58encode(key) | |
print(enc_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment