Great job! Now that we've got a shell for our contract, let's learn about how Vyper deals with variables.
State variables are permanently stored in contract storage. This means they're written to the Ethereum blockchain. Think of them like writing to a DB.
# @version >=0.2.4 <0.3.0
# This will be stored permanently in the blockchain
storedData: int128
In this example contract, we created a int128
called storedData
which holds a default value of 1
.
The uint256
data type is an unsigned integer (256 bit), meaning its value must be non-negative.
There's also an int128
(128 bit) data type for signed integers (a type to store positive and negative integers).
# @version >=0.2.4 <0.3.0
# This creates a constant uint256 with a value of 10
TEN: constant(uint256) = 10
In this example contract, we created a constant
uint256
called TEN
and set it equal to 10
.
Our Pokemon DNA is going to be determined by a 16-digit number.
In the coding area on right-side, declare a constant
uint256
named DNA_DIGITS
, and set it equal to 16
.