Skip to main content
Metis Swap API is no longer actively maintained and has been superseded by Swap V2.
When adding custom instructions to a Metis swap transaction causes it to exceed Solana’s 1232-byte transaction size limit, reduce maxAccounts in the /quote request and rebuild. This page provides a retry loop that decrements maxAccounts until the transaction fits. In some cases where you might be limited or require strict control by adding your own instructions to the swap transaction, you might face issues with exceeding transaction size limit. In this section, we will provide some helping code to help you requote when the transaction size is too large.
NOTEWe provide a maxAccounts param in the /quote endpoint to allow you to reduce the total number of accounts used for a swap - this will allow you to add your own instructions.

Refer to this section for more information and do note its limitations and important notes before using

Example Code

  1. Request for quote and the swap transaction as per normal.
  2. Serialize the transaction.
  3. Use the conditions to check if the transaction is too large.
    1. If too large, requote again with lower max accounts - do note that the route will change.
    2. If not, sign and send to the network.
TIPWe recommend maxAccounts 64 and start as high as you can, then incrementally reduce when requoting.Do note that with lower max accounts, it will might yield bad routes or no route at all.
TIPWhen you serialize the transaction, you can log the number of raw bytes being used in the transaction.You can either add your custom instructions before or after serializing the transaction.

Example Response