6

I am trying to use the Solana JSON RPC to request the data from blocks using get_block. I've been using this a bunch just fine but have started to get an error that I don't understand, and can't find any explanation for.

The request is:

[{'jsonrpc': '2.0', 'id': 1, 'method': 'getBlock', 'params': [150059418, {'encoding': 'json', 'transactionDetails': 'full', 'rewards': False}]}]

I'm using the python requests module to post it:

resp = requests.post(dev_client_url, headers=headers, data=json.dumps(request_vec))

where the headers are just {'Content-Type': 'application/json'}

the response code is 200

but it has an error: [{'jsonrpc': '2.0', 'error': {'code': -32015, 'message': 'Transaction version (0) is not supported'}, 'id': 1}]

What does this even mean? This is a valid block https://solscan.io/block/150059418?cluster=devnet and the error seems reproducible, as I can just submit that request now and it fails with that error.

If anyone can help I would greatly appreciate it! Full minimum working example below:

import requests
from requests.structures import CaseInsensitiveDict
import json as json

data_vec = [{'jsonrpc': '2.0', 'id': 1, 'method': 'getBlock', 'params': [150059418, {'encoding': 'json', 'transactionDetails': 'full', 'rewards': False}]}]

headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"

dev_client_url ="https://api.devnet.solana.com"


resp = requests.post(dev_client_url, headers=headers, data=json.dumps(data_vec))

print(resp.json())

1 Answer 1

4

There will be some forthcoming communications and documentation from the devrel team this week on the matter but for now, know that you'll need to add support for v0 transactions to your consumer service and pass the maxSupportedTransactionVersion option to getBlock.

The gist on v0 transactions is that they add support for "Address Lookup Table accounts" which allow for referencing more accounts than would typically fit withing the serialized size limit. Two new fields will need to be handled when .version == 0

  • From getBlock the .transactions[].meta.loadedAddresses field lists additional .writable and .readonly addresses that have been loaded from address lookup table accounts. They extend the .transactions[].message.accountKeys field by concatenation. That is

    tx = .transactions[index];
    tx.message.accountKeys | tx.meta.loadedAddresses.writable | tx.meta.loadedAddresses.readonly
    

    Account indexes within Instructions then point into this total concatenated list.

  • Transaction objects from both getBlock and getTransaction now also have a .message.addressTableLookups object, which is a mapping of which Lookup Table Account specified which addresses in .meta.loadedAddresses

4
  • Without checking for the presence of an account loader ix via sysvar instructions, would there be / is there an idiomatic way to get transaction version during program runtime in the rust solana_program?
    – Lando
    Commented Jul 25, 2022 at 0:27
  • Thanks for this. Can i just check something. Right now I am using the programIdIndex in each instruction of the transaction to check whether that instruction interacted with our program. will that index still only refer to the message["accountKeys"] node for a v0 transaction, or do i need to handle the readable/writable nodes myself.
    – daoplays
    Commented Jul 25, 2022 at 8:13
  • 1
    new question -> new post
    – trent.sol
    Commented Jul 25, 2022 at 18:18
  • "The gist on v0 transactions is that they add" - this is confusing. What was the version before version 0?
    – mikemaccana
    Commented Jan 9, 2023 at 15:38

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.