Crate pallet_im_online

source ·
Expand description

I’m online Pallet

If the local node is a validator (i.e. contains an authority key), this pallet gossips a heartbeat transaction with each new session. The heartbeat functions as a simple mechanism to signal that the node is online in the current era.

Received heartbeats are tracked for one era and reset with each new era. The pallet exposes two public functions to query if a heartbeat has been received in the current era or session.

The heartbeat is a signed transaction, which was signed using the session key and includes the recent best block number of the local validators chain as well as the NetworkState. It is submitted as an Unsigned Transaction via off-chain workers.


Public Functions

  • is_online - True if the validator sent a heartbeat in the current session.


use pallet_im_online::{self as im_online};

pub mod pallet {
	use super::*;
	use frame_support::pallet_prelude::*;
	use frame_system::pallet_prelude::*;

	pub struct Pallet<T>(_);

	pub trait Config: frame_system::Config + im_online::Config {}

	impl<T: Config> Pallet<T> {
		pub fn is_online(origin: OriginFor<T>, authority_index: u32) -> DispatchResult {
			let _sender = ensure_signed(origin)?;
			let _is_online = <im_online::Pallet<T>>::is_online(authority_index);


This pallet depends on the Session pallet.



  • The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
  • Autogenerated weights for pallet_im_online


  • A type that is the same as OpaqueNetworkState but with Vec replaced with [WeakBoundedVec<Limit>] where Limit is the respective size limit PeerIdEncodingLimit represents the size limit of the encoding of PeerId MultiAddrEncodingLimit represents the size limit of the encoding of MultiAddr AddressesLimit represents the size limit of the vector of peers connected
  • Heartbeat which is sent/received.
  • An offence that is filed if a validator didn’t send a heartbeat message.

Type Definitions

  • A tuple of (ValidatorId, Identification) where Identification is the full identification of ValidatorId.
  • A type for representing the validator id in a session.