Staking Without the Stake: Engineering LOGIK's The Plug
· updated · solidity, ethereum, nft, staking, community
Move a Plug to a new wallet on day 556 and it starts over. Move it a day later and the new owner gets an Alchemist at full charge. Everything about that difference comes down to a timestamp.
LOGIK made The Plug as a way to invite collectors into his work, with studio visits, events and art drops. I wrote the contract and built the site. Each of the 888 tokens has a juice meter. You can watch it fill while the token stays in your wallet. The Plug
Reading the meter
The meter starts at 1%. Every 60 days through day 360, it picks up another rank and a new piece of art. The last stretch is longer. Day 557 unlocks The Alchemist.
Each token has a “birthday,” set when it’s minted. On a metadata read the contract subtracts the birthday from the current block timestamp. The number of whole days tells it which artwork to return. Nothing needs to happen on-chain the morning a token reaches a new level.
//@dev How we keep track of how many days a person has held a Plug
mapping(uint256 => uint) internal _birthdays; // tokenId -> timestamp
function countDaysPassed(uint256 tokenId) public view returns (uint256) {
return (block.timestamp - _birthdays[tokenId]) / 1 days;
}
I put the reset in the transfer hook. A sale, a gift and a move to your own hardware wallet all come through there. Once the token has reached 557 days, the hook leaves its birthday alone.
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal virtual override
{
// Alchemists (557+ days) keep their birthday forever
if (_exists(tokenId) && countDaysPassed(tokenId) < 557) {
_setBirthday(tokenId); // back to day 0
}
emit PlugTransferred(from, to);
}
Three sets of art
The token number also determines its edition. There are 176 Chicago Plugs, eight St. Louis Plugs and 704 Nomads. Each edition has its own eight images. Two holders can be at the same level and see different art.
Drawing up a guest list
Having the token in your wallet was enough. There was no separate vault to deposit it in and no transaction to sign each time it earned juice. A marketplace could still show yesterday’s image if it had cached the metadata. The contract could answer with today’s level whenever someone asked.
I added read-only functions to list holders by level or edition. With 888 tokens, we could scan the collection when an artist wanted a guest list. That let us answer a practical question, like who had reached Hustler in time for an invitation.
June 2022, at the door in Brooklyn
All 888 Plugs went in the first two hours of the public mint. Eight months later I wrote a second contract for LOGIK’s Sugoi festival. It asked The Plug about a holder’s artwork and issued a different RSVP key depending on the answer. The most interesting bug turned up when the oldest Plugs reached their next birthday during the claim window. The Sugoi ticket build
Artwork © LOGIK. The Plug collection · Deployed contract