59

On etherscan:

-->> accounts >> contract accounts >> selecting one contract,

There are two types of transactions mentioned under No Of Transactions:

Normal transactions and Internal transactions.

What is the difference between them and why are the Normal transactions usually much less than Internal transactions?

1

5 Answers 5

18

Internal transactions, despite the name (which isn't part of the yellowpaper; it's a convention people have settled on) aren't actual transactions, and aren't included directly in the blockchain; they're value transfers that were initiated by executing a contract.

Check these answers as well

  1. TheDAO internal transactions
  2. How to get contract internal transactions
3
  • nicksmac: Are internal transactions the events laid into the logs? Is that what they are? Commented Jun 22, 2016 at 17:15
  • 1
    @ThomasJayRush its value transfers that were initiated by executing a contract.
    – niksmac
    Commented Jun 23, 2016 at 1:30
  • @ThomasJayRush no, they are just calls from one contract to another
    – Ethan
    Commented Jul 23, 2016 at 4:15
16

In the Ethereum protocol there's only transactions and message calls. A transaction is a type of message call.

A transaction may perform other message calls, but these are not transactions (even though blockchain explorers may label them inaccurately as "internal transactions"). These (internal) message calls are not published on the blockchain.

To try illustrating, a transaction in Javascript looks like:

{
  from: ...,
  to: "C1",
  value: ...,
  gas: ...,
  data: ...,
  gasPrice: ...,
  nonce: ...
}

This is what you will see on the blockchain: a "Normal transaction". An "Internal Transaction" is the effects of taking the data part, feeding it to the contract C1, and executing the Ethereum Virtual Machine. The data is what tells C1 that it should call another contract C2: there is no separate {from:C1, to:C2,...} object on the blockchain that's needed.


Contracts calling each other, along with receiving payment, is the reason why "Normal transactions are usually much less than Internal transactions". For example, TheDAO tokens were originally purchased by calling a function on TheDAO and sending ETH with it.

2
  • 1
    When you say "These (internal) message calls are not published on the blockchain", isn't that false since all the data is public and contained in a block, assuming of course the transaction was mined? Commented Dec 14, 2017 at 22:52
  • 2
    @mecampbellsoup The internal message calls can be derived since indeed all blockchain data is public, but you also need to execute the EVM as the answer explains. They are not "published" in the sense that most clients do not provide a "lookup" for them.
    – eth
    Commented Dec 30, 2017 at 13:15
12

An internal transaction is not a real transaction - it has no signature and is not included in the blockchain. It is the result of a contract initiating a value transfer, or calling another contract, typically using the CALL opcode.

"Similar" opcodes are: CALL, CREATE, CREATE2, CALLCODE, DELEGATECALL, SELFDESTRUCT.

2
  • 4
    full list of opcodes is: CREATE, CALL, CALLCODE, DELEGATECALL, SELFDESCTUCT
    – Nulik
    Commented Dec 2, 2017 at 0:23
  • Why does a contract need to call another contract for a value transfer? Can it not just make the value transfer within itself?
    – Ini
    Commented Mar 13, 2021 at 14:34
4

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when a transaction with associated input data (contract interaction) is made to it. Source.


As @nick-johnson nicely demonstrated the concept in this link:

Internal transactions, despite the name (which isn't part of the yellowpaper; it's a convention people have settled on) aren't actual transactions, and aren't included directly in the blockchain; they're value transfers that were initiated by executing a contract.

As such, they're not stored explicitly anywhere: they're the effects of running the transaction in question on the blockchain state. Blockchain explorers like etherscan obtain them by running a modified node with an instrumented EVM, which record all the value transfers that took place as part of transaction execution, storing them separately.

For more info, take a look at this link.


To understand this, check out the following example:

The EOA address A wants to send some ERC-20 tokens to the EOA address C. To do this, the EOA address A should make a transfer transaction to the ERC-20 Contract address B, with these parameters:

tx_obj = {
            'from'      : EOA_address_A,
            'to'        : ERC_20_Contract_address_B,
            'value'     : 0,
            'data'      : data,
            'gas'       : estimated_gas,
            'gasPrice'  : web3.eth.gas_price,
            'nonce'     : web3.eth.get_transaction_count(EOA_address_A),
            'chainId'   : web3.eth.chain_id
            }

wherein

estimated_gas = self.w3.eth.estimate_gas({
            'from'      : EOA_address_A,
            'to'        : ERC_20_Contract_address_B,
            'value'     : 0,
            'data'      : data,
            'nonce'     : web3.eth.get_transaction_count(EOA_address_A),
            'chainId'   : web3.eth.chain_id
            })

and

data = contract_token.encodeABI(fn_name="transfer", args=[EOA_address_C, to_wei(amount, 'ether')])

wherein

contract_token = web3.eth.contract(address=ERC_20_Contract_address_B, abi=ERC_20_Contract_address_B_abi)

In this example, the EVM recognizes tx_obj as transaction parameters : 0 amount from EOA_address_A to ERC_20_Contract_address_B with "data" as data. This is called a transaction.

The so called Internal transaction is the consequence of this transaction. i.e., with this transaction made, by triggering the transfer function in the ERC_20_Contract_address_B and passing the "data" provided by this transaction, ERC_20_Contract_address_B's transfer function will be run and tokens will be transferred to EOA_address_C.

Because of this fact that running this function won't change the blockchain state (despite the main transaction), the EVM won't recognize this as a transaction and people conventionally call this an internall transaction. However, blockchain explorers like etherscan obtain them by running a modified node with an instrumented EVM, which record all the value transfers that took place as part of transaction execution, storing them separately.

1
  • 1
    Because of this fact that running this function won't change the blockchain state (despite the main transaction) but EOA_address_C gets a tokens transferred to it, hence I believe there will be change of the blockchain state. Right?
    – dade
    Commented Jan 11, 2023 at 15:24
-1

Internal transactions are ETH transfers from smart contracts, there's a good explanation on the different kinds of transfers here: https://docs.alchemyapi.io/alchemy/guides/using-webhooks#address-activity

Also, you can now get notifications for internal transactions using Alchemy https://blog.alchemyapi.io/blog/internal-transactions-notifications

1
  • 1
    Welcome to the Ethereum Stack Exchange! A number of you from Alchemy have been posting duplicate answers without answering the question more precisely. Some of the duplicate answers that do not answer the question have been deleted. Some questions may be an opportunity to demonstrate how Alchemy actually helps or solves the question is asking.
    – eth
    Commented Apr 1, 2021 at 0:24

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.