1

The RPC returns empty arrays for pre/postTokenBalances for the transaction below, when there is actually a token transfer.

https://explorer.solana.com/tx/2M8DiyZuMwgJRXtccpj3VbQ4t7AFnSHfr7EFbq7dtEdhhguXGVofHb2DSx626PnByNTihcfLKhZ6xviGzcXGvJo6

Expected: pre/postTokenBalances should have the records for 2432558691285.5888 KIN transferred.

Actual: pre/postTokenBalances are just empty arrays.

According to the RPC documentation:

preTokenBalances: <array|undefined> - List of token balances from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction

  • I assume "omitted" here means undefined. For this transaction, I'm getting empty array and not undefined, which means "token balance recording" is enabled for this transaction?
  • How do I know whether a transaction has "token balance recording" enabled? Tried searching around, but couldn't find any relevant info.

RPC response snippet:

{
    "jsonrpc": "2.0",
    "result": {
        "blockTime": 1608579465,
        "meta": {
            "err": null,
            "fee": 10000,
            "innerInstructions": [],
            "logMessages": [
                "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
                "Program log: Instruction: TransferChecked",
                "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 5651 of 200000 compute units",
                "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success"
            ],
            "postBalances": [
                9690639800680,
                0,
                2039280,
                2039280,
                1461600,
                1118555520
            ],
            "postTokenBalances": [],
            "preBalances": [
                9690639810680,
                0,
                2039280,
                2039280,
                1461600,
                1118555520
            ],
            "preTokenBalances": [],
            "rewards": [],
            "status": {
                "Ok": null
            }
        },
        "slot": 56619660,
        "transaction": {
            "message": {
                "accountKeys": [
                    {
                        "pubkey": "agsWhfJ5PPGjmzMieWY8BR5o1XRVszUBQ5uFz4CtDiJ",
                        "signer": true,
                        "source": "transaction",
                        "writable": true
                    },
                    {
                        "pubkey": "agmTGWQdxedymuZ1XzWSTPxXyCRDG93RBXmKHgw6AMm",
                        "signer": true,
                        "source": "transaction",
                        "writable": false
                    },
                    {
                        "pubkey": "mintUWJmhmFHzZnw5SRE3CEx72ib9CZYJrrzHzZzWj3",
                        "signer": false,
                        "source": "transaction",
                        "writable": true
                    },
                    {
                        "pubkey": "5CtDePTpEadRxUk6pkFVmShGMpgjvwVw6eBTcpZedkQS",
                        "signer": false,
                        "source": "transaction",
                        "writable": true
                    },
                    {
                        "pubkey": "kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6",
                        "signer": false,
                        "source": "transaction",
                        "writable": false
                    },
                    {
                        "pubkey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
                        "signer": false,
                        "source": "transaction",
                        "writable": false
                    }
                ],
                "addressTableLookups": null,
                "instructions": [
                    {
                        "parsed": {
                            "info": {
                                "authority": "agmTGWQdxedymuZ1XzWSTPxXyCRDG93RBXmKHgw6AMm",
                                "destination": "5CtDePTpEadRxUk6pkFVmShGMpgjvwVw6eBTcpZedkQS",
                                "mint": "kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6",
                                "source": "mintUWJmhmFHzZnw5SRE3CEx72ib9CZYJrrzHzZzWj3",
                                "tokenAmount": {
                                    "amount": "243255869128558880",
                                    "decimals": 5,
                                    "uiAmount": 2432558691285.589,
                                    "uiAmountString": "2432558691285.5888"
                                }
                            },
                            "type": "transferChecked"
                        },
                        "program": "spl-token",
                        "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
                    }
                ],
                "recentBlockhash": "8ddxF1eMK5cnTuqJpmQUmAcBh6RNpjev5ebFM7JQUJKg"
            },
            "signatures": [
                "2M8DiyZuMwgJRXtccpj3VbQ4t7AFnSHfr7EFbq7dtEdhhguXGVofHb2DSx626PnByNTihcfLKhZ6xviGzcXGvJo6",
                "55EZawMh8Kj4agKBksE5FHHvCQ4q3qbUYu8ACrYuyBS7styWpcGXeaUspRrYsmTVreBoFUk1epdmAKa72wKUdSqS"
            ]
        },
        "version": "legacy"
    },
    "id": "b7049b7f-e293-4ddc-8ce7-29b4e0cbd508"
}

1 Answer 1

1

Considering the change was merged at the end of December 2020, right after the time this transaction was executed https://github.com/solana-labs/solana/pull/13673, this is definitely too old of a transaction to have pre / post token balances.

It is strange that there's an empty array rather than undefined or nothing at all. I can't explain that unfortunately, sorry!

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.