Open In App

What are ETH Internal Transactions?

Last Updated : 22 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Internal transactions are often used to clear or settle balances on the Ethereum platform. They can be contrasted with typical transactions, which are aimed at moving tokens from one account to another. This article focuses on discussing the following topics for ETH Internal Transactions:

  • What is ETH Internal Transactions?
  • Features of Internal Transactions.
  • Why Are Internal Transactions Not Visible In Wallet?
  • The Gas Cost Of Internal Transaction.
  • How Do Internal Transactions Affect The Balance In Wallet?
  • Internal Transactions vs External Transactions.
  • Conclusion.

Let’s start discussing each of these topics in detail.

What is ETH Internal Transactions?

Internal transactions have several uses, such as:

  • Creating a balance of tokens for new accounts created on-chain 
  • Clear or settle balances on the Ethereum platform 
  • Automatically creating local tokens for deployed contracts when they’re first requested 
  • Publishing approved contracts to the blockchain and transferring ownership of them, without actually “deploying” them locally by copying the code onto your machine. This is called “approval” mode and is most often used in conjunction with automated testing setups. 

All of these uses, however, share in common the fact that they ultimately change the balance of tokens in some accounts. They do not send tokens from one account to another. They allow you to change a balance simply by creating an internal transaction against that account’s contract code.

Features of Internal Transactions

  • Internal transactions do not broadcast to the blockchain the same way that normal transactions do. 
  • Instead, they are immediately reflected in the relevant account’s state and balance on the Ethereum node, whereas normal transactions must wait for a block to be mined and propagated through the network before they can be seen.
  • Internal transaction balances are not cleared with every block. They remain in place as long as a transaction is still active or until it’s explicitly cleared using another internal transaction. 
  • This is necessary because internal transactions have side effects on the local state that would not be desirable if they were automatically deleted after each block. 
  • Internal transactions are not always safe to attempt. 
  • Internal transactions are fully atomic, however: they may be committed at any time and rolled back at any time. This means that internal transactions can’t be overwritten by future transactions; they aren’t affected by soft forks or other types of changes to the blockchain’s consensus rules.

Why are Internal Transactions Not Visible in Wallet?

Internal transactions are not visible in the wallet because they are not sent out to the decentralized network. To use bitcoin one does not need to be part of a decentralized peer-to-peer network, but it does provide some benefits: 

  • One can see how much money everyone else has.
  • One can also choose who is allowed to send bitcoins to their address. But there is a trade-off: if the user is not part of that network then nobody can check that the user is allowed to use this money as well as nobody will ever know how much money the user’s address holds.

All Internal Transactions Must Have a Witness:

  • All internal transactions must have a witness, otherwise, the transaction cannot be committed to the blockchain and can fail when it is attempted in the network’s consensus process. 
  • The witness is simply a function that returns true for success or false for rejection. It is specified in Ethereum using the keyword ‘_W’ to denote a private function. 
  • The witness must return true in order to commit an internal transaction, otherwise, it will fail when attempted in the consensus process. The reason for this is that internal transactions have side effects on the local state, which could be considered invalid by a transaction derived from it.

The Gas Cost of Internal Transaction

Internal transactions are processed by the Ethereum node network in the same way that normal transactions are, by storing their transaction headers and then running their code to finalize the relevant state changes. 

  • This means that internal transactions have a gas cost just like normal transactions do, but, since gas is paid only when the transaction is successfully mined on the main chain, internal transactions have a lower gas cost than normal. 
  • As with most things in Ethereum, this low risk comes with a price: internal transactions can fail because they failed to pay sufficient gas. 
  • If this happens, they revert their state changes and return your tokens to their original values.

How Do Internal Transactions Affect The Balance in Wallet?

  • Internal transactions are always safe to try because they will always revert their state changes if they fail to commit.
  • Internal transactions automatically clear all existing side effects when you try to clear or settle them, so you only need to pay for a transaction once in order for it to succeed. This is not true for normal transactions, which can be replayed multiple times against your account.
  • It’s important that internal transactions are never considered to be “confirmed” (i.e. their state is locked in on the main chain) while they have side effects. In a single-chain environment, this could lead to internal transactions being considered confirmed when they have not cleared side effects that later cause them to revert. This risk is even greater in a multi-chain environment, where it’s difficult or impossible for nodes to know if a cleared state is present on any fork but the main one.

Internal Transactions vs External Transactions

Below are some of the differences between internal transactions and external transactions.

Internal Transactions

External Transactions

Internal transactions take place within one ledger. External transactions take place between different ledgers.
Internal transactions are transactions performed within the EVM and they are aimed at processing data. External transactions, on the other hand, deal with sending value from one user to another. 
Ethereum’s internal transactions let you send smart contracts from one wallet to another without having to use an exchange. External transactions are to be kept in mind as they allow you to send money from your wallet to someone else’s wallet. The contract of the sender and the recipient must be stored on the EVM.

The difference between Internal transactions and External transactions is that Internal transactions take place within one ledger and External transactions take place between different ledgers. 

  • If a cryptocurrency is considered an Internal transaction that would be a private or internal transaction, while if it is considered an External transaction that would be an external transaction. 
  • For example, if Alice wants to sell Bob on Amazon, Bob may be looking for a Blockchain-based marketplace like Amazon where he can buy the product from Alice more cheaply and easily.

Conclusion

Internal transactions are an underleveraged tool for interacting with the blockchain. They can make your interactions with deployed contracts much easier (especially in conjunction with state channels) and allow you to clear or settle balances on the platform without taking the risks associated with normal on-chain transactions. Internal transactions are also necessary for using several advanced low-level features such as automatic contract approval and ABI-encoding.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads