I'm trying to access data that I'm storing through the RPC off-chain endpoint. enter image description here

Is there any way to get the instance of off-chain storage in service.rs through which we can extract that has been stored using the front-end?

  • 1
    Please provide your exact code when you are writing the data to the offchain storage, and an exact screenshot of how you are trying to read it it via the RPC. I can already tell you that you are using the set RPC here, not get, which is wrong.
    – kianenigma
    Mar 21, 2022 at 19:45
  • 1
    @kianenigma the way I read the question is the inverse of what you have. I think Pawan is saying they are storing the data through this localStorageSet endpoint as displayed, and now not getting anything back when trying OffchainStorage::get() in code. Not sure if this changes your answer. Mar 21, 2022 at 23:37

1 Answer 1


On the client-side we can get the off-chain storage instance from shared backend instance (which is of type Arc < FullBanckend >). This instance can be find inside new_full().

After getting the Bankend's shared instance, we can access our off-chain storage like this:

// The relevant ocw storage instance.
let ocw_storage = backend.offchain_storage();

// Prefix for accessing values for our application.
let prefix = &sp_offchain::STORAGE_PREFIX;

// Get our value
ocw_storage.get(prefix, key);

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.