A simple on-chain mailbox: anyone can leave a message for the owner, who can read and clear them.
Key Facts
Description
Mailbox stores messages sent to its owner. It is one of Cyrus Adkisson's solidity-baby-steps examples from August 2015, among the earliest teaching contracts written in Solidity.
Source Verified
Exact runtime and creation bytecode match with soljson v0.1.1+commit.6ff4cd6, optimizer on. Source: github.com/cyrusadkisson/solidity-baby-steps mailbox.sol, revision blob 7a81b8eb8e (author original, verbatim). Verified on Etherscan. Not submitted to Sourcify: its oldest supported compiler is v0.1.7.
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)
contract Mailbox {
struct Message {
uint64 time;
string contents;
}
mapping (address => bytes32[]) hashes;
mapping (address => mapping(bytes32 => Message)) messages;
event NewMessage(address indexed recipient, bytes32 hash);
function sendMessage(address to, string contents) {
// Get message hash.
bytes32 hash = sha3(contents);
// Do we already have this message?
for (uint i = 0; i < hashes[to].length; i++) {
if (hashes[to][i] == hash) {
return;
}
}
// Is there a free slot?
for (i = 0; i < hashes[to].length; i++) {
if (hashes[to][i] == 0) {
break;
}
}
if (i == hashes[to].length) {
// No free slot - make the array bigger.
hashes[to].length++;
}
// Store the message.
hashes[to][i] = hash;
messages[to][hash] = Message(uint64(now), contents);
// Trigger event.
NewMessage(to, hash);
}
function getMessageHashes() constant returns (bytes32[]) {
return hashes[msg.sender];
}
function getMessageTime(bytes32 hash) constant returns (uint) {
return messages[msg.sender][hash].time;
}
function getMessageContents(bytes32 hash) constant returns (string) {
return messages[msg.sender][hash].contents;
}
function deleteMessage(bytes32 hash) {
delete messages[msg.sender][hash];
for (uint i = 0; i < hashes[msg.sender].length; i++) {
if (hashes[msg.sender][i] == hash) {
delete hashes[msg.sender][i];
}
}
}
}External Links
Related contracts
Ponzi
Same deployerA 102 percent pay-forward queue from 8 August 2015 that reverts on every deposit, appending to an array it never lengthens.
0xce44c7...75f579August 8, 2015MessagingContract
Same deployerAn early messaging contract on Ethereum, allowing users to send on-chain messages stored by content hash.
0xdc884e...45f48bAugust 8, 2015MessagingContract v2
Same deployerAn upgraded on-chain messaging contract with per-address message tracking and delete functionality, from the same Frontier developer who built the simpler Messa
0x18991f...dfff72August 8, 2015MessageStore
Same deployerA 6-line contract storing a single public string, deployed Day 9 of Ethereum by a prolific early experimenter who shipped 18 contracts in one week.
0xd2eccd...ff3d6bAugust 8, 2015OnChainProfile
Same deployerAug 8 2015 deploy by 0x8674c218 — one of the most prolific contract deployers of Ethereum's first day. Sibling of the verified MessagingContract / Ponzi / Messa
0x4ab020...f9d97dAugust 8, 2015MessagingContract
Same deployerAn on-chain messaging contract with per-address tracking and delete functionality, by the same Frontier developer who iterated on messaging across four deployme
0x97b29a...7c3532August 8, 2015