9

I often see the two words used interchangeably. This has led me to read the docs:

Extrinsics fall into three categories: inherents, signed transactions, and unsigned transactions.

extrinsic

Data that is external to the blockchain and included in a block. In general, there are two types of extrinsics:

  • signed or unsigned transactions.
  • inherents inserted by block authors.

transaction

A type of extrinsic that can be safely gossiped between nodes on the network because it can be verified through signatures or signed extensions.

What is the difference between an extrinsic and a transaction? Is a transaction an extrinsic?

2 Answers 2

12

Yes, in Substrate, transactions can generally be thought of as any piece of data that's intended for the transaction pool (and consequently, could potentially be included in a block). But there are technical nuances needed to be spelled out: the term "transaction" is in fact quite misleading, although does have merit from a user friendliness perspective (yes, technically extrinsic pool would be more accurate).

Extrinsics (a.k.a. Types of Transactions)

In Substrate, a "thing that could exist in the transaction pool" — more commonly known as "a transaction" in the non-Substrate world — can be one of 3 distinct types, all of which fall under a broader category called "extrinsics". Extrinsics is just a general term to mean "any information that originates from outside a runtime". These are:

  • Signed transactions: these must contain the signature of the account sending the inbound request to the runtime. With signed transactions, the account used to submit the request typically pays a transaction fee and must sign it using the account's private key.
  • Unsigned transactions: these don't carry any information about who submitted the transaction, since the format of this type of transaction doesn't require a signature. You can define what conditions must be met for such a transaction to be valid (FRAME has an attribute macro to do this).
  • Inherents: are a special type of unsigned transaction made by block authors which carry information required to build a block such as timestamps, storage proofs and uncle blocks.

Key differences

Here are some key differences between the different types of extrinsics:

  • Contrary to signed transactions, unsigned transaction types require implementing custom validation logic which can consume more resources for checking validity compared to signed transactions.
  • Unsigned transactions have no economic deterrent to prevent spam or replay attacks, so custom logic must account for protecting the network from these types of transactions being misused.
  • Inherents exist to address the need of adding some data to a block, whereas signed or unsigned transactions exist to potentially change the state of the blockchain.

Examples

Here are some examples of each type of extrinsic being used in different scenarios:

Scenario Function call example Type Reason
Bob wants to send some tokens to Alice and tip the block author to give this transaction more priority, using the Balances pallet. pallet_balances::Call::transfer in Polkadot Signed transaction This function can be called by any account, so we must ensure that the caller signs the transaction and pays a fee for it to be processed.
Charlie proposes a tip to reward Dave using the Tipping pallet. pallet_tips::Call::report_awesome in Polkadot Signed transaction This function is designed so that any account can call it, by depositing some amount and giving a reason for the tip which will be stored on-chain.
The on-chain council passes some motion that includes submitting a batch of valid transactions to be executed. pallet_utility::Call::batch in Polkadot Unsigned transaction This type of extrinsic can only be submitted if a majority of the council approves it and cannot be executed by any single account.
A validator node sends a signal to the network to indicate it's online. pallet_im_online::Call::heartbeat in Kusama Unsigned transaction This can only be called by a node that's registered as a validator in the network, which is verified as part of an internal check of the function's logic and allows the node to call it without paying any fees.
The network wants block authoring nodes to include the current timestamp into the blocks they produce. pallet_timestamp::Call::now in Kusama Inherent This is a special extrinsic that can only be included in a block by an authoring node.
A parachain needs to send its relay chain the validation data the relay chain expects. paras_inherent::Call::enter in Kusama Inherent This is a special type of extrinsic that can only be sent by a collator node.
4

Broadly speaking an extrinsic is data that is external to the blockchain that is included in a block - think of the extrinsic root in a block with all its children (example). You can think of an extrinsic as a broader term to encompass, as the definition says, inherents, signed transactions, and unsigned transactions - these are all types of extrinsics.

Is a transaction an extrinsic?

Yes, in the same sense that a rose is a flower.

A transaction is a type of extrinsic.

3
  • 1
    You could also send inherents into the transaction pool, as they are unsigned transactions. However, the inherent implementation should prevent that inherents are applied more than once per block.
    – bkchr
    Apr 29, 2022 at 8:59
  • Inherents aren't runtime calls. Time stamps are a good example. Apr 29, 2022 at 14:48
  • Edited my answer.
    – Bruno
    Apr 29, 2022 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.