DEV Community

Julien Klepatch
Julien Klepatch

Posted on • Originally published at

How to choose the right variable in Solidity?

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:

Discussion (0)