Facebook pixel Smart Contracts
Ethereum 101

Smart Contracts



Anyone can write code that runs on the World Computer One of the main benefits of the Ethereum blockchain is the addition of Smart Contracts. These allow code to be submitted to the State Transition, and to have their output added to the ledger. Contracts and accounts are identical during execution within the EVM, so a peer-to-peer payment is treated just like any other computation. In the Ethereum world, every action that can be registered can be encoded in software, and the entire network is able to compute the outcome simultaneously.

The Ethereum Virtual Machine executes code called Smart Contracts. When a contract is invoked by paying a fee, the network adds the related state changes to a new transaction, and the system propagates the update.
Smart Contract Creation

Smart Contract Creation

When a Smart Contract is deployed to the network, the creator pays a small fee, and can invoke it to trigger an event.
A: CREATE SOLIDITY SMART CONTRACT; B: COMPILE USING SOLIDITY COMPILER (SOLC); C: PERFORM DEPLOYMENT; D: STORES THE ABI AND CONTRACT ADDRESS; E: INSTANTIATES THE CONTRACT; F: INVOKE CONTRACT METHODS FOR DATA STORAGE; G: Passes the .sol file; H: Using the bytecode invokes deployment via Web3js; I: Returns the contract address and the ABI; J: Passes the address of the ABI of the contract; K: Passes all the parameters for the contract methods; L: Signs and passes Ether to perform the operation; M: ETHEREUM NODE.

In order to run a new smart contract, the creator must first deploy it to the chain and pay gas for that operation. This will return the newly created address of the contract, which can then be used for further configuration steps.

CREATING CONTRACTS

Once the code is written, the owner must submit the contract and pay for the fuel (Gas) to store the contract on the Ethereum Virtual Machine. Once the contract is submitted, the network will run it whenever someone pays for the appropriate amount of gas. Gas cannot be held in a wallet, but is instead purchased at the time of a transaction in order to fund its execution. The Gas Price, or the amount of Ether required to purchase computation, is scaled automatically to match the current amount of computation available in the network and the current demand for it. This flexible structure ensures that the network will not ever accept more computation demands than it can fulfill.

ORACLE

In the event that a smart contract needs to check for information outside of the Ethereum ecosystem, a third party such as an Oracle can be used to add that information to the blockchain. Oracle services provide external data for use in smart contracts, and are held accountable through staking or other incentive mechanisms on-chain. If enough Oracles are used, the information can be considered to be sufficiently reliable. Further consideration of Buterin's initial work on the concept may be beneficial.

AN EXPLOSION OF APPLICATIONS

While the basic functionality of Smart Contracts only goes so far, they can be structured in layers to create more complex functionality. As long as all of the individual contracts are funded with the proper amount of gas, there’s nothing stopping developers from building fully integrated apps entirely on these decentralized networks. In the remainder of this module, we’ll explore how this concept has been expanded, and how it turned 2017 into a gold rush for software developers.

Get Involved

The best part of blockchain is that anyone can get involved!