Say I have given a versioned transaction and I want to get the accounts in the same format my smart contract will see it in. How do I do this?

Edit: I've tried the below, but this always gives me Error: Failed to get account keys because address table lookups were not resolved, which makes sense since this is a synchronous method and I didn't fetch the LUTs onchain anywhere else.

const allAccs = transaction.message.getAccountKeys().keySegments().reduce((acc, cur) => acc.concat(cur), []);

2 Answers 2


Figured it out. If our transaction is tx, we can just do:

const LUTs = (await Promise.all(transaction.message.addressTableLookups
    .map((acc) => conn.getAddressLookupTable(acc.accountKey))))
    .map((lut) => lut.value).filter((val) => val !== null) as AddressLookupTableAccount[];
const allAccs = transaction.message.getAccountKeys({ addressLookupTableAccounts: LUTs })
    .keySegments().reduce((acc, cur) => acc.concat(cur), []);


    const tx = await connection.getParsedTransaction(
        maxSupportedTransactionVersion: 0
  • Thanks for this, but I already solved my issue in my answer below. Additionally, the tx hasn't been executed yet, so I can't use getParsedTransaction. I didn't say it had, but tbf I also didn't say it hadn't :)
    – Ahri
    Commented Dec 29, 2023 at 22:55

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.