I have a pallet that does some light calculation on one or more storage items (GasReserve and IdleFunds below) or wraps some internal functionality. E.g.

impl<T: Config> Pallet<T> {
        pub fn get_time() -> Option<T::BlockNumber> {
        pub fn idle_surplus_funds() -> BalanceOf<T> {

I would want this function to be directly accessible to a frontend using polkadot.js API. These getters don't modify state, so I don't want to expose them as extrinsics using #[pallet::call]. Any fn defined as #[pallet::getter(fn fn_name)] on a storage item becomes available through api.query.pallet.fn_name

I want to similarly expose the above funtion which does not directly map to a single storage item. Is this possible somehow? Preferably without creating a RuntimeApi section on this pallet, these getters are not relevant to the substrate client, only to a web frontend.

Benefit of exposing these: Code duplication between frontend and backend is avoided (as the frontend would have to query the underlying storage items and then compute the result internally), helping maintainability.

1 Answer 1


V15 metadata will be exposing Runtime API type information for clients to consume in order to do things like generate web interfaces to make Runtime API calls. The state_call RPC method exists to allow people to call these runtime APIs and get back results in a web UI.

So, if you want to make some information available to the outside world, I would create a RuntimeApi for it, knowing that they can already do what you want, and support for calling them will only be improving over time :)

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.