3

According to Substrate doc on Runtime development: "...the runtime for a Substrate node contains all of the business logic for executing transactions, saving state transitions, and interacting with the outer node."

Can anyone please point out where the APIs are for these functions? ("executing transactions, saving state transitions, and interacting with the outer node.") Is it "sp_api"? (https://docs.substrate.io/main-docs/fundamentals/runtime-intro/)

My understanding is that we don't need FRAME and Pallets to build a runtime, and building one from scratch probably is necessary to better understand how Substrate works under the hood.

Is there an example how this can be done?

2 Answers 2

2

Well you have misunderstood the docs. So Substrate is divided into substrate node and the runtime. The runtime is the state transition function which contain custom logic. But also there is FRAME framework for building the runtime.

The runtime compiles to WASM. So it means you can build your own runtime framework and compile it to WASM but this is the hard path because all developers are using the existing FRAME , so you will have little help building your own runtime framework. But this gives much flexibility which in most cases you wouldn't want it. So it is just better to use FRAME because there alot of modules/pallets which are present to help you and never re-invent the wheel. And learning FRAME just follow the documentation. And if you want to understand the substrate node, just follow the codebase. Because the focus is on the runtime and the whole node logic is abstracted away.

2

You can refer to frameless-runtime, which is a minimal substrate runtime implementation written from scratch.

It doesn't use the construct_runtime! macro, instead it manually implements the required methods on the Runtime struct, which in turn are used to implement various runtime apis. You can check the impl Runtime { ... } and impl_runtime_apis! { ... } code block for details.

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.