I'm trying to create and extend an address lookup table. The program successfully creates the lookup table but when it comes to extending the table, I get this error:
SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Invalid account owner
I pass the same keypairs for both instructions but error tells me that the owner is invalid. This is the code for creating the ALT:
let { blockhash } = await connection.getLatestBlockhash();
const currentSlot = await connection.getSlot();
const slots = await connection.getBlocks(currentSlot - 200);
const [lookupTableInst, lookupTableAddress] =
web3.AddressLookupTableProgram.createLookupTable({
authority: payer.publicKey,
payer: payer.publicKey,
recentSlot: slots[2],
});
const messageV0 = new web3.TransactionMessage({
payerKey: payer.publicKey,
recentBlockhash: blockhash,
instructions: [lookupTableInst],
}).compileToV0Message();
const transaction = new web3.VersionedTransaction(messageV0);
transaction.sign([payer]);
const tx = await connection.sendTransaction(transaction);
console.log(`Created lookup table: ${tx}`)
And this is the code for extending the ALT: let { blockhash } = await connection.getLatestBlockhash();
const extendInstruction = web3.AddressLookupTableProgram.extendLookupTable({
payer: payer.publicKey,
authority: payer.publicKey,
lookupTable: lookupTableAddress,
addresses: winners,
});
const messageV0 = new web3.TransactionMessage({
payerKey: payer.publicKey,
recentBlockhash: blockhash,
instructions: [extendInstruction],
}).compileToV0Message();
const transaction = new web3.VersionedTransaction(messageV0);
transaction.sign([payer]);
const tx = await connection.sendTransaction(transaction, {skipPreflight: true});
console.log(`Extended lookup table: ${tx}`)
What could go wrong in this situation?