Closed 6otah closed 3 months ago
you should check your private key, decode method is from official recommend
export const owner: Keypair = Keypair.fromSecretKey(
bs58.decode('private key')
)
Private key is valid. I can make simple transaction with it
I generated 3 new wallets:
2827706161348e272d6db5e2bd728df1c8f785bb74c8a34de57c39b49aa1ae3209ec2ae6272454617f3d6f373e7413dc3e1c60315995659a418f005529885ed4
solscan
03f8313c669bd2cceb91f1908566ee700cbcb71186d9d0694203c70e2e4f068eb26293ebe31491d7ecfc467ed2fe3590c7b20b1aefd1e9b42acc3117b8672d0b
solscan
ad35dbd2ecb33786c47018900432950816f82cdf15047a6e012aea06713f9226ea5c69e8e3e703e0cbebafedb54bf3b4418220e0ffe01ee5285b6a57bd0afa99
solscan
None of them works.
how did get private key? I tested it and first wallet's private key should be oZeXFzYRkxnJMMEtsh1m3hm8Y1xBDc5VBR6fZbEhQySRu5hDTR5L1thW9TdMEqtsgmpXUsTf9BwNZ8J6h2CpMbh
and this is valid base64 format not the string you pasted here
the string you provided is hex
format not base64,
please export private key to base64 format,
code below is how to convert it to base64
const fromHexString = (hexString: string) =>
Uint8Array.from(hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)))
bs58
.encode(
Uint8Array.from(
fromHexString(
'2827706161348e272d6db5e2bd728df1c8f785bb74c8a34de57c39b49aa1ae3209ec2ae6272454617f3d6f373e7413dc3e1c60315995659a418f005529885ed4'
)
)
)
.toString()
if you are trying to export private from keypair, use this code to get base64 format private key bs58.encode(wallet.secretKey)
Yes, you're right. Thank you!
InitSdk
does not work with new wallets. Here is the test code:When I use new wallets, the code returns the following error:
New test wallet:
9f3638a2f8e4a89980ccbbed17ebcbb20804bd9ce3d26f26c3acbc277a3cf60907194b2db586b578bf90afa0c8f6b2e246e527d8028218806c826d5bb1248b3f
With the old test wallet, the code works:
5XqzNffaeUnW5ntEikr3aJychF2Nhdj7UEaj9X9qR9kfdg3cFmcdyzpL4JcMBDBJ7N1JuwQBAfjQN3eDu8wUEef9