How to choose the right variable in Solidity?

github logo ・1 min read

In Solidity smart contracts, there are 3 types of variable:

  • Fixed-size types
  • Variable-size types
  • User-defined types

There are many different kind of variables, but the one I used the most are:

  • uint, to represent numbers, like amount for ether / ERC20 token transfers
  • address to specify recipient of transfers
  • arrays, to represent collection of data
  • mappings to also represent collection of data but this time when we want easy retrieval with a key
  • struct to represent some structured data, like a user

The full video is available here:

twitter logo DISCUSS
Classic DEV Post from Oct 11

What was your win this week?

Got to all your meetings on time? Started a new project? Fixed a tricky bug?

Julien Klepatch profile image
I teach Blockchain developers how to build Ethereum Dapps on and Covers Smart Contracts, Solidity, Truffle and Web3.