A 100-Year Contract: Engineering Kim Rose's Blood Series
· solidity, ethereum, on-chain, nft, generative-art
Kim Rose has spent most of her life avoiding blood. For her new show, Born to Live, she made art from it. The Blood Series is her own blood meeting poison in her Los Angeles studio, filmed as it happens. Nothing is digitally manipulated; what you see is the live reaction between the two, cut into continuous loops. There are three pieces, Erlebnisse, Yūgen and Orphic, each a 1-of-1 on Ethereum.
Kim wanted the work to live the way its subject does. Each piece grows slower and dimmer as it ages. After a hundred years it dies and turns black for a day, then glows gold for nine months and is reborn, and the cycle starts again. As the pieces’ own descriptions put it: “We may never see the death and birth of this piece, but our surviving generation will.”
As the engineer and architect, this post will cover how a piece of art keeps time for a century, and why, unlike our Ocean Series, there’s no server anywhere in it.
No server this time
Kim’s Ocean Series follows the weather, so it needs a server that reads a weather API and tells the token what to show. That works for a piece that changes by the hour like the “Ocean Series”, it’s the wrong foundation for a piece meant to outlive its artist, its collector and its developer (nobody can promise a server will still be answering in 2123).
So the Blood Series keeps everything that matters in two places built to last: the logic lives in the contract, and the art lives on IPFS. When anyone asks for the token’s metadata, the contract reads the current time from the chain (block.timestamp), works out where the piece is in its century, and returns the matching file.
There’s no oracle, no keeper bot and no transaction to trigger a change. tokenURI is a view function, so working out the state costs nothing and needs no one. Many dynamic NFTs change when somebody pays gas to update them, or depend on a service staying online. These change once a decade on their own, for as long as Ethereum keeps producing blocks.
Three pieces
Each piece is its own contract with a supply of one, and all three share the same lifecycle code. Each has twelve loops of its own: ten reds, one black and one gold.
A century, in twelve states
- Ten reds, one per decade. Each decade gets its own loop, slower and dimmer than the one before: Pulse, Rhapsody, Bloom, Fever, Communion, Ember, Lull, Dusk, Vigil and finally Last Breath. A century starts on October 25, the day the cycle began, so decades turn on October 25, not January 1.
- Black: Stillness. The end of the century: the final day or two before October 25. The first one is due in October 2123.
- Gold: Renewal. The first 274 days (about nine months) of the next century, from October 25 through late July.
- Back to Pulse. The cycle repeats. The very first century skips gold: the pieces are born in Pulse.
Here’s Erlebnisse at four points in its life:
On-chain, the whole lifecycle is one array of IPFS paths. The base URI is ipfs://, so tokenURI only has to pick an index:
contract Orphic is Satoshigoat {
uint256 public cycleStartTime = 1698192000; // October 25, 2023 (midnight UTC)
// red: [0,9], black: [10], gold: [11]
string[12] private _hashes = [
"QmWQXJ…/red3-1.json",
// … red3-2 through red3-9 …
"QmWQXJ…/red3-10.json",
"QmWQXJ…/black3.json",
"QmWQXJ…/gold3.json"
];
function tokenURI(uint256 tid) public view virtual override returns (string memory) {
if (!_exists(tid)) revert URIQueryForNonexistentToken();
return string(abi.encodePacked(_baseURI(), _getIPFSHash()));
}
}
Working out the state
_getIPFSHash() does on every read.Here’s the core of it, lightly condensed from the deployed contracts (same logic, fewer comments):
function _getIPFSHash() private view returns (string memory) {
uint256 today = block.timestamp;
uint256 trueDeltaYears = DateTime.getYear(today) - DateTime.getYear(cycleStartTime);
// Work in [1, 100] within a century
uint256 modDeltaYears = isHundredMultiple(trueDeltaYears) ? 100 : trueDeltaYears % 100;
// A view function can't move cycleStartTime forward, so simulate it
uint256 newCycleStartTime = cycleStartTime;
if (trueDeltaYears >= 100) {
uint256 numHundreds = trueDeltaYears / 100;
if (isHundredMultiple(trueDeltaYears) && isBeforeCenturyTurn(today))
numHundreds -= 1; // this year's century turn hasn't happened yet
newCycleStartTime = DateTime.addYears(cycleStartTime, numHundreds * 100);
}
// GOLD: the first 274 days of every century after the first
bool pastFirstCentury = trueDeltaYears > 100
|| (isHundredMultiple(trueDeltaYears) && !isBeforeCenturyTurn(today));
if (pastFirstCentury && newCycleStartTime <= today
&& DateTime.diffDays(newCycleStartTime, today) <= 274)
return _hashes[11];
// RED 1–9: one per decade, turning on October 25
for (uint256 i = 1; i <= 9; i++) {
if (modDeltaYears < 10 * i) return _hashes[i - 1];
if (modDeltaYears == 10 * i)
return isBeforeCenturyTurn(today) ? _hashes[i - 1] : _hashes[i];
}
if (modDeltaYears <= 99) return _hashes[9]; // RED 10
// BLACK: the final day(s) before the century turns
uint256 nextCentury = DateTime.addYears(newCycleStartTime, 100);
return DateTime.diffDays(today, nextCentury) <= 1 ? _hashes[10] : _hashes[9];
}
//@dev Is the date between January 1 and October 24?
function isBeforeCenturyTurn(uint256 today) internal pure returns (bool) {
uint256 m = DateTime.getMonth(today);
uint256 d = DateTime.getDay(today);
return m < 10 || (m == 10 && d < 25);
}
Four problems shaped this function:
- A view function can’t write. Ideally the contract would move
cycleStartTimeforward a hundred years each time a century ends. ButtokenURIis read-only, and making it writable would mean someone has to send a transaction every century. Instead, every read recomputes where the current century started (newCycleStartTime). - Solidity has seconds, not dates. There’s no built-in calendar. I used BokkyPooBah’s DateTime library, which converts timestamps to dates with the Julian day formula and handles leap years, so “October 25” means October 25 in every year, not “some multiple of 365 days later.”
- Decades don’t turn on New Year’s. Counting years is easy, but knowing which side of an October 25 boundary you’re on is hairy.
isBeforeCenturyTurnsettles every edge case: in the year a decade ends, the piece stays in the older red until October 25 and moves on after it. - Time comes from validators.
block.timestampcan drift by a few seconds. The smallest unit in this lifecycle is a day, so it doesn’t matter.
Because the state changes only once a decade, marketplace caching isn’t a problem either. A wallet or the collector’s 32-inch display frame can fetch the metadata whenever it likes and get the right answer.
The sale
Each piece sells privately through Kim’s gallery first, with the option to open a public sale later. The shared base contract (Satoshigoat, the same one from the Ocean Series, now with a configurable supply) handles both:
//@dev Gallery sale: admins mint directly to the buyer
function mint(address payable to)
external isSquad nonReentrant enoughSupply(1) notContract(to)
{
_safeMint(to, 1);
}
//@dev Public sale, once it's switched on
function purchase()
external payable isPublic nonReentrant enoughSupply(1) enoughEther(msg.value)
{
_safeMint(_msgSender(), 1);
}
function toggleIsPublicSale() external isSquad { isPublicSale = !isPublicSale; }
Royalties (10%) are declared in each collection’s contract-level metadata on IPFS, and a small group of admin wallets (Kim and me) can run the admin functions, so no single key is a point of failure.
Built to last, with a way to fix it
A contract meant to run for a century (or more) should run transiently, but it shouldn’t be impossible to repair, either. Each piece has a few backup functions that admins can call if something outside the contract goes wrong:
//@dev [BACKUP METHOD] Change one of the ipfs hashes for the project
function setIPFSHash(uint8 idx, string memory newHash) external isSquad { … }
//@dev [BACKUP METHOD] No clue why this would be needed but it's here lol
function setCycleStartTime(uint256 newStartTime) external isSquad { … }
setIPFSHash matters most. If a file ever needs to be re-pinned under a new path, the lifecycle can point at it without redeploying.
Trade-offs
- The art has to stay pinned for a century. Content addressing guarantees nobody can swap the files, but someone still has to keep hosting them.
setIPFSHashis the hedge if a path ever has to change. - The date library is tested through 2345. The cycle logic itself has no end date, but past 2345 it runs on calendar math nobody has tested. That still leaves room for three full lifecycles.
- October 25 is baked in. Decade and century boundaries come from the calendar-year difference plus the October 25 check in
isBeforeCenturyTurn.setCycleStartTimecan move the start, but the turn date itself is part of the code, which is fine for a cycle that was always meant to begin on October 25.
None of these change the experience. Today, all three pieces begin their first decade in Pulse. The first Stillness is a hundred years out.
Contracts
- Erlebnisse:
0x6bEFDEE4c5Dab6731fa506740718FB9553752327 - Yūgen:
0x2CF74ea3353eb8Ba666cF3887def2674b319B9f9 - Orphic:
0xCC18D522121D77C0bd0dC5189E5b4834Da448ef8
Artwork © Kim Rose. See the series at kimroseart.com.