Instruction
Identify the Instruction-s you need to call in Solana. For example, the following InstructionExpenses
Determine how much lamports your instruction spends on the destination network (most often, for account creation). Record this value as expenses. Each instruction is technically worth 5000 lamports (since we can’t determine how many resources it will spend in advance, the implication is that it can be executed in a separate transaction). Therefore, 5000 + expenses is the estimate of how much lamports will cost the execution.Pubkey substituion
Determine which accounts in the instruction are input-dependent and cannot be passed directly from the user for security reasons. For example, if there is a PDA in the destination network that depends on some unique transfer identifier, then we need to formPubkeySubstitutions
.
This gives the following Solidity code:
Pubkey placeholders
As well as pubkey substitutions, placeholders could be used to substitute extcall accounts, but placeholders can’t be used to calculate ATA during extcall execution. At the moment we have following placeholders:- Wallet Placeholder :
J4vKrc4pCdtiHpxFDfBy4iyZ22Uf7fBjJyJ817k4673y
- if you set this pubkey to some account, it will be replaced by actual Submission Wallet during execution. Submission wallet is a token account that contains transferred tokens during execution. - Submission Placehoder :
7cu34CRu47UZKLRHjt9kFPhuoYyHCzAafGiGWz83GNFs
will be replaced by Submission account during execution. Submission account contains transfer metadata such as native sender, send from chain, etc. - Authority Placeholder :
2iBUASRfDHgEkuZ91Lvos5NxwnmiryHrNbWBfEVqHRQZ
will be replaced by Submission Authority account during execution. Submission authority is an owner/authority account for Submission Wallet. It is this account that manages On-Chain external call preparation for Solana.
DataSubstitution
If you need a transfer amount as part of your transfer and it cannot be calculated in advance, then you must useDataSubstitution
. One substitution is
now available (SubmissionAuthWalletAmount
) which works as follows. Takes the account_index
account of the current instruction, interprets it as a
token account, takes its balance, chooses its encoding (big endian, little endian), use substration
and inserts it into the current instruction by
offset
before calling it.