admin管理员组文章数量:1357399
I am working with Solana and phantom wallet I have a wallet with a public key and I have it's secret phrase posed of 12 words. when I generate keypairs from the secret phrase I use:
const getKeyPair = (mnemomic) => {
const seed = bip39.mnemonicToSeedSync(mnemomic).slice(0, 32);
const Keypair = web3.Keypair.fromSeed(seed);
return Keypair;
};
the generated keypair has publicKey and privateKey , but when am checking my balance using the generated public key I find the balance is always 0 even when I try to airdrop Sol using my code it's not getting in the account.
But if I check using my public key from phantom wallet I get the Sol I have and if I want to airdrop sols they also proceed normally.
Why is my generated public key not the same as the one in phantom wallet?
I am working with Solana and phantom wallet I have a wallet with a public key and I have it's secret phrase posed of 12 words. when I generate keypairs from the secret phrase I use:
const getKeyPair = (mnemomic) => {
const seed = bip39.mnemonicToSeedSync(mnemomic).slice(0, 32);
const Keypair = web3.Keypair.fromSeed(seed);
return Keypair;
};
the generated keypair has publicKey and privateKey , but when am checking my balance using the generated public key I find the balance is always 0 even when I try to airdrop Sol using my code it's not getting in the account.
But if I check using my public key from phantom wallet I get the Sol I have and if I want to airdrop sols they also proceed normally.
Why is my generated public key not the same as the one in phantom wallet?
Share Improve this question edited Oct 20, 2022 at 18:14 mikemaccana 124k110 gold badges432 silver badges534 bronze badges asked Feb 10, 2022 at 6:25 Said PcSaid Pc 6551 gold badge8 silver badges14 bronze badges2 Answers
Reset to default 4solana-keygen recover 'prompt:?key=0/0' -o phantom_wallet.json
First, we need to generate the publicKey and privateKey from the seed phrase using this mand :
solana-keygen recover 'prompt:?key=0/0' -o phantom_wallet.json
remark : our account may have many wallets the mand above access the first wallet , if we need to access wallet number 10 for example we need to change the 'prompt:?key=0/0' to 'prompt:?key=10/0' "only the first 0 is changing"
next this will generate public key "will be written in the console" and a json file with secret key contains an array of 64 element which is the secret key. now to generate the KEYPAIRS in solana web3 javascript SDK we do the following:
let seed = Uint8Array.from(
process.env.REACT_APP_OUR_SECRET_KEY.split(",")
).slice(0, 32);
// create keypairs
let KEYPAIRS = web3.Keypair.fromSeed(seed);
IMPORTANT : in .env files REACT_APP_OUR_SECRET_KEY is stored without brackets [ ] example : 15,320,52,... as we see a table without brackets [ ]
本文标签: javascripthow to generate keypair from secret phrase (mnemonic) SOLANAStack Overflow
版权声明:本文标题:javascript - how to generate keypair from secret phrase (mnemonic) SOLANA - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743996064a2573009.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论