Instructionは、Solanaプログラム上で特定の関数を実行するためのリクエストです。Instructionsは、オンチェーン操作の基本的な構成要素です。各instructionは、呼び出す1つのプログラム、必要なアカウント、およびプログラムが解釈するバイト配列のデータ(通常は実行するinstructionハンドラを識別するためのdiscriminatorと、それに続くシリアライズされた引数)を正確に指定します。各instructionの実行ロジックはプログラムに保存されており、各プログラムは独自のinstructionsセットを定義します。Solanaネットワークとやり取りするには、1つ以上のinstructionsをトランザクションに追加し、ネットワークに送信して処理します。
Diagram depicting a transaction with an instruction, broken up into its 3 components
Instruction structure
Instructionの3つのフィールド(program_id、accounts、data)、AccountMeta、コンパイル済みinstructions、およびSOL転送の例。
Instruction introspection
プログラムがInstructions sysvarを介して現在のトランザクション内の兄弟instructionsを検査する方法。
重要なポイント
- 単一プログラム: 各instructionは
program_idを介して正確に1つのプログラムを対象とします。 - アカウントメタデータ:
accounts配列は、instructionが読み取りまたは書き込みを行うすべてのアカウントに対してAccountMetaを提供します。 - 不透明なデータ:
dataフィールドは、対象プログラムによって形式が定義されるバイト配列です。
Is this page helpful?