@@ -343,9 +343,25 @@ func decodeSystemTransfer(tx *solana.Transaction) {
343343 // OR
344344 {
345345 // There is a more general instruction decoder: `solana.DecodeInstruction`.
346- // But before you can use `solana.DecodeInstruction`,
347- // you must register a decoder for each program ID beforehand
348- // by using `solana.RegisterInstructionDecoder` (all solana-go program clients do it automatically with the default program IDs).
346+ // It looks up the decoder for `progKey` in a central registry, so it
347+ // works for any program ID regardless of what you know at compile time.
348+ //
349+ // Each `programs/<name>` package registers its decoder via init(),
350+ // which only runs when the package is imported. If you are not
351+ // already using the package's builders (e.g. `system.NewTransferInstruction`),
352+ // blank-import it so the decoder is available - same idiom as
353+ // database/sql drivers:
354+ //
355+ // import (
356+ // _ "github.com/gagliardetto/solana-go/programs/system"
357+ // _ "github.com/gagliardetto/solana-go/programs/token"
358+ // // ...add more as needed
359+ // )
360+ //
361+ // For a program that solana-go does not ship (e.g. a custom Anchor
362+ // program), register its decoder yourself:
363+ //
364+ // solana.MustRegisterInstructionDecoder(myProgramID, myDecoderFunc)
349365 decodedInstruction , err := solana.DecodeInstruction (
350366 progKey,
351367 accounts,
@@ -361,9 +377,6 @@ func decodeSystemTransfer(tx *solana.Transaction) {
361377 if !reflect.DeepEqual (inst, decodedInstruction) {
362378 panic (" they are NOT equal (this would never happen)" )
363379 }
364-
365- // To register other (not yet registered decoders), you can add them with
366- // `solana.RegisterInstructionDecoder` function.
367380 }
368381
369382 {
0 commit comments