Jack Allan Kasbeer

← Inventions & Projects

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.

The Plug at full charge: The Alchemist, Chicago edition.

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.

1%Fly on the Wallat mint
17%Dream Chaserday 60
33%Mover & Shakerday 120
50%Hustlerday 180
67%Innovatorday 240
83%The Connectday 300
95%Senseiday 360
100%The Alchemistday 557 · locked
The Plug, 1%, Fly on the Wall
Fly on the Wall
The Plug, 17%, Dream Chaser
Dream Chaser
The Plug, 33%, Mover and Shaker
Mover & Shaker
The Plug, 50%, Hustler
Hustler
The Plug, 67%, Innovator
Innovator
The Plug, 83%, The Connect
The Connect
The Plug, 95%, Sensei
Sensei
The Plug, 100%, The Alchemist
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.

The Alchemist, Chicago edition
Chicago
The Alchemist, St. Louis edition
St. Louis
The Alchemist, Nomad edition
Nomad

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.

Sequence comparison: typical NFT staking requires approving and staking into a vault and later unstaking, each costing gas; with The Plug, the NFT never moves and any wallet or marketplace reading tokenURI sees the level for days held since the last transfer.
Explicit staking vs. what we're calling implicit staking.

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.

Flow: the Plug contract exposes listPlugOwnersForHash and listPlugOwnersForType; free view calls produce an off-chain snapshot used for airdrops from other artists, event invitations and guest lists, and merch, studio and gallery visits.
How a juice level becomes something you can hold, attend or wear.

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