A tutorial contract testing fixed-size array passing as function parameters in Solidity.
Key Facts
Description
A tutorial contract from Cyrus Adkisson's solidity-baby-steps series (contract #47) that tests passing fixed-size arrays as parameters to Solidity functions. Explores how arrays are encoded in calldata and how they can be received and processed by contract functions.
Deployed twice on September 30, 2015. Part of a series of contracts (#47) testing different data passing mechanisms including arrays, bytes32, and strings.
Source Verified
Exact creation bytecode match. Author Cyrus Adkisson published source at https://github.com/cyrusadkisson/solidity-baby-steps/blob/master/contracts/47_array_passer.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.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
import "mortal";
// contract Descriptor {
// function getDescription() constant returns (uint16[3]){
// uint16[3] somevar;
// return somevar;
// }
// }
contract ArrayPasser is mortal {
address creator;
/***
* 1. Declare a 3x3 map of Tiles
***/
uint8 mapsize = 3;
Tile[3][3] tiles;
struct Tile
{
/***
* 2. A tile is comprised of the owner, elevation and a pointer to a
* contract that explains what the tile looks like
****/
uint8 elevation;
//Descriptor descriptor;
}
/***
* 3. Upon construction, initialize the internal map elevations.
* The Descriptors start uninitialized.
***/
function ArrayPasser(uint8[9] incmap)
{
creator = msg.sender;
uint8 counter = 0;
for(uint8 y = 0; y < mapsize; y++)
{
for(uint8 x = 0; x < mapsize; x++)
{
tiles[x][y].elevation = incmap[counter];
counter = counter + 1;
}
}
}
/***
* 4. After contract mined, check the map elevations
***/
function getElevations() constant returns (uint8[3][3])
{
uint8[3][3] memory elevations;
for(uint8 y = 0; y < mapsize; y++)
{
for(uint8 x = 0; x < mapsize; x++)
{
elevations[x][y] = tiles[x][y].elevation;
}
}
return elevations;
}
}