State Variable

Defining a contract for your SpacecryptFactory is great, it would be even better if your spacecrypt has some specifications. To this end, there are the so called state variables.

What is it

State variable are variable permanently associated to the contract storage. They are permanently stored on the blockchain.

In your factory, it would look like this.

contract SpacecryptFactory {
  // An integer variable
  uint public data = 42;



Every Spacecrypt has a timeout. It is a public uint variable and is set to 60.
pragma solidity ^0.4.24; contract SpacecryptFactory { // Declare timeout }

Data types

Data can have different types regarding what they describe. In the above example, timeout is an unsigned integer, denoted by uint. Let's have a look into various data types to extend our contract.


There are multiple types of integers.

  • Unsigned integers, written uint with values between 0 and 2^256-1 (believe me, it is a big number).
  • Integers, written int and values between -2^255 and 2^255-1.

Integers, either signed or unsigned, support common arithmetic operation such as

  • addition +,
  • substraction -,
  • multiplication *,
  • Euclidian division /,
  • remainder of Euclidian division %,
  • exponentiation **

Then, you can write the euclidian division of 2^64 by 3^16

// Exponentiation operator `**` has priority over euclidian division `/`
uint public division = 2**64 / 3**16;


Entities on blockchain are identified by their address. You have an address, I have an address and contracts have an address. Therefore, to select a specific entity, an address type is needed. Every address address hold 20 bytes written in hexadecimal notation.

address public example = 0x00000123456789abcdef;


Integers and addresses are good identifiers. However, is your name a number? String of characters, known as bytes32, are there to handle text format.

// Notice strings support Unicode
bytes32 public name = 'John doe 😃';



Give your SpacecryptFactory its own sweet name
pragma solidity ^0.4.24; contract SpacecryptFactory { // Default spaceship timeout uint public timeout = 60; // Name of your factory bytes32 public name = ; }