Substrate Types and Traits

To access Substrate specific types, the module's Trait must inherit from the SRML. For example, to access the Substrate types Hash, AccountId, and BlockNumber, it is sufficient to inherit the system module:

# #![allow(unused_variables)]
#fn main() {
pub trait Trait: system::Trait {}

This provides access to the types Hash, AccountId, and BlockNumber anywhere that specifies the generic <T: Trait> using T::<Type>. It also provides access to other useful types, declared in the pub Trait {} block in systems/src/


Unlike in smart contract development, the way to inherit shared behavior is not to directly import other modules. Instead, it is common to either implement the same logic in the new context or utilize a trait from srml/support to guide the new implementation. By abstracting shared behavior from the runtime modules into srml/support, Substrate makes it easy to extract and enforce best practices in the runtime. You can find the trait documentation here. See Using Balances for an example of usage.