1

I want to transfer solana from one account to another , I am using browser frotend js, not nodejs how I can get this secret key and transfer data,

Please do not suggest this


 var from = web3.Keypair.generate();
    // Generate a new random public key
    var to = web3.Keypair.generate();

Please suggest with public key since from web wallet I am getting only the public key

I need to understand how I can get this array with web3js, or wallet-adapter or splToken

var web3 = require("@solana/web3.js");
// Address: asdasvfhgasomeaddress
const DEMO_FROM_SECRET_KEY = new Uint8Array([
    37, 21, 197, 185, 105, 201, 212, 148, 164, 108, 251, 159, 174, 252, 43, 246,
    225, 156, 38, 203, 99, 42, 244, 73, 252, 143, 34, 239, 15, 222, 217, 91, 132,
    167, 105, 60, 17, 211, 120, 243, 197, 99, 113, 34, 76, 127, 190, 18, 91, 246,
    121, 93, 189, 55, 165, 129, 196, 104, 25, 157, 209, 168, 165, 149,
]);

1 Answer 1

2

You're misunderstanding how browser based dapps work. The app never gets access to the user's private key. You also can't sign a transaction without the user's private key. Instead you can request the user sign a transaction, and the wallet browser extension will pop up and display that request to the user. Their browser extension holds the key, and never exposes it to the dapp. It is responsible for doing all signing using that key.

Check our the wallet-adapter docs here for an example: https://github.com/solana-labs/wallet-adapter/blob/master/APP.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.