I'm struggling to send SOL to another address(fixed one when initialize) on Rust level along logging the sender's account address on the program.

Do I need PDA for this? Also I have to log the sender's account address on the program.

I tried to write some code by investigating code example. Please let me know if this would work. :)

use anchor_lang::prelude::*;


pub mod transfer_sol {
    use super::*;
    pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {

    pub fn buy_ticket(ctx: Context<BuyTicket>, amount: u64) -> Result <()> {
        let base_account = &mut ctx.accounts.base_account;
        let user = &mut ctx.accounts.user;

        // Transfer Sol
        let transfer_sol = transfer(




pub struct Initialize<'info> {
    user: Signer<'info>,
        payer = user,
        space = 8 + 100,
        seeds = [b"tickets".as_ref()],
    base_account: Account<'info, BaseAccount>,
    system_program: Program<'info, System>,

pub struct BuyTicket<'info> {
    pub base_account: Account<'info, BaseAccount>,
    pub user: Signer<'info>,
    pub system_program: Program<'info, System>,

pub struct BaseAccount {
    pub users: Vec<PublicKey>,
    pub dest: PublicKey

2 Answers 2


Since the user's wallet is a signer in the instruction, your example will work! You can propagate their signature down to any other program, which is what you're doing with the invoke into the system program's transfer instruction.

  • Thanks for the answer. What do you mean by propagate their signature down to any other program?
    – sunnydev
    Sep 16, 2022 at 4:47
  • If I sign your instruction, I can also be a signer for any CPI that you call from your instruction. So if your instruction calls transfer to move my lamports, that's fine. If your instruction withdraws from my stake account, that's also OK. You can read more about it at docs.solana.com/developing/programming-model/…
    – Jon C
    Sep 16, 2022 at 11:35

Simple answer is that you don't need a PDA to transfer Solana from one account to another.

If your goal is to transfer Solana from a system program owned account to another account (owned by any program), then you just need to pass in the signature of the sender account. That signature could come from a PDA or a key pair private key.

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.