My first experience with writing an Ethereum smart contract with Solidity and key takeaways
July 12, 2021

Reading Time: ( Word Count: )

I started learning solidity and wrote my first smart contract to mimic the functionalities of a bank. In this function that I wrote with the help of quest, features written include being able to:

  • Deposit Money
  • Get Account Balance
  • Validate Funds in account before being able to transact
  • Earn Interest on the money

Here is what I learned.

Solidity was developed specifically for the purpose of writing smart contracts on the blockchain.

A contract in solidity is the equivalent of class in other languages such a Py, JS etc

Other architecture is similar as in solidity also uses functions but it has predefined keywords that allow for a condensed form of powerful code

One of the biggest differences is that any user or any contract can inherently hold monetary balance or can be paid and has an inbuilt “payment account”. So there is no need for payment APIs like Stripe to be able to transact on the chain.

Public and Private Keywords determine the visibility of a function. Any public function can be called openly by anybody else on the chain.

“msg” variable is quite useful and it allows access to blockchain. msg.sender links to the account that calls a function, msg.value the amount in question, msg.gas the amount of available gas for the transaction

Each contract is first compiled and then deployed on the chain. The act of deploying a contract constitutes of a small fee, which is to cover the verification, time stamping and use of shared compute and storage resources on the blockchain.

Each transaction is executed in blocks or chunks alongside other transactions, which can cause a little bit of delay (usually in seconds).

Some useful keywords that came in handy → msg, balances, mapping, address, public returns, private returns, payable, deposittimestamps

For coding enthusiasts, my code can be found here: https://github.com/MinhasMA/Solidity/blob/master/BankSmartContract.sol%20

j

MORE PROJECTS