0

I want to get the account that are UnsignedAccounts and SignedAccounts, can it be infered from the transaction below?

{
  "data": {
    "signatures": [
      {
        "0": 0,
        "1": 0,
        "2": 0,
        "3": 0,
        "4": 0,
        "5": 0,
        "6": 0,
        "7": 0,
        "8": 0,
        "9": 0,
        "10": 0,
        "11": 0,
        "12": 0,
        "13": 0,
        "14": 0,
        "15": 0,
        "16": 0,
        "17": 0,
        "18": 0,
        "19": 0,
        "20": 0,
        "21": 0,
        "22": 0,
        "23": 0,
        "24": 0,
        "25": 0,
        "26": 0,
        "27": 0,
        "28": 0,
        "29": 0,
        "30": 0,
        "31": 0,
        "32": 0,
        "33": 0,
        "34": 0,
        "35": 0,
        "36": 0,
        "37": 0,
        "38": 0,
        "39": 0,
        "40": 0,
        "41": 0,
        "42": 0,
        "43": 0,
        "44": 0,
        "45": 0,
        "46": 0,
        "47": 0,
        "48": 0,
        "49": 0,
        "50": 0,
        "51": 0,
        "52": 0,
        "53": 0,
        "54": 0,
        "55": 0,
        "56": 0,
        "57": 0,
        "58": 0,
        "59": 0,
        "60": 0,
        "61": 0,
        "62": 0,
        "63": 0
      }
    ],
    "message": {
      "header": {
        "numRequiredSignatures": 1,
        "numReadonlySignedAccounts": 0,
        "numReadonlyUnsignedAccounts": 2
      },
      "accountKeys": [
        "QAkyC4TN83zAYcRETJxK92aEVREqaDc3ejdtSuUjjfj",
        "6bmWX7G92w72uewtdbjJ898scxC4Mn1TQi9U2UnnFme6",
        "8S95TmSdzxQrG9tnppEdTqanwWjKtBFBLV1Rh96VTp6r",
        "cqYNVxjS7Xin1LmfM7KMwqKockNZpa4yiPkJ1L8ZvWN",
        "6kyAE2eHjdiupYVp9Qs6pjbq8Frk7G5deLAaW8tEtEBu",
        "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
      ],
      "recentBlockhash": "EPajeuQdGsf2qDA3rQsK8UpRX6V9GWPvcpwezTg5RaR8",
      "instructions": [
        {
          "programIdIndex": 4,
          "accounts": [0, 1, 3, 5, 2],
          "data": "xuVmYHgcsG7vwEpQSFFtT"
        }
      ],
      "indexToProgramIds": {}
    }
  }
}

I need to transform it like

AccountMeta(
        pubKey: pubKey,
        isWriteable: false,
        isSigner: isSigner,
      );

1 Answer 1

1

Certainly! In the accountKeys, the order goes:

  • writable signer accounts
  • readonly signer accounts
  • writable non-signer accounts
  • readonly non-signer accounts

And the "header" gives all the info to figure it out:

      "header": {
        "numRequiredSignatures": 1,      // total signers
        "numReadonlySignedAccounts": 0,  // subset of signers which are readonly
        "numReadonlyUnsignedAccounts": 2 // total readonly unsigned accounts
      },

So that gives:

      "accountKeys": [
        "QAkyC4TN83zAYcRETJxK92aEVREqaDc3ejdtSuUjjfj",  // writable signer
        "6bmWX7G92w72uewtdbjJ898scxC4Mn1TQi9U2UnnFme6", // writable unsigned
        "8S95TmSdzxQrG9tnppEdTqanwWjKtBFBLV1Rh96VTp6r", // writable unsigned
        "cqYNVxjS7Xin1LmfM7KMwqKockNZpa4yiPkJ1L8ZvWN",  // writable unsigned
        "6kyAE2eHjdiupYVp9Qs6pjbq8Frk7G5deLAaW8tEtEBu", // readonly unsigned
        "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"   // readonly unsigned
      ],
1
  • ok, thank you .
    – Davy King
    Commented May 14 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.