Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Solana Stack Exchange is a question and answer site for Solana software users and developers. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
As Solana developer, web3.js and CPIs are bread and butter. A recent update on web3.js caught my attention. "Transaction" is deprecated and "VersionedTransactions" with "MessageV0" is the norm. It seems, he developments will make it harder for developers to create transactions. Three questions pop out my mind:
Does it mean we won't create instructions with programId, keys, data anymore soon?
How will "VersionedTransactions" with "MessageV0" affect CPIs?
How does "Sealevel" look like in the new context since there won't be "AccountMeta[]" anymore?
Background information
Address Lookup Tables are reference tables that list and index writeable and readable accounts. It empowers transactions with more capabilities and enable new use cases on Solana by significantly reducing the transaction size through offloading accounts as references on the chain.
"VersionedTransactions" and "Lookup Tables":
https://www.youtube.com/watch?v=8k68cMeLX2U
"Transaction":
https://solana-labs.github.io/solana-web3.js/classes/Transaction.html
"VersionedTransactions" and "MessageV0":
https://solana-labs.github.io/solana-web3.js/classes/VersionedTransaction.html
"TransactionInstruction" is deprecated:
https://solana-labs.github.io/solana-web3.js/classes/TransactionInstruction.html
"TransactionMessage":
https://solana-labs.github.io/solana-web3.js/classes/TransactionMessage.html#instructions
With "VersionedTransactions", transactions don't follow the usual simple format with "TransactionInstruction" (programId, keys, data):
instructions[] (programId : PublicKey, keys: AccountMeta[], data: Buffer)
signatures (mandatory)
Instead "VersionedTransactions" have a more complex format with indexes pointing to lists of accounts:
message (header, addressTableLookups, compiledInstructions, staticAccountKeys, recentBlockhash)
signatures (optional)
Good thing, at the moment "MessageV0" can be still compiled through "new TransactionMessage" with the method "compileToV0Message" by providing the following familiar inputs:
instructions[] (programId : PublicKey, keys: AccountMeta[], data: Buffer)
payerKey
recentBlockhash
This is a few questions rolled into one, but I'll try to address them all. First off, "legacy" does not mean "deprecated", so legacy transactions will always be supported. The web3.js
VersionedTransaction
can in fact be a legacy
Transaction
, so you can transition to using that.
Does it mean we won't create instructions with programId, keys, data anymore soon?
You'll still create instructions as before. It's how they get converted into
Message
s and
Transaction
s that's different. The legacy
Message.compile
still works
https://github.com/solana-labs/solana/blob/8daed75df9a0b5c942ec1cc745a48356db7f46ad/web3.js/src/message/legacy.ts#L109
How will "VersionedTransactions" with "MessageV0" affect CPIs?
Not at all! Programs still behave the same, and the transaction format has no impact on how programs create instructions. The only difference might be that they can provide many more accounts during CPI thanks to address lookup tables.
How does "Sealevel" look like in the new context since there won't be "AccountMeta[]" anymore?
Also no difference!
AccountMeta
s still exist and are used by programs. The runtime just fetches more accounts if there's an address lookup table.
You can read more about Versioned Transactions at
https://solanacookbook.com/guides/versioned-transactions.html#versioned-transactions
Thanks for contributing an answer to Solana Stack Exchange!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.