Loan state machine in Solidity

In this video we will create a loan smart contract with Solidity.

There will be 2 kind of parties interacting with the smart contract:

  • investors
  • borrowers

The investor will send Ether at the beginning of the loan, and at the end the borrower will reimburse the investor of the initial amount lent, plus some interest.

The loan has different phases (pending, active, closed), which can be modeled as a state machine. Luckily, Solidity has a construct called enum that is very convenient for state machines. We are going to use a State enum to build our loan state machine and keep our smart contract code clean

Leave a Reply

Your email address will not be published. Required fields are marked *