Skip to content

Instantly share code, notes, and snippets.

@doingthisalright
Created May 16, 2022 02:11
Show Gist options
  • Save doingthisalright/9229cc2064502b3f0005ebc953982138 to your computer and use it in GitHub Desktop.
Save doingthisalright/9229cc2064502b3f0005ebc953982138 to your computer and use it in GitHub Desktop.
Convert String Private Keys exported from wallets like Phantom to File Based Private Key
# Taken from https://stackoverflow.com/a/69256259
# Usage: python3 PrivateKeyStringToFile.py <String Private Key>
import base58
import sys
byte_array = base58.b58decode(sys.argv[1])
json_string = "[" + ",".join(map(lambda b: str(b), byte_array)) + "]"
print(json_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment