# Security of Smart Contracts 1: Overflow

By [Hicss](https://paragraph.com/@freesuton) · 2022-02-21

---

For the previous version of 0.6, solidity won’t check the overflow. For a uint8 variable with a maximum value of 255, when adding 1 to it, it will be 0.

![](https://storage.googleapis.com/papyrus_images/289bea8f4d377a5709d3fa1ddbb3b8d266ddb63c17590ba31d47a7f8241eae56.png)

![](https://storage.googleapis.com/papyrus_images/0a5cf02325a523eaeda086c7f60d85b7f7196b7269934c56a71d23507f932a7a.png)

Example for an attacker to exploit the contract.

When the attacker call transfer without any balance, the value will be overflow and will be a very large amount. So the attacker will get a very large amount of tokens.

![](https://storage.googleapis.com/papyrus_images/f8088f47c8f0e0d22713aa1ff06c2d93ca83d086ffbf492e7d2dc0642128ad4f.png)

![](https://storage.googleapis.com/papyrus_images/4a79915700e987801b7a64f83ff12e81071a03862000593a7b04dbc103723569.png)

---

*Originally published on [Hicss](https://paragraph.com/@freesuton/security-of-smart-contracts-1-overflow)*
