The Black Hole at the center of America

At the center of every galaxy there is a black hole, destroying everything that happens by. For Eddie Glaude, at the center of the mythical America is “the lie” and it taints everyone and everything…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Rescuing an NFT

As some of you know, I do Ethereum development/consulting as a freelancer on my free time. I’ve been around long enough (4 years soon) that I’ve seen lots of weird s*it in the cryptocurrency space. But hey, that’s also one of the reasons I love it!

The user (well, from now on: the client) had received an NFT as payment for some work. Not being very crypto-savvy, this client had accepted the NFT in a form of a wallet’s private key: the NFT was in a wallet, and he was given the private key to the wallet.

Now, this approach has one main issue: whoever gave that private key to the client also knows the private key. Rule number uno in the crypto space: NEVER SHARE YOUR PRIVATE KEY WITH ANYONE. Unfortunately, this approach also had another issue: the private key was known to some pirate bots.

So if the private key was known to bots, why didn’t they simply empty the wallet? That’s a very valid question, and I don’t have the answer to that — my best guess is that the bots simply weren’t smart enough to recognize that the wallet had a valuable NFT in it. Also, I have no idea why or how the bots got the private key.

What the bots were smart enough for was that whenever the wallet received any Ethers, they stole it. Therefore it was impossible to transfer the NFT out by regular means — whenever the client tried to send Eth for the gas fees, the bots stole it.

So if we can’t send in Ethers to rescue the NFT, what can we do? If only we could bundle two transactions together in one atomic bundle: supplying Ethers to the wallet and transferring the NFT out. Unfortunately the basic Ethereum transaction system doesn’t support such functionality.

MEV to the rescue!

MEV allows one to privately bribe the blockchain’s miners to bundle multiple transactions together (among other things), in a single atomic bundle: either all of its transaction succeed, or none. The bundle’s transactions are also promised to be included in a block next to each other, so no bot can steal the Eth between the transactions.

Flashbots are awesome

My first try was to start modifying the website to do what we needed, but it turned out to be a bit bigger project than I initially anticipated. After an hour or two of fast coding, I gave up on that approach.

After some small trial-and-errors, the script worked. Hurray!

Add a comment

Related posts:

Using open source software when starting your business

In this post I aim to outline the merits and pitfalls when using open source software in a commercial setting. Open source in a broad sense means that the source code for a piece of software is…

Five tips on websites usability

Today there are millions of websites accessible with a couple of clicks. However, in this multitude, we have the same idea on how a single website should work. As soon as the homepage is loaded, we…

Top 3 Myths About Remote Web Developers

Top 3 Myths About Remote Web Developers was originally published at Soshace.com. Soshace is a hiring platform for web developers: hire a developer or apply for a remote job.