Skip to content

Instantly share code, notes, and snippets.

@softlion
Created May 24, 2024 22:14
Show Gist options
  • Save softlion/7cdc27464c28b69c67023bb5f2728e5e to your computer and use it in GitHub Desktop.
Save softlion/7cdc27464c28b69c67023bb5f2728e5e to your computer and use it in GitHub Desktop.
CONVERT SOLFLARE PRIVATE KEY FORMAT (decimal json) INTO HELIUM WALLET PRVATE KEY FORMAT (base58)
#CONVERT SOLFLARE PRIVATE KEY FORMAT (decimal json) INTO HELIUM WALLET PRVATE KEY FORMAT (base58)
#pip install base58
import json
import base58
# Your Solana private key as a JSON array of integers
solana_private_key_json = '[79, 60, 46, 159, 168, 210, 229, 181, 155, 62, 45, 118, 26, 77, 75, 81, 205, 71, 201, 184, 159, 45, 110, 19, 200, 162, 167, 210, 229, 181, 195, 214]'
# Parse the JSON array to a list of integers
private_key_list = json.loads(solana_private_key_json)
# Convert the list of integers to a byte array
private_key_bytes = bytearray(private_key_list)
# Convert the byte array to a Base58 string
solflare_private_key_base58 = base58.b58encode(private_key_bytes).decode('utf-8')
# Print the Base58 string
print(solflare_private_key_base58)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment