The second incrementer from the solidity-baby-steps tutorials, written to show what a transactional call looks like from geth.
Historical Significance
The ethereum.org token tutorial is where most people who deployed a token in this period started, and this is its opening form: a balance mapping, a guarded subtraction and the metadata a wallet needs to show a name. It has no allowance, so nothing can spend on a holder's behalf and no exchange or escrow can be given a limit. That gap is exactly what ERC-20 was written to close, and copies like this one are the before picture.
Context
Deployed 3 September 2015, during the Frontier era.
Key Facts
Description
Example 21 of the solidity-baby-steps tutorial series, deployed by the author of the series. increment takes an amount and adds it to a counter, writing a short status string into storage as it goes so that the caller can tell from geth which branch ran. The source carries the geth command line it was written to demonstrate. Anyone can call increment; the creator address is recorded but never checked.
Source Verified
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)
// Submitted by EthereumHistory (ethereumhistory.com)
// This contract demonstrates a simple non-constant (transactional) function you can call from geth.
// increment() takes ONE parameter and merely increment the "iteration" value by that much.
// see below for the geth command to send the parameter to the increment(int howmuch) function.
contract Incrementer2 {
address creator;
int iteration;
string whathappened;
function Incrementer2()
{
creator = msg.sender;
iteration = 0;
whathappened = "constructor executed";
}
// call this in geth like so: > incrementer2.increment.sendTransaction(3, {from:eth.coinbase}); // where 3 is the howmuch parameter
function increment(int howmuch)
{
if(howmuch == 0)
{
iteration = iteration + 1;
whathappened = "howmuch was zero. Incremented by 1.";
}
else
{
iteration = iteration + howmuch;
whathappened = "howmuch was nonzero. Incremented by its value.";
}
return;
}
function getWhatHappened() constant returns (string)
{
return whathappened;
}
function getIteration() constant returns (int)
{
return iteration;
}
/**********
Standard kill() function to recover funds
**********/
function kill() returns (bool)
{
if (msg.sender == creator)
{
suicide(creator); // kills this contract and sends remaining funds back to creator
return true;
}
else
{
return false;
}
}
}
/*
> incrementer2.increment.sendTransaction(3, {from:eth.coinbase});
"0x9cbceb6f5c3819322f48d0f01d111ac4b6223a2427447e857f493084da886ce5"
> incrementer2.getWhatHappened();
"constructor executed"
> incrementer2.getWhatHappened();
"howmuch was nonzero. Incremented by its value."
> incrementer2.getIteration();
3
> incrementer2.increment.sendTransaction(-7, {from:eth.coinbase});
"0x4e251eb394e2ba82536cbbb2ab88b9b7da94ffccd106bb3051394cbcc8280f66"
> incrementer2.getIteration();
-4
> incrementer2.increment.sendTransaction({from:eth.coinbase});
new BigNumber() not a number: [object Object]
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at <unknown>
at encodeParams (<anonymous>:-13909:-61)
at toPayload (<anonymous>:-103977:-61)
> incrementer2.increment.sendTransaction(.0004, {from:eth.coinbase});
"0x5bd69b68afca88f7521b25e55af8bcd6d9b8edff0ec455b3f7fd772ea03c163e"
> incrementer2.getIteration();
-4
> incrementer2.getWhatHappened();
"howmuch was zero. Incremented by 1."
> incrementer2.getIteration();
-3
>
*/External Links
Related contracts
GetBalance
Same deployerCyrus Adkisson experimental getter (Sep 2015) exposing the ether balance of a hardcoded address via getMyBalance(). Verified byte-for-byte with soljson v0.1.1.
0x759ad4...239a87August 26, 2015Contract 0xddcd64...a08e7b
Same deployerThe greeter tutorial contract: it stores a greeting set at deployment and can be shut down by its owner.
0xddcd64...a08e7bAugust 26, 2015basicInfoGetter
Same deployerA tour of the EVM globals, carrying the constructor of the file it was copied from
0xad826c...d33547August 31, 2015Contract 0x3ea0db...b922e0
Same deployerThe basic info getter from the solidity-baby-steps tutorials, a read only window onto the block and message globals.
0x3ea0db...b922e0August 31, 2015Contract 0xba575c...78733f
Same deployerA contract built to probe what the msg globals actually return, endowed with 5 ETH, deployed 1 September 2015.
0xba575c...78733fSeptember 1, 2015Contract 0x8b180c...c084df
Same deployerA third deployment of the msgExaminer that records its own creation message
0x8b180c...c084dfSeptember 1, 2015