Substrate Developer Hub

Substrate Developer Hub

  • Tutorials
  • Knowledge Base
  • Recipes
  • API Reference
  • Languages iconEnglish
    • 简体中文
    • 繁體中文
    • Help Translate

›Runtime

Getting Started

  • Overview
  • Installation
  • Getting Started on Windows
  • Glossary

Learn Substrate

  • Extrinsics
  • Transaction Pool
  • Account Abstractions
  • Session Keys
  • Transaction Weight
  • Off-Chain Features

Runtime

  • Runtime Overview
  • Runtime Primitives
  • FRAME
  • Pallets
  • Runtime Macros
  • Runtime Metadata
  • Runtime Storage
  • Runtime Origin
  • Runtime Execution
  • Runtime Events
  • Runtime Errors
  • Transaction Fees
  • Off-Chain Workers
  • Debugging
  • Runtime Tests
  • On-Chain Randomness
  • Runtime Upgrades

Smart Contracts

  • Overview
  • ink! Smart Contracts
  • ink! Concepts
  • ink! Development
  • EVM Pallet
  • ink! F.A.Q.

Integrate

  • Polkadot-JS
  • Client Libraries
  • Chain Specification
  • The Subkey Tool
  • Memory Profiling

Advanced

  • SCALE Codec
  • Consensus
  • The Block Import Pipeline
  • Executor
  • Cryptography
  • Storage
  • SS58 Address Format

Contribute

  • Help Translate
Edit

Runtime Origin

The runtime origin is used by dispatchable functions to check where the call came from.

Raw Origins

Substrate defines three raw origins which can be used in your runtime module:

pub enum RawOrigin<AccountId> {
    Root,
    Signed(AccountId),
    None,
}
  • Root: A system level origin. This is the highest privilege level.

  • Signed: A transaction origin. This is signed by some public key and includes the account identifier of the signer.

  • None: A lack of origin. This needs to be agreed upon by the validators or validated by a module to be included.

Custom Origins

You are also able to define custom origins that can be used for authorization checks in your runtime functions.

More details TODO

Custom Origin Call

You can construct calls within your runtime with any origin. For example:

// Root
proposal.dispatch(system::RawOrigin::Root.into())

// Signed
proposal.dispatch(system::RawOrigin::Signed(who).into())

// None
proposal.dispatch(system::RawOrigin::None.into())

You can look at the source code of the Sudo module for a practical implementation of this.

Next Steps

Learn More

  • Learn origin is used in the decl_module macro.

  • Learn

Examples

  • View the Sudo module to see how it allows a user to call with Root and Signed origin.

  • View the Timestamp module to see how it validates an a call with None origin.

  • View the Collective module to see how it constructs a custom Member origin.

  • View our recipe for creating and using a custom origin.

References

  • Visit the reference docs for the RawOrigin enum.
Last updated on 9/30/2020 by Dan Forbes
← Runtime StorageRuntime Execution →
  • Raw Origins
  • Custom Origins
  • Custom Origin Call
  • Next Steps
    • Learn More
    • Examples
    • References
Substrate Developer Hub
Developer Hub
TutorialsKnowledge BaseRecipesAPI Reference
Community
Community HomeNewsletterSubstrate Technical ChatSubstrate SeminarStack OverflowTwitterEvents
More
Substrate Builders ProgramBlogSubstrate GitHubDeveloper Hub GitHubPrivacy PolicyTerms of UseCookie Settings
Copyright © 2021 Parity Technologies