0

I have a anchor contract with a couple instructions inside. The first instruction is from the user to a PDA account

let transfer_instruction: Instruction = system_instruction::transfer(user.key, to_account.to_account_info().key, lamports);
        solana_program::program::invoke_signed(
            &transfer_instruction,
            &[
                user_account.to_account_info(),
                to_account.to_account_info().clone(),
                ctx.accounts.system_program.to_account_info(),
            ],
            &[],
   )?;

and the second one is from a PDA to another PDA

ctx.accounts.pda1.add_lamports(other_lamports)?;
ctx.accounts.pda2.sub_lamports(other_lamports)?; 

When I view this transaction on SolScan or SolanaFM, the flow of the funds from user to PDA is trackable through the transaction ID or the account's public keys and nicely display in a graph how the funds from the user travels to the PDA account.

However the second transaction that moves funds from PDA to another PDA does not show in the flow charts displaying how the funds travel from the first transaction to the second. The funds do end up moving to the final destination PDA and it does display that there was balance changes at the destination, however it doesn't show in the flow charts. Only the first transaction is viewable. Is there a reason for this?

I guess I don't really mind if it doesn't show all the transactions in detail however, I would like to believe there is a way to be more transparent and display every transaction occurring "behind the scenes". Anyway, any explanation would be insightful.

Also does this mean that all contracts with just the second type of transactions, (PDA to PDA) will not be displayed as well?

1 Answer 1

1

The inner instructions only show instructions into other programs, ie the system_instruction::transfer that you reference at the start of your question.

A program, however, owns all of the lamports and data in accounts assigned to it, so it can modify data and deduct lamports from the accounts that it owns. Just like it doesn't need to send an instruction to another program to modify the data, it doesn't need to send an instruction to deduct lamports, which is why these movements are only captured in the post balances.

The difference between pre and post balances is the only way to capture these movements, so be sure to use those to capture all SOL movements. SPL Tokens are different, however, and will always have an instruction for a token movement.

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.