Category Archives: Uncategorized

Andrew Parker’s Sybil-Resistant User-Operated NFT Minting Mechanism

Never mind that NFTs have rolled off the hype cycle’s peak of inflated expectations and now grind through an unknowably-long trough of disillusionment! Let’s revisit Andrew Parker’s mechanism for end-user NFT minting, and make some technical cleanups and tweaks such that NFT contracts extract maximum fees from minters.

NB: there’s no code in here, so if you’re expecting to find something to copy/paste into the contract that some ding dong on Fiverr is paying you to cobble together, you can just scram, kid. As I say at the office from time to time, my job is (tragically) not to write code any longer, but to help you figure out what code to write.

Definitions

  • Minting
    Creating a new token in an NFT contract.
  • Premine
    Old-school scam wherein a select number of individuals operate a blockchain in secret and private before exposing its critical values to the rest of the internet for public mining, thereby safely reserving an unholy pile of the shitcoin for the initial operators themselves without competition against the rest of the universe of hashpower. Satoshi is the original premine case, which is how you know that Bitcoin is a scam.
  • Gas
    The cost of including a transaction in an Ethereum block. Dynamic, like Bitcoin transaction fees, based on current demand for block space.

Current Minting Challenges

NFT drops, premints and user-operated minting and so on generally suffer on a few common axes: mishandled manual allocations, sophisticated contract operators out-performing naive humans, and egregious gas fees.

Manual allocations are when NFT contract authors (or their marketing agencies) sell or give away individual tokens or token-minting rights before the contract hits the blockchain[1]In some cases, the NFT contract can be updated by its authors or maintainers, but I’ll neglect this case for now, excommunicating such misbehavior as cryptographic heresy. Manual allocations are sometimes implemented with some kind of pre-computed list (dumb) embedded in the contract (wasteful) blessing specified addresses with permissions to call various NFT minting methods, or in the dumbest possible cases, the contract authors themselves are the only ones allowed to “mint” NFTs and then variously hand the tokens out or auction them. All of the above implementations are stupid, poorly factored, and generally suck (and moreover point towards the comic ignorance of NFT contract authors of pretty much all prior art in the space), but can be understood in the context of contract authors attempting to milk their mints/drops for as much end-user cash as possible.

A smaller number of Ethereum contracts by JavaScript developers with delusions of grandeur (those who bother to look will find a Lisp in the historical detritus. No points for guessing why that never made it into the DevRel propaganda…) attempt to solve this problem by hardcoding rules like “any given wallet can only mint N tokens per Q blocks” into the contract. I find this even more tragically stupid than the premine strategies (which are at least not stupid and intellectually honest insofar as the implementation is saying: “these are my enn eff tees and you can have them for a price that I set”), because it conflates individuals with addresses, something that Bitcoin lore disposed of purt goddamn near a decade back. The poor schmucks who attempt this strategy are so unfortunate that nobody around them is smart enough to whisper “sybil attack” in their ears, and so they go about blissfully unaware of the entire corpus of literature until they release their contract and it gets pwned on day zero by someone with a college-prep high-schooler’s mathematical savvy. This is like inventing scalable session handling by storing session data in individual web heads, pushing that sticky session notion into your load balancer, and then wondering why new nodes in your autoscaling pool don’t serve as much traffic as old nodes. In 2027.

Egregious gas fees are the final failure mode I find worth talking about, because these are typically also a symptom of unqualified engineers mucking about with mathematical systems they don’t really understand. During exceptionally hype-frothy NFT minting event the sheer number of people attempting to call methods on the popular contracts to mint tokens explodes the demand side for Ethereum block storage space. Naturally, those who bid the highest get their transactions confirmed, and everyone else misses out. Not just everyone else competing for block space to support the particularly popular transaction, but everyone on the entire Ethereum network now competes against folks tryna get their mitts on the latest cryptowhatever, which is not just a spectacular waste of the NFT squad’s money (hey, I love me a deflationary cryptosystem, don’t get me wrong), but of everyone’s money who might be attempting to use Ethereum for…something useful. Assuming such applications exist. But I digress.

Design Goals

  • Low gas fees
  • Arbitrary users can mint NFTs
  • No off-chain trust mechanisms
  • Minting mechanisms can’t be spammed
  • NFT authors capture some fraction of the demand otherwise spent on gas fees
  • Thwart front-running

Design

Proof-of-work.

That’s probably not enough to go on (tee hee hee), so I’ll sketch out the fundamental mechanism for those unfamiliar with how Bitcoin solves this exact same problem.

The minting method must accept payment, and has a signature of:

mint :: str -> ()

Where that str argument is the nonce used to prove that work has been done.

Hashing implementation

  1. Concatenate:
    1. mint function caller’s address
    2. supplied nonce
  2. Hash output of 1.

Difficulty (and the ultimate input)

Bitcoin adjusts difficulty every so often by comparing how quickly blocks were generated with a desired production rate and then ratcheting up or down the required number of leading zeros from the output of hashing some well-known data (neé nonce).

In an NFT implementing this interface, you’ll track difficulty in the exact same way: calculating how many leading zeros your hash function needs to output in order for the contract to consider the nonce valid for NFT minting.

Since mining is a proxy (syntactic sugar) for the minter’s ability to buy the NFTs they want to mint, shouldn’t we just give folks the ability to buy NFTs over the counter, without any of this complicated hashing stuff? If the buy-side is prone to literally throwing money away on gas fees during times of competition for block space, how can we capture that cash that’s otherwise being lit on fire during minting races?

To effectively capture the gas market, simply add the order of magnitude of wei sent along with the minting transaction to the number of leading zeros from the hash output, and if the total number of zeros is greater than the current difficulty number, mint a new NFT.

Departures from Parker

  1. Dynamically calibrate difficulty after every minting event to ensure desired output characteristics
  2. Incorporate payments to augment pure hash difficulty
  3. Don’t require the previous token’s hash in minting
    This is probably the most controversial proposal. I contend that if you check to see if difficulty needs adjustment after every single minting event, you can ensure that even if an infinite number of mintings are submitted in a single block, the adjustment recalculation will ensure that as soon as your difficulty threshold exceeds that which is supplied in the infinite series, all other minting transactions will be tossed. For this we have the serial nature of block construction in Ethereum to thank 🙂

Design Goal Evaluation

  • Low gas fees
    Check, gas auction dynamics are captured by the payable minting function, and concatenating the number of zeros of wei along with the leading zeros of the hash output to get final hash strength.
  • Arbitrary users can mint NFTs
    Check.
  • No off-chain trust mechanisms
    Check.
  • Minting mechanisms can’t be spammed
    Check.
  • NFT authors capture some fraction of the demand otherwise spent on gas fees
    Check.
  • Thwart front-running

References

References
1 In some cases, the NFT contract can be updated by its authors or maintainers, but I’ll neglect this case for now, excommunicating such misbehavior as cryptographic heresy

The hateful jealousy of those who cannot

On the way to dropping the children off at school this morning, we espied a truly noxious plume of smoke right around the corner from Cedar’s school. To satisfy my morbid curiosity, after I shipped Cedar to his first day of first grade (!), Tallulah and I took a slight detour to check out what looked to be a truly magnificent pyre of modern hydrocarbons.

Lo and behold, when we pulled onto the offramp, an entire ad-hoc unhoused enhousement had tragically gone up in flames:

I disembarked, wandered up to get a quick look, and asked how long they expected to hold us up on the offramp, to resounding shrugs from WSDOT and firefighters alike.

Being joyously a new owner of a truck fully equipped for most reasonable offroading situations, and still wanting to get my daughter to school not terrifically late, I effected a two-point turn, and went bumping into the median between the offramp and the highway. Only to be accosted by some standard-size American in a broken down Ford sedan something or other: “YOU STUPID FUCK!”

This is just what you have to expect from the chronically oppressed American. They know they can’t get or do anything, and their response is to get absolutely infuriated when they see other folks they can’t understand aren’t cattle like themselves to raise the spectre of rule-following and fairness.

Following the rules is for schmucks. Those who can, do. Those who cannot, endure. I have a truck capable of getting me out of minor binds like “pulled off on an exit that was immediately closed right in front of me”, and frankly the Ford in question could absolutely have driven up the shoulder back to the highway junction, even if it wasn’t capable of navigating the ditch. But! Its pilot is tragically cursed by the American prole’s mental capture by the local rule system, and can’t comprehend how anyone else would be willing or able to break those rules.

I’m rubber, you’re glue etc.

Fixing pocket doors with captured-nut hangars

The captured-nut pocket door hangers my 2005-vintage pressed-shitboard house came with are the absolute fucking worst.

This bolt (that threads into carriage running on the pocket door rails behind the moulding)…

…will back out of the threads on the carriage over time.

When it does, one side or the other of the pocket door will drop down to the floor, and leave you with the threaded part of the nut poking up out of the door. Good luck getting a wrench up behind the molding to screw it back into the carriage.

Since this has happened to me on 3 separate pocket doors in my house over the last year, I have tried umpteen different approaches to getting these bolts back into their carriages and the doors rolling smoothly, and I have finally developed a formal process that works every time. It’s a giant pain in the ass, but it is at least less obnoxious than staring at a cockeyed door poking out of the wall that you CAN’T EVEN USE TO CLOSE OFF THE SOCIAL PART OF THE HOUSE FROM THE CHILDREN AFTER BEDTIME, or flailing un-directedly at the problem with no plan.

Trust me, I’ve lived both of those stories. This repair method works, and doesn’t require that you take off moulding or make any other destructive repairs to the foamed-wood-product buttbox Americans call houses.

The fix.

  1. Detach the pocket door from the other hangar. In my experience, this is always the “shallow end” of the door, that makes contact with the wall when the pocket door is closed.

    Rotate the retaining clip into its non-retaining position, lift the door up, and push the bolt out of the receiver on the top of the door:
  2. Remove the bolt that has unscrewed itself from the carriage from the other receiver at the other end of the door. In my experience, this is always the “deep end” of the door, that recesses way way way back into the wall.
  3. Thread the bolt from 2 back into its carriage.
  4. Tie a string around the bolt from 2 in such a way that you can yank on it for a bit before it comes untied, but use a knot that will come undone after a reasonable amount of wiggling so that you don’t end up with a string stuffed up in your pocket or heaven forfend, dangling over your door causing a permanent eyesore.
  5. Using a prybar, shim the door so that the bolt-receiver is juuuust below the z-height where the bolt would slide into the receiver:

    Protect your shitty plastic laminates from the metal! The children do enough damage to the house already, you don’t need to compound it while effecting a fix.
  6. Position a chair such that you can gently lean on the prybar with one foot.
  7. Lever the door up just enough for the nut to slide into the receiver, and pull on the string from 4 until you get that satisfying *click* indicating the bolt-head is firmly seated in the receiver. You will have to wiggle the door up and down while pulling on the string in order to get it past a detent.

    If the string comes off the bolt, go back to step 4.
  8. Rotate the clip back into position.

    To hang the door on the second hangar, you can use the exact same technique, or take an easier approach:
  9. Lever the door up until the bolt-receiver is in the appropriate position.
  10. Using a long, thin rod (I recommend small-diameter carbon fiber tubes, an essential tool in my toolbox of weird), push the bolt into the receiver until it clicks

    The reason that you can’t do this for the “deep end” of the pocket door is because you simply cannot get a rod into the gap that the door recesses into in such a way that you can push on the bolt. Instead, you need to pull on it, which has been the source of pretty much all of my howling about how to fix these doors.
  11. Slide the door into the recessed position, and using your long thin rod (or whatever, a knife will work at this point), rotate the retaining clip into position.

Voilá, you have a properly-rehung door again. You also know how to reset it after the children slam it against its stops fifty times and that accursed bolt backs out again.