A Solidity string utility library authored by Piper Merriam and deployed on October 12, 2015, providing functions for converting between unsigned integers and s
Historical Significance
StringLib is among the first named and explicitly attributed Solidity utility libraries on Ethereum. Merriam's author attribution with an email address in on-chain source code represents an early norm in open-source smart contract development. The two-library wrapper pattern used here, where StringUtils delegates to StringLib, was an early exploration of library composition patterns in Solidity.
Context
The Ethereum Frontier era in October 2015 lacked shared library infrastructure. Developers deploying utility code had to write, compile, and deploy their own helper contracts. Merriam's cluster of utility libraries (DateTime on October 6 and StringLib on October 12) represents one of the earliest systematic efforts to build reusable on-chain tooling on Ethereum. The Ethereum community was still developing conventions for code attribution, documentation, and reuse during this period.
Key Facts
Description
The StringLib contract was deployed at block 373552 on October 12, 2015, by Piper Merriam. The source code header explicitly attributes the work: "String Utils v0.1" and "@author Piper Merriam - pipermerriam@gmail.com". The contract contains two libraries: StringLib, which implements the core logic, and StringUtils, which acts as a thin wrapper delegating to StringLib.
The library provides two functions. The uintToBytes function converts an unsigned integer to its decimal string representation, stored as a bytes32 value. It works by repeatedly extracting the least significant digit using modular arithmetic and building the string from right to left using bit shifts. The bytesToUInt function performs the reverse conversion, reading ASCII digit characters from a bytes32 value and accumulating the integer result.
The contract was compiled with Solidity v0.1.5 and was deployed six days after the DateTime library by the same address. Both libraries were part of pipermerriam's active development infrastructure for the Ethereum Alarm Clock, where human-readable string formatting of call identifiers and amounts was a practical requirement.
The explicit author attribution with an email address in the source code was a common convention in early Solidity development, borrowed from documentation practices in other programming languages. Piper Merriam applied this convention consistently across his early contracts.
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 on Etherscan.
Show source code (Solidity)
// String Utils v0.1
/// @title String Utils - String utility functions
/// @author Piper Merriam - <pipermerriam@gmail.com>
library StringLib {
/// @dev Converts an unsigned integert to its string representation.
/// @param v The number to be converted.
function uintToBytes(uint v) constant returns (bytes32 ret) {
if (v == 0) {
ret = '0';
}
else {
while (v > 0) {
ret = bytes32(uint(ret) / (2 ** 8));
ret |= bytes32(((v % 10) + 48) * 2 ** (8 * 31));
v /= 10;
}
}
return ret;
}
/// @dev Converts a numeric string to it's unsigned integer representation.
/// @param v The string to be converted.
function bytesToUInt(bytes32 v) constant returns (uint ret) {
if (v == 0x0) {
throw;
}
uint digit;
for (uint i = 0; i < 32; i++) {
digit = uint((uint(v) / (2 ** (8 * (31 - i)))) & 0xff);
if (digit == 0) {
break;
}
else if (digit < 48 || digit > 57) {
throw;
}
ret *= 10;
ret += (digit - 48);
}
return ret;
}
}
/// @title String Utils - String utility functions
/// @author Piper Merriam - <pipermerriam@gmail.com>
library StringUtils {
/// @dev Converts an unsigned integert to its string representation.
/// @param v The number to be converted.
function uintToBytes(uint v) constant returns (bytes32 ret) {
return StringLib.uintToBytes(v);
}
/// @dev Converts a numeric string to it's unsigned integer representation.
/// @param v The string to be converted.
function bytesToUInt(bytes32 v) constant returns (uint ret) {
return StringLib.bytesToUInt(v);
}
}External Links
Related contracts
MemberRegistry
Same deployerOwner-controlled dynamic-array member registry.
0x1f3b19...7c161aAugust 13, 2015Members
Same deployerOwner-controlled member registry with array + mapping tracking.
0xaeb2ac...a5fd37August 14, 2015MembershipRoster
Same deployerAn Ethereum Public Trust roster contract for adding, removing, and checking members.
0xf1d327...aa0455August 14, 2015KillMul
Same deployerTest/utility contract with `suicide(address)` kill switch and a `multiply2` helper.
0x3e5e1f...7c78cdAugust 14, 2015Members
Same deployerOwner-controlled member registry using sequential id + mapping storage.
0xc6810e...db4e6fAugust 14, 2015EthereumAlarmClock
Same deployerThe first deployment of Piper Merriam's Ethereum Alarm Clock, a smart contract protocol for scheduling transactions at future block numbers, launched on Septemb
0xb0059e...cc0cc1September 22, 2015