1

Firstly, do I understand correctly that CPI call is one of the ways to call a method of program?

If so, only by examining a TX on the blockchain, will it be possible to distinguish a CPI call to a program from a normal one?

2 Answers 2

0

A CPI is when a program calls another program during a transaction.

You can see CPI as inner instructions in the solana explorer:

Here an example: https://explorer.solana.com/tx/625sih8CkKT4pknX4JXuZSpH7awjfhDYcFpCDQDuwSTRxc9dD6JH5emk8Fi4TVQmWaeWiHS7xhD22s72LDHoaeQL

You can see its using the Jupiter Accounts Route and then does a CPI to flux beam. enter image description here

6
  • You can see its using the Jupiter Accounts Route and then does a CPI to flux beam. -- I see a list of accounts and TXs. Where precisely is that observed?
    – kriss100
    Commented Mar 14 at 19:57
  • By the way, when a browser wallet makes a swap, is CPI getting used too?
    – kriss100
    Commented Mar 14 at 19:59
  • Yes every transaction can do a CPI into another program. You can see it marked as Inner Instruction in the solana explorer. Other explorers may show it differently
    – Jonas H.
    Commented Mar 14 at 20:25
  • I'm not asking what a TX can do. I asked -- when a browser wallet makes a swap, is CPI getting used too? Or not?
    – kriss100
    Commented Mar 14 at 20:36
  • In other words: do browser addons or wallets, for swap operations, use CPI a) always b) often c) almost never?
    – kriss100
    Commented Mar 14 at 20:38
0

When you fetch a transaction with the getTransaction endpoint, you'll get all of the top-level instructions in the transaction in transaction.message.instructions, which are not CPIs. You'll also get the meta.innerInstructions, which are all of the CPIs.

More information at https://solana.com/docs/rpc/http/gettransaction

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.