My first smart contract! What did I learn?

Cryptocurrency News and Public Mining Pools

My first smart contract! What did I learn?


This post is about what I learned in the journey of my first smart contract development using solidity as the programming language. This is not a 100% super tutorial on how to develop smart contracts. If you are looking for one I was inspired by this :

This info is like a story and notes of my brain trying to create its first smart contract. Please feel free to correct me or share a better explanation. I will really appreciate the feedback.

When I searched for "smart contracts development" I found many resources where they suggest to use the truffle framework but also some of them said that Remix was a good tool to start, so I went with this one (Remix.ethereum) why? because I wouldnt need to install NodeJS and truffle to achive my simple goal that was to create the SC and interact with it as easy as possible

Smart Contract

The idea behind this smart contract consist in having a parent that wants his kid to withdraw the money deposited after certain date. You can check the code here:


  1. Due to I am using solidity, in any smart contract I should define the compiler version. I do this in the first line of code where I write "pragma solidity = 0.8.1;"
  2. To store an address I define a variable as address type. In this case I'll store the parent and kid addresses
  3. The person who deploy the smart contract is the parent so that is why in the constructor I set the parent address to the one who send the transacion (msg.sender)
  4. What does it mean having external in a function? So after some reading I understood that external is a type of visibility that solidity functions could have. Also, external functions cannot be called internally and they can be cheap (in terms of gas) due to the data is not copied to memory. These are some good links:
  5. What does it means having payable in a funcion? It means that the smart contract can recieve some ether throught this function, the ether sent in the transacion will be added to the balance of the smart contract. If I sent ether to a non payable function it will throw an error. I found this in stackexchange and I liked it.
  6. What about payable()? I could say that in ethereum there are 2 types of address: normal address and payable address. We can only send ether to payable address so payable() will convert the normal address into a payable address
  7. I can view how much ether the smart contract has by address(this).balance

Future tasks

  1. How can the parent add more kids?
  2. How can the parent add more balance to the kid

submitted by /u/bloodkn07
[link] [comments]

Facebook Comments