I want to modify some on-chain storage from offchain worker by sending a signed transaction, so I write a dispatch function which handles the transaction. But the dispatch function also can be accessed from other way as normal(such as a user sign an extrinsic out of blockchain). I want to block the other ways so the on-chain storage only can be modified by offchain worker. How to do this, or is there any method that can distinguish different access path?

Or how can I extract the KeyTypeId from AccountId?

  • why not just check the origin of the transaction?
    – dadzerlaze
    May 24, 2023 at 8:12

1 Answer 1


The pallet::call macro requires the function to be public. So it's either in the frontend you just don't expose the function but anyhow a user can access the function (using polkadot js to interact with your chain).

Because even the ofchain worker requires the Call to be public.

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.