Skip to content

Commit

Permalink
docs: fix README code on decoding tx instruction (gagliardetto#136)
Browse files Browse the repository at this point in the history
Fixes issues on code sample provided in section "Parse/decode an instruction from a transaction" from the README
  • Loading branch information
GCrispino authored Nov 15, 2023
1 parent 42c0c1b commit 43995cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func exampleFromGetTransaction() {
endpoint := rpc.TestNet_RPC
client := rpc.New(endpoint)

txSig := solana.MustSignatureFromBase58("3pByJJ2ff7EQANKd2bgetmnYQxknk3QUib1xLMnrg6aCvg5hS78peaGMoceC9AFckomqrsgo38DpzrG2LPW9zj3g")
txSig := solana.MustSignatureFromBase58("3hZorctJtD3QLCRV3zF6JM6FDbFR5kAvsuKEG1RH9rWdz8YgnDzAvMWZFjdJgoL8KSNzZnx7aiExm1JEMC8KHfyy")
{
out, err := client.GetTransaction(
context.TODO(),
Expand Down Expand Up @@ -327,12 +327,15 @@ func decodeSystemTransfer(tx *solana.Transaction) {

// Find the program address of this instruction:
progKey, err := tx.ResolveProgramIDIndex(i0.ProgramIDIndex)
if if err != nil {
if err != nil {
panic(err)
}

// FInd the accounts of this instruction:
accounts := i0.ResolveInstructionAccounts(&tx.Message)
// Find the accounts of this instruction:
accounts, err := i0.ResolveInstructionAccounts(&tx.Message)
if err != nil {
panic(err)
}

// Feed the accounts and data to the system program parser
// OR see below for alternative parsing when you DON'T know
Expand Down

0 comments on commit 43995cc

Please sign in to comment.