Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the initial value of Ethereum contract variables?

I make some contracts code with mapping data. When I first access data value, ethereum returns 0.

Is it specification of ethereum? In other word, Can I write a contract on the assumption that variable's initial value is 0?

like image 830
Kenichi Kurimoto Avatar asked Jul 18 '16 02:07

Kenichi Kurimoto


1 Answers

Yes, this is the default behavior. Each types have a "zero-state" default value. For example boolean have a default value of false, integer a default value of 0 and strings a default value of ""

You can read more here http://solidity.readthedocs.io/en/develop/control-structures.html#default-value

like image 187
AlexN Avatar answered Nov 15 '22 13:11

AlexN