title: Get program id/address from Solana transaction data (solana/web3.js)
body: <p>I want to determine whether a transaction has interacted with a specific program id &quot;cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ&quot; (being the Candy Machine program address).</p>
  <p>I'm using @solana/web3.js to get the below (bottom of post) Candy Machine mint transaction data using connection.getTransaction(txn.signature).</p>
  <p>How can I determine whether the transaction interacted with the Candy Machine program?</p>
  <p>I have tried digging into transaction.meta.innerInstructions, but I can't work out how to translate this into program id addresses.</p>
  <pre><code>[
    {
      'accounts': '2',
      'data': '3Bxs4h24hBtQy9rw',
      'programIdIndex': '8'
    },{
      'accounts': '2',
      'data': '9krTDU2LzCSUJuVZ',
      'programIdIndex': '8'
    },{
      'accounts': '2',
      'data': 'SYXsBSQy3GeifSEQSGvTbrPNposbSAiSoh1YA85wcvGKSnYg',
      'programIdIndex': '8'
    },
  ...etc.
  ]
  </code></pre>
  <p><em>Note: I realise I could just search for the program address within &quot;logMessages&quot; string, but that's cheating somewhat and I'm trying to learn how this all works.</em></p>
  <p>Example mint transaction data which DOES interact with the Candy Machine program:</p>
  <pre><code>{
    blockTime: 1640299576,
    meta: {
      err: null,
      fee: 10000,
      innerInstructions: [ [Object], [Object] ],
      logMessages: [
        'Program 11111111111111111111111111111111 invoke [1]',
        'Program 11111111111111111111111111111111 success',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
        'Program log: Instruction: InitializeMint',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2390 of 200000 compute units',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
        'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]',
        'Program log: Transfer 2039280 lamports to the associated token account',
        'Program 11111111111111111111111111111111 invoke [2]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Allocate space for the associated token account',
        'Program 11111111111111111111111111111111 invoke [2]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Assign the associated token account to the SPL Token program',
        'Program 11111111111111111111111111111111 invoke [2]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Initialize the associated token account',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
        'Program log: Instruction: InitializeAccount',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3449 of 179576 compute units',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
        'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 24522 of 200000 compute units',
        'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
        'Program log: Instruction: MintTo',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2879 of 200000 compute units',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
        'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ invoke [1]',
        'Program 11111111111111111111111111111111 invoke [2]',
        'Program 11111111111111111111111111111111 success',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]',
        'Program log: Instruction: Create Metadata Accounts',
        'Program log: Transfer 5616720 lamports to the new account',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Allocate space for the account',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Assign the account to the owning program',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 23040 of 176519 compute units',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s success',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]',
        'Program log: Instruction: Create Master Edition',
        'Program log: Transfer 2853600 lamports to the new account',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Allocate space for the account',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Assign the account to the owning program',
        'Program 11111111111111111111111111111111 invoke [3]',
        'Program 11111111111111111111111111111111 success',
        'Program log: Setting mint authority',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [3]',
        'Program log: Instruction: SetAuthority',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2019 of 126852 compute units',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
        'Program log: Setting freeze authority',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [3]',
        'Program log: Instruction: SetAuthority',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2021 of 122246 compute units',
        'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
        'Program log: Finished setting freeze authority',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 28978 of 148307 compute units',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s success',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [2]',
        'Program log: Instruction: Update Metadata Accounts',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 7238 of 116624 compute units',
        'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s success',
        'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ consumed 94165 of 200000 compute units',
        'Program cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ success'
      ],
      postBalances: [
           636708880,    1461600,
             2039280,    4572720,
        737969768141,    5616720,
             2853600,    1009200,
                   1, 1089991680,
          9286574880,    1141440,
             1169280,  898174080,
             1141440
      ],
      postTokenBalances: [ [Object] ],
      preBalances: [
           898690080,          0,
                   0,    4572720,
        737719768141,          0,
                   0,    1009200,
                   1, 1089991680,
          9286574880,    1141440,
             1169280,  898174080,
             1141440
      ],
      preTokenBalances: [],
      rewards: [],
      status: { Ok: null }
    },
    slot: 112965987,
    transaction: {
      message: Message {
        header: [Object],
        accountKeys: [Array],
        recentBlockhash: 'B2EuNArBL5XL1coHVZY53Gob7FxrqUxA77DsBRPJwVyd',
        instructions: [Array],
        indexToProgramIds: [Map]
      },
      signatures: [
        '5E8VZSRhfUffRuZFUwoGmDsV1hMzqq2zD5sV6hZPAVFQizXa5SeEpYKw5RWfSMX4bsxB8GyELfPJhYaeLxUn5yjT',
        '4ZaC8PSqBH95Yk8X8aSiea6dEBwostzaf9WxQQKdNNKs4VjGGUJDYw8iAJsp9SxwkgUjM68kZuD4xK1Yxwnq4jM1'
      ]
    }
  }
  </code></pre>
  <p>Thanks!</p>