Arrow icon
Ness Labs: Make the most of your mind
Learn more about Joggo

A Summary of

The hitchhiker’s guide to smart contracts in Ethereum

Manuel Araoz
View original

Getting Started with Smart Contracts on Ethereum

  • Ethereum was designed as a smart contract platform -- smart contracts run in the Ethereum Virtual Machine (EVM)
    • Turing Complete programming language
  • Each Ethereum operation has a cost measured in gas, and each gas unit consumed by a transaction must be paid for in Ether, based on a gas/Ether price which changes dynamically

Setting up your environment

  • Install and run the testrpc node; leave it running while you develop
  • Most popular language for writing contracts is Solidity
  • Truffle development framework helps with smart contract creation, compiling, deployment and testing

Writing your first Ethereum smart contract

  • Read-only functions that don’t perform any state changes cost no gas
  • Transactional function execution requires sending a transaction to the network and spending gas

Interacting with your smart contract

  • Use Truffle console to send messages via function calls and read its public state

Iterating the contract code

  • Every time you want to check if a document was notarized, you need to iterate through all existing proofs which makes the contract spend more gas

Deploying to the real testnet network

  • During development, run nodes in testnet mode so you don’t spend real money
  • To try it in the real network, you need a real testnet/livenet Ethereum client

Problems to avoid

  • Reentrancy, failure in sending, loops that can trigger gas limits, call stack depth limit, timestamp dependency
Related content
See all posts
Arrow icon