Back to Home

StructAndFor

program
0x127389741d50...5630c64362b5
FrontierContract #1,109Exact Bytecode MatchEdit this contract
Deployed September 13, 2015 (10 years ago)Block 228,566

A tutorial contract testing struct definitions and for loops in early Solidity.

Key Facts

Deployer
Cyrus Adkisson(0xcf684D...AD1Bac)
Deployment Block
228,566
Deployment Date
Sep 13, 2015, 02:17 PM
Code Size
630.0 B
Gas at Deploy
1,803,502
Transactions by Year
20151

Description

A tutorial contract from Cyrus Adkisson's solidity-baby-steps series (contract #65) testing struct definitions and for loop iteration. Combines structs with array storage and iterates over them, testing the interaction between these language features.

Deployed on September 13, 2015. Part of a numbered tutorial progression that systematically explored Solidity language features on mainnet.

Source Verified

SolidityExact bytecode match(630 bytes)
Compiler: soljson

Exact creation bytecode match. Author Cyrus Adkisson published source at https://github.com/cyrusadkisson/solidity-baby-steps/blob/master/contracts/65_struct_and_for_loop_tester.sol. Batch-matched against 357 deploy TXs from deployer 0xcf684dfb8304729355b58315e8019b1aa2ad1bac.

Heuristic Analysis

The following characteristics were detected through bytecode analysis and may not be accurate.

Detected Type: program

Frontier Era

The initial release of Ethereum. A bare-bones implementation for technical users.

Block span: 01,149,999
July 30, 2015March 14, 2016

Bytecode Overview

Opcodes630
Unique Opcodes56
Jump Instructions25
Storage Operations12

Verified Source Available

Source verified through compiler archaeology and exact bytecode matching.

View Verification Proof
Show source code (Solidity)
// This contract creates a 9x9 map of Tile objects. 
// Each tile has an elevation value (as well as an owner and descriptorContract which aren't used here)
// 
// In the constructor, the elevations are set to standard values via for loops.

contract StructAndFor {

    address creator;
    uint8 mapsize = 9;
    Tile[9][9] tiles; 
    
    struct Tile 
    {
        address owner;
        address descriptorContract;
        uint8 elevation;
    }
    
    function StructAndFor() 
    {
        creator = msg.sender;
        for(uint8 y = 0; y < mapsize; y++)
    	{
        	for(uint8 x = 0; x < mapsize; x++)
        	{
        		tiles[x][y].elevation = mapsize*y + x; // row 0: 0, 1, 2, 3, 4...   row 1: 9, 10, 11, 12
        	}	
        }	
    }
    
    function getElevation(uint8 x, uint8 y) constant returns (uint8)
    {
    	return tiles[x][y].elevation;
    }
    
    /**********
     Standard kill() function to recover funds 
     **********/
    
    function kill()
    { 
        if (msg.sender == creator)
        {
            suicide(creator);  // kills this contract and sends remaining funds back to creator
        }
    }
}

External Links