Take our survey for a chance to win $50 Take our survey for a chance to win $50

Introduction to Smart Contracts on the Ethereum Network

While the first widespread application of the blockchain technology was the Bitcoin network and financial operations, most of the current work in the blockchain space is being done with decentralized applications, smart contracts and various versions of blockchain technology that are based on the Ethereum network.

While the details of every smart contract on the Ethereum network are going to be different, all contracts do have certain things in common.

A smart contract on the Ethereum network has four parts to it. The first part is the computer code that describes what happens when the contract is active and once it terminates. The next part is storage of the contract on the blockchain network. Then, there is execution by the computers on the network. Finally, there are updates to the blockchain and payments of currency.

Smart contracts on the Ethereum network create virtual logs with events that occur as a result of contract implementation. Virtual logs do not have an impact on the execution of a contract. At the same time, contracts do have functions that can alter the state of a contract after the values of the contract change. Parties can and should agree on these functions before activating a contract, so that the money would move between accounts after the contract and the network verify compliance to the conditions described in the contract.

The primary variables that identify Ethereum wallets for the withdrawal and deposit of funds are addresses. After your smart contract becomes active on the network, it will also get its unique address. The address of the contract will be different from the address of the creator of the contract, even though the contract will contain information about its creator.

The next variable present in a smart contract on the Ethereum network is the size of the contract.

 

Getting started with a smart contract

Before you create a smart contract on the Ethereum network, you need to think about what information the contract will need to store and how it will determine that the conditions of the contract are being met. One of the best approaches is to make a list with the general structure of your agreement. Typically, the network will store the details of the contract as a mapping of a number of individual transactions and the details about each transaction in the contract.

In your contract, you should define two different struts. The first one should contain information about the party initiating the transaction and about its amount. The second should describe storage and mapping.

Once you do that, you should describe the exact functions that your contract is going to execute on a regular basis and criteria that will make the contract initiate the functions. In you contract, you can use proposer transactions. Those are the actions by the party that created the contract. Initial conditions typically include limits of an agreement, wallet information for the deposit of funds and the description of when the deposit is going to happen.

Investor transactions in a smart contract on the Ethereum network are the ones that are initiated by someone other than the contract creator. These transactions go into the account specified previously. If a contract has a time limit, it will generate the final transaction when the limit is over.

At this point, a user has an option of choosing what will happen with the funds that the contract collects. If you are a creator of a contract, you should first create a dummy contract, list yourself as an investor and go through the iterations of the contract to check that it will work the way you want it to.

Once you write the code for your contract, you will need to compile it into a format that the network will be able to accept. You can do this by using Solidity online compiler located at Etherchain.org/solc. After you compile your contact, upload it, pay for it with Ether and sign it with your private key. Finally, there is deployment of your contract on the Ethereum network.