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 May 10

Why I ignore the hype (and you should too)

It’s been 20 years since I made my first website. I've been burned by the hype ti...

Julien Klepatch profile image
I teach Blockchain developers how to build Ethereum Dapps on https://eattheblocks.com and https://www.youtube.com/channel/UCZM8XQjNOyG2ElPpEUtNasA. Covers Smart Contracts, Solidity, Truffle and Web3.