Miguel Piedrafita

Miguel Piedrafita

Miguel Piedrafita

Articles & Threads

Articles & Threads

A collection of thoughts, tutorials & threads.

In 2022:

โ—† Moved to Lisbon ๐Ÿ‡ต๐Ÿ‡น โ—† Joined @worldcoin ๐Ÿชฉ โ—† Launched 65 projects ๐Ÿš€ โ—† Spoke at 6 conferences ๐ŸŽค โ—† Traveled to 11 countries โœˆ๏ธ โ—† Taught myself Solidity & Rust ๐Ÿฆ€ โ—† Made frens all around the world ๐ŸŒ

Insane year, next one will be even better. Let's go 2023!

Making Stable Diffusion Safer for Third Parties
Miguel Piedrafita

Miguel Piedrafita

โœจ So you want to add AI image generation to your website?

Rarely, Stable Diffusion will generate NSFW images from regular prompts. The default filter catches it, but your users getting a black image isn't much better. ๐Ÿ˜…

How can we get around this? With a new model ๐Ÿ‘‡


The default filter Stable Diffusion comes with is pretty good, and usually manages to catch these "exceptions".

(it's easy to manually bypass and only filters sexual content, but that's for another thread ๐Ÿ‘€)

When it triggers, SD will replace your image with a black square. โฌ›๏ธ

Continue Reading
Generating Better AI Images By Default
Miguel Piedrafita

Miguel Piedrafita

โœจ Defaults are incredibly important for image models.

Most users won't spent hours tweaking prompts, they'll type the first thing that comes to their minds and run with the result.

Fortunately, it's pretty easy to optimize for that, and generate better images by default. ๐Ÿคฏ


Image models like Stable Diffusion or DALL-E are so amazing because they're general purpose.

They can generate drawings, photographs, icons and logos, 3D environments, and much more! ๐Ÿš€

However, good results require work: paragraphs of prompts and constant iteration.

Continue Reading
Quickly Recreating Magic Login from Scratch
Miguel Piedrafita

Miguel Piedrafita

โœจ I started a new app recently, and while I've used Laravel in the past for "heavy" apps, decided to go 100% with Next.js this time, as a challenge.

As I'm building all the scaffolding from the app, I've borrowed some ideas from Laravel that JS devs might find interesting... ๐Ÿ‘‡


While I mostly use @laravelphp for the Queue these days (no other solution comes close, especially coupled with Vapor), you usually don't think about the work it does for you:

๐Ÿ“จ Crafting & sending mail ๐Ÿ” Authentication & authorization

With @nextjs, you start from scratch. ๐Ÿ˜…

Continue Reading
How I went viral by building an AI Twitter bot
Miguel Piedrafita

Miguel Piedrafita

โœจ Yesterday, I made a tweet that converted all the replies into images, using Stable Diffusion.

It blew up, with +2k people coming together to generate all kinds of art, memes, and play around with ML.

Here's how I built it, how much it cost me, and how you can try it out! ๐Ÿ‘‡


I'm a big fan of @midjourney's (another AI image tool) approach to launching:

They made a Discord, where everyone can generate images in public. If you see someone making something cool, you can see their prompt, tweak it, and put your own spin into it.

It makes AI multiplayer!

Continue Reading
Adding a live map to my website
Miguel Piedrafita

Miguel Piedrafita

โœจ As part of my quest to make my website more personal, I've now added a map showing where I am.

The cool thing? It dynamically updates the location every day when I wake up, generates an Apple Maps screenshot, and a low-res placeholder. ๐Ÿ˜ฎ

Here's how I built it ๐Ÿ‘‡


Firstly, we need a way to get the data.

There's probably a lot of ways to do this, but I went for the dumbest (and simplest) one: an iOS shortcut that runs every day after I wake up.

It reads the phone location, and sends it to an API route which saves it to the db. ๐Ÿ›Œ โžก๏ธ ๐Ÿš€

Continue Reading
How to "Discover" Good Tweets
Miguel Piedrafita

Miguel Piedrafita

quick alpha for good twitter takes:

talk to lots of people

identify the ideas/examples you keep bringing up in every conversation

tweet those ideas to keep track of them

over time, refine and rehash those ideas over more tweets


earliest example of this I can think of is my experience with my school trying to "update" itself.

I realised I was always bringing up the same example when talking about crypto-native apps, so I made it into a thread.

Continue Reading
How to Learn Anything
Miguel Piedrafita

Miguel Piedrafita

๐Ÿ“ How to learn anything

Get started with a project, with a stack you're familiar with (but a new piece you want to master).

Then, debug your way into knowledge.


This is the technique I've been using for 10 years to learn pretty much everything I know.

I wrote an short article on it a year ago, when I had just gotten started with crypto.

Continue Reading

๐ŸŽ™The last episode of @PJVogt's new crypto podcast told the story of @ConstitutionDAO.

As an addendum, I talked about my experience there, and tried to explain why I'm so excited for the web3 space.

also, purple flowers ๐Ÿ’

An open-source transaction intelligence repository
Miguel Piedrafita

Miguel Piedrafita

โœจ Wallet history is notoriously hard to "explain" to users. At best, you get a bunch of swaps, but every other tx is a "contract interaction".

I've spent the past week working on a solution (and recreating the iOS lockscreen on web to showcase it ๐Ÿคช).


๐Ÿ”Ž Today, your wallet's history is a big mess of numbers for anyone non-technical.

Even if websites build UIs for submitting transactions, all context is lost once they leave the page, and they'll have to face Etherscan if they ever want to remember what that was again. ๐Ÿคท

Continue Reading
Optimizing RPC calls
Miguel Piedrafita

Miguel Piedrafita

๐Ÿ›  Had to optimise some RPC calls today, and noticed that ethers.js calls eth_blockNumber every time you call getTransaction().

If you don't care about network confirmations and want to save on your Infura bill, you can use this helper instead ๐Ÿ˜


And while we're at it, if you need to lookup a lot of @ensdomains names, use multicall to do it on O(2) transactions instead of O(n*2).

Here's a little ethers.js implementation I made, which already includes an ENS method, just call resolveNames(addr)!

gas is to today's blockchain what bandwidth was to 1990's interney

We spend too much time explaining the specifics of NFTs to anti-crypto people.

We should be explaining how the current systems work instead, in short & accesible formats.

Otherwise, they're just hating Capitalism through us, without understanding how we make things better.

NFTs enable patronship, not paywalls
Miguel Piedrafita

Miguel Piedrafita

Responding to this tweet

i suppose this is the large gulf yes i think ownership means "i have this" they think ownership means "no one else has this [so i am placed to sell it to them]" twitter.com/Tayruu/status/1484759556068904960

05:30 AM ยท Jan 22, 2022

Something the "right click save" people need to understand, is that NFTs don't represent ownership as in "only I can use/see this content".

We're not building paywalls.

We're building systems where you can click on an image, see its creator, and who financially supported them.


With the new Twitter update, I can now go into someone's profile, click their pfp and instantly know who the artist is.

Sure, "you don't neccesarily need the blockchain to do this", but you'd need all companies to agree on using a global database.

Ethereum is that database.

Continue Reading
Explaining crypto from scratch to a non-technical teenager
Miguel Piedrafita

Miguel Piedrafita

โœจ A few months ago, I made a stream where I got a non-technical friend and explained everything crypto to them, from blockchains and PoS, to smart contracts, ENS & more.

I finally had time to edit the 5h of stream into a consumable video ๐Ÿ˜

Enjoy! ๐Ÿ‘‡๐Ÿ‘‡


Keep in mind this stream happened a few months ago, when I knew much less about the space (especially DeFi), and lots of things have changed since then, but I thought it could be helpful for some people anyway ๐Ÿ˜

Continue Reading

๐Ÿ“ Some notes on how Iโ€™d recreate @viamirrorโ€™s token race mechanism fully on-chain.

๐Ÿ” Uses @nicksdjohnsonโ€™s EIP-3668 (offchain data retrieval) to verify Twitter profiles from Solidity

๐Ÿ—ณ Both voting power and rewards can be tokens or NFTs, and are distributed trustlessly!

Why Gaming NFTs look like scams
Miguel Piedrafita

Miguel Piedrafita

I feel like the reason why gamers are so against NFTs in games (aside from hating lootboxes, which is fair) is that games are inherently centralised.

The only true benefit of gaming NFTs is decentralisation, and games are precisely defined by their limitations, their rules.


But what about "X thing NFTs enable" (interoperability, reselling, etc.)?

As many have pointed out, you can already have all those things without NFTs. You can build marketplaces, APIs, and SDK's to share content between games.

You can do all those things, in a centralised way.

Continue Reading
Short Thoughts on Music NFTs & Manufacturing a Product
Miguel Piedrafita

Miguel Piedrafita

Music NFTs will not happen until all the thought leaders and VCs stop talking about them and trying to make it work

I rlly think someone needs to come in without having heard of the concept before for it to work, and that kind of person is being scared away rn by all the hype


It's the same as @PleasrDAO's $DOG & a bunch of other "VC flagship ideas".

They need to happen organically, and any attempt to "manufacture" them will fail.

And they'll not happen organically if everyone keeps overhyping the idea and raising insane rounds for prototypes

Short Thoughts on DAO Takeovers
Miguel Piedrafita

Miguel Piedrafita

Something I realised while working @ConstitutionDAO & watching other "open DAOs":

The builders will usually be hands down building and with no time to be active in Discord/community.

The most active & visible people in the community can often be the ones adding the least value.


This is really dangerous, especially at the start, since it makes it really easy for "grifters" to take credit over everyone's work, or even hijack the DAOs leadership.

It's the prisoner's dilemma all over again, if everyone collaborates but someone deflects, they can take over.

Continue Reading
We're Buying the US Constitution
Miguel Piedrafita

Miguel Piedrafita

๐Ÿ“œ My friends and I are buying one of the 11 surviving copies of the US Constitution, and you can help!

Introducing @ConstitutionDAO, a project to "rescue" the Constitution from the hands of private collectors, and put it back into the hands of The People.

WTF is going on? ๐Ÿ‘‡


In September, @Sothebys announced they were going to auction the only copy of the Constitution still in the hands of private collectors.

This Reuters article surfaced in our feeds yesterday, and we started joking around with "aping into the constitution"

Continue Reading
A proposal for web2.5
Miguel Piedrafita

Miguel Piedrafita

โœจ The blockchain is one of the biggest innovations of this century.

Like computers or the internet in their early stages, it's currently very limited.

We can't build most kinds of apps on-chain today, but we can future-proof them for when it evolves.

Welcome to web2.5 ๐Ÿš€


Smart contracts on the Ethereum blockchain are insanely powerful ideas but, in practice, they contain some pretty big limitations.

Contract code must >24KB. Each assembly call is priced by a certain amount of gas (storing a word is ~20k), and the maximum gas for any tx is ~30M

Continue Reading
Paradigm Shifts: don't rebuild, reimagine
Miguel Piedrafita

Miguel Piedrafita

โœจ I have a story that always comes to mind when analyzing new paradigm shifts.

It applies as well to web3, as it does to the Internet or any other big shifts in the way we do things.

I've told it to many people in the last few months, so I thought I'd share it with everyone ๐Ÿ‘‡


I lived through the middle of a "paradigm shift" in high school.

We had been using books for years (as everyone does), but suddenly the school decided they wanted to modernize, and issued a Chromebook to every student.

Teachers were given a year to upgrade their teaching plans.

Continue Reading
More thoughts on Worldcoin
Miguel Piedrafita

Miguel Piedrafita

๐ŸŒŽ Some more thoughts on @worldcoin

Here are some things people seem to be confused about it, and some answers to the most common questions I've seen.


First, what is Worldcoin?

If you haven't read it already, I wrote a thread yesterday summarizing what it is and why I'm excited about it.

Make sure to check that out first ๐Ÿ‘‡

Continue Reading
Why I scanned my iris for crypto and you should too
Miguel Piedrafita

Miguel Piedrafita

๐Ÿ”ฅ I scanned my iris to participate in an experiment for global currency, UBI, biometric sybil-resistance and crypto.

Hereโ€™s what @worldcoin is, how it works, how it might not work, and why Iโ€™m very excited about it anyway.


โœจ Worldcoin is an attempt at creating a collectively-owned global currency that gets distributed fairly and anyone has access to.

To get there, they want to allow everyone to claim a free share of it. ๐Ÿ’ธ

Continue Reading
It's Showtime!
Miguel Piedrafita

Miguel Piedrafita

๐Ÿ‘‹ Hey! I couldn't be more excited to announce I'm joining Showtime to help build the best crypto social network.

A short recap of my life until now

Iโ€™ve been coding for a while now, almost 10 years. I started with open-source and slowly shifted gears to become an indie maker. I managed to build an audience around my indie journey and my projects, meet amazing people and have lots of fun.

Continue Reading
Server Authentication for web3
Miguel Piedrafita

Miguel Piedrafita

One of the big appeals of dApps is that the user owns their data. However, for this to be true, we need to authenticate the user with their web3 identity (their wallet). This is easy to do client-side (since they can submit all their tx's themselves using Metamask) but gets harder when we need to verify their identity from a server.

In this article, Iโ€™ll be outlining the technical implementation of a โ€œLogin with walletโ€ button, similar to the ones provided by Showtime or Foundation.

Continue Reading
Building apps with Mirror
Miguel Piedrafita

Miguel Piedrafita

Over the past few weeks, I built a few apps that integrated with Mirror, to try and understand how their protocol worked. I started using their internal APIs and, from there, worked my way to more decentralized sources. Hereโ€™s how I did it (and how you can too).

The Actual Write Race

The idea for The Actual Write Race was to build a list of all existing Mirror publications, and rank them based on the number of articles they had written (simulating Mirrorโ€™s $WRITE race) to add a fun touch.

Continue Reading
Hello, Mirror!
Miguel Piedrafita

Miguel Piedrafita

Hey! Iโ€™m Miguel, and last week I dropped out of university to work on crypto. Iโ€™ll be using Mirror to share my crypto journey and talk about projects I work on and things I learn.

Up next, Iโ€™ll be publishing about how I built a Mirror client with Next.js (and how you can build apps on top of Mirror), some thoughts on the future of web3 apps and why I think Mirror is one of the most exciting projects on the space, and a look at how โ€œLogin with your walletโ€ flows are implemented.

If this sounds exciting, you can follow me on Twitter to keep up with me and get notified when those posts go live.

See you around!

Introducing dm.link
Miguel Piedrafita

Miguel Piedrafita

โœจ I've been working on something new this past few weeks, and I'm super excited to finally share it with everyone

๐Ÿš€ Introducing dm.link, a new way of distributing your Twitter content

Learn more about what it is and why I'm excited about it below ๐Ÿ‘‡


To put it simply, dm.link enables "DM newsletters".

You can create DM lists people can follow, and send tweets to those lists without even leaving the Twitter app.

In fact, the whole subscription process happens without leaving Twitter as well ๐Ÿ˜ฏ

Continue Reading
Twitter's DM Third-Party Client Issues
Miguel Piedrafita

Miguel Piedrafita

Everyone wants a standalone Twitter DM app, so why is nobody building one?

A breakdown of the problem, all possible workarounds, and what I consider to be the optimal solution ๐Ÿ‘‡


Twitter has an API and endpoints for retrieving & sending direct messages.

However, the API only provides access to the last 30 days of DM history.

No app (except Twitter's apps) can access messages (or entire chats) sent more than 30 days ago.

Continue Reading

I also wrote plenty of articles before crypto, on the projects that I was working on, and the things I learned there.

You can find those in the archive โ†’