Can an Ethereum smart contract execute another smart contract?
Smart contracts on Ethereum
With this tutorial you will be able to take your first steps in the development of smart contracts on the Ethereum BlockchainX platform. With a simple example we will see how a contract is written, how it is deployed, how it is instantiated in your own private
Ethereum network and, most importantly, how it is executed.
1. Introduction
Blockchain technology is still a path in which there is much to explore and discover, but today we can already do interesting things with it apart from speculating with cryptocurrencies. Bitcoin led the way by allowing the exchange of cryptocurrency in a secure and decentralized manner. Ethereum goes further and can be considered as a second generation blockchain implementation in which the idea of exchanges between parties is generalized.
1.1. blockchain
In this tutorial I am not going to explain the details of what a blockchain is and how it works. However, being surely the most important concept of all this technology, I am going to comment on
what is going on for those who are still not clear about it.
I leave out many details so as not to divert the focus from the objective of this tutorial. A blockchain is a network to manage a decentralized account book that is replicated in each of the nodes that make up the network. This book consists of a sequential chain of immutable blocks, which would become the pages of the book. The new transaction notes are recorded in a new block that once full is “sealed” and added to the end of the chain.
In addition, cryptographic functions are used throughout the process to prevent information manipulation and guarantee data consistency.
1.2. Ethereum
In general terms, Ethereum is defined as a decentralized blockchain contract execution platform with no
trusted authority (zero trust). Contracts are scripts that define processes from simple cryptocurrency exchanges like Bitcoin does to complex policies that are triggered by events. Contracts work on tokens, which determine who participates in a contract and with how much value. Both the contract participants and the contract itself are identified by an account with a unique address. Participant accounts are called Externally Owned Accounts (EOA).
In addition to identifying each of the elements of the Ethereum network, the accounts serve as persistent information storage.
1.3. smart contracts
A normal contract specifies an agreement between parties with actions and conditions of performance. A contract becomes “smart contract migration” when it includes code and logic that execute actions and enforce conditions, that is, code that enforces the contract without the need for manual intervention by either party. The most interesting thing beyond that supposed “intelligence” is that the contract is executed within the network, in the Ethereum
Virtual Machine (EVM).
This execution is not free but is paid in the form of “gas”, a small amount of ether currency contributed by one or more of the participants in the contract. An important detail is that the execution is decentralized but not distributed, which means that it occurs in all the nodes of the network. The contract is developed in a specific language (Solidity, Serpent or Mutan), is compiled to EVM and, with few exceptions, complies with a standard interface called ERC20.
0