1

I'm storing pubkey, can I use that pubkey only to transfer sol from the smart contract to that pubkey?

0

2 Answers 2

1

In order to transfer Sol to a pubkey, you need to pass that pubkey (Account) in your program instruction (Context). Solana programs (Smart Contracts) have to load all accounts before being able to send/receive/allocate etc...

So storing the pubkey only won't suffice. You need to pass the account (doesn't need to be a signer, just regular system account)

Then check if the passed account address matches the pubkey you were storing. If so, transfer the funds.

0

Sure. As long as you don't DECREASE the SOL (or token) amount in the target account, you can send funds there with the public key only.

You can easily try it out. Just send some funds from your Phantom wallet to any other address. Phantom will not ask you for the target's private key. It will just send the funds out of YOUR wallet (for which it has the private key and for which you will need to approve / sign the transaction) right into the other wallet specified by a public key only.

1
  • I meant inside smart contract using rust. Can we do that? I just stored the address and amount, can I transfer sol with this much data?
    – pramitgaha
    Aug 7, 2022 at 1:30

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.