Smart contract (also self-executing contract, blockchain contract, or digital contract) is an electronic algorithm intended for the automation of the contract execution process in the blockchain. The general idea of smart contracts is to exclude divergences in the treatment of the agreement terms by the entered parties.
Smart contracts are basically just computer code that is stored in a distributed blockchain. Because the blockchain is distributed, a copy of it is stored in each computer of the network. This implies that a copy of the smart contracts code is also stored in each computer of the network, and can in fact be executed in the same way by each computer. In the Ethereum blockchain, the code is executed in a specific environment: the Ethereum Virtual Machine (EVM). Every network node (i.e. each computer) will verify new blocks by going through the transactions included in it and implementing the codes initiated by them in the EVM. Since they all have an exact copy of the same chunk of code, each network node makes the same calculations, saving equal values