3

I am writing a program to transfer SOL owned by the system program to another system program PDA, in the tests everything works fine and also on the frontend UI but the problem is that, when the user has to sign, the amount to transfer from the PDA does not show and when signing the transaction it executes as it should

enter image description here

The code of my frontend looks like this

 const tx = await program.methods.transferToGameEscrow(new BN(one_sol/2), escrowBump, publicKey).accounts({
    destination: roomEscrow,
    pda: escrowPda,
    systemProgram: anchor.web3.SystemProgram.programId
  }).rpc();

This is my rust code but I wonder why it does not show the amount to transfer on the sign page

  pub fn transfer_to_game_escrow(ctx:Context<SendSol>, amount: u64, abump:u8, an_owner:Pubkey) -> Result<()>{
        let ix = transfer(
            ctx.accounts.pda.key,
            ctx.accounts.destination.key,
            amount
        );
        
        invoke_signed(
            &ix,
            &[
                ctx.accounts.pda.to_account_info(),
                ctx.accounts.destination.to_account_info(),
                ctx.accounts.system_program.to_account_info(),
            ],
            &[&[
                b"a_player_escrow".as_ref(), 
                an_owner.as_ref(), 
                &[abump]
            ]],
        )?;
        Ok(())
    }
1
  • I have also implemented it according to your method, and there is no such situation as you mentioned! How are we different? This was more than a year ago, is it still the same now?
    – 刘铁锈
    Commented Mar 26 at 13:48

1 Answer 1

3

It seems you're transferring from a PDA (i.e. not from the wallet the user has selected in Phantom) to some other account roomEscrow, which also seems to be not the account the user has selected in Phantom.

So it seems to me (correct me if I'm wrong) that there will be no balance on the selected account "Wallet 3", and the transfer will just happen from and to two accounts that are different from the current wallet account.

Since Phantom only shows the Estimated Balance Change for the user's account, it has nothing to do here.

1
  • Oh right I understand thank you! Would that make a difference if I use a PDA owned by my own program or would the issue still remain the same?
    – Sing
    Commented Aug 12, 2022 at 0:35

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.