'Creating FS wallets on solana using JSON RPC
I'm new to Solana and trying to create FS wallets using JSON RPC API. I read about solana CLI interface and can generate new FS wallets using solana-keygen new <path-to-wallet.json-file>. But now I'm trying to do the same using JSON RPC. I've installed python client for the purpose but couldn't find how to do that using that client. I'm connected to devnet cluster and can use CLI smoothly but wants to do the same using JSON RPC. Any help will be appreciated.
Solution 1:[1]
A file system wallet is just a JSON-encoded array of 64 bytes, i.e.
[144,14,239,36,55,74,88,13,156,116,241,90,128,236,78,228,107,31,163,192,87,111,115,179,102,156,95,175,141,214,242,59,100,51,187,180,77,254,194,99,11,126,9,57,115,190,156,251,141,82,79,159,150,37,216,246,193,172,71,65,153,212,158,85]
If you want to create one in Python, you can do:
import json
from solana.keypair import Keypair
wallet = Keypair()
wallet_bytes = list(wallet.secret_key)
output_file = open('fs.json', 'w')
json.dump(wallet_bytes, output_file)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jon C |
