AnonCast: Token-Gating in a Weekend

NoirCon 1 at ETHDenver 2025 · February 2025 · 13:25

Noir compiler engineer Michael Klein hosts a workshop at NoirCon 1 during ETHDenver 2025 on AnonCast, a project showing how token-gating can be built in a weekend. It demonstrates a Noir application that uses zero-knowledge proofs to check access without revealing who the user is.

Speakers

Topics

From NoirCon 1 at ETHDenver 2025, hosted by Aztec Network.

Transcript

all right and we will get started hello my name is Michael Klein and this will be a non-cast token gating in a weekend we'll talk about what is a non-cast the original version how it was improved other things we can do with token gating and Noir and then wrap up with a few final thoughts so first of all what is a non-cast uh this is an interview with cartic Patel one of the creators of a non-cast nobody can tell who wrote what poed even us the zero knowledge proofs are constructed on the client so on the web app none of the identifying data is actually sent to any servers just that the proof is sent to the servers and once the proof is validated on the server we send that out to the post there's no identifying information

that's sent we don't even collect any metrics or analytics on the site just because we wanted to say as pure as we can to an nidity why is this interesting well it was built in a weekend so it was a really tiny project and it exploded uh over a 100,000 holders uh close to a million transfers and about 15,000 each warp cast and Twitter followers uh and I there were a couple celebrity Impressions that I'm going to mention uh Jesse poch of Bas was sent in an onc and he responded talking about metamask and uh there's also a report that vitalic pan has uh aped into the Anon token of course it's Anonymous so we don't actually know if he's

posted so so from a user perspective what does this look like well we have this post anonymously modal and if you have a sufficient balance of a non tokens you can alternatively post to a non-cast on warcast promote the post to Twitter as well or delete posts and on uniswap uh and a non- token is about a fifth of a Cent and there's an option to reveal yourself at L date so does this actually cost a n tokens no it's just a balance check once you have the required balance for some feature you can use it as many times as you'd like some uh as long as you know there's a rate limiting uh and then what does this actually cost well about 10 10 usdc to access forecaster posting and about uh

4,500 usdc to access Twitter and xposts I should mention that um the Twitter and X posts do have to go through like the central server and have a bit of a a higher moderation burden and that's why there's a higher gate as far as I understand so what did the MVP look like what did he actually need to to get this out well the a non token an erc20 with with some simple mixins was deployed to ethereum this was pretty much all that they had on chain and the original version was just a quick hackathon project that used a fully trusted setup with a Merkel tree off chain to check all the current an non holders and then on the client side you would just prove

that you have an ethereum signature for an address that's derived that is inside the Merkel tree um so as long as and and in the first version you had to have at least 20,000 a n non which is uh back off top of my head that's about $4,000 uh you would sent your Tweet and the proof to the back end backend checks the proof and sends it out and you can't really read this but you can see that it's about 50 lines of code is the primary circuit to do this token gating which is really cool there is a little bit more in the EC recover to just kind of pin a couple different Library functions together to actually pull out a public address but that's all that's really required for this very straight

forward so how did they improve it it it got popular and they realized that the original levels of security the offchain miracle tree and the 20,000 token balance might need a little bit of tweaking so what did they do what what are like some of the standard improvements that you might do with a token gating project like this while the first version was minimal and only ensured that somebody had a sufficient balance of a nonan through the Merkel tree but they they wanted to actually do more about proving for ethereum specifically so that it could stay up to date more automatically and didn't require up-to-date backend Merkel trees and then the users have to somehow also fetch all the an non users and calculate that Merkel tree as well it's a bit much of a burden for a client side

proof so uh they talked to us and we connected them with some existing work from vayer for client side proofs uh sorry ethereum storage proof proofs and they were able to adopt them uh so with the MVP version they just send their tweet content plus a proof to the back end and um we do need the full tweet content to be visible so that it could be moderated if required and currently you sign with the eth wallet so it's a little bit more streamlined you send uh you you basically check the ethereum contract storage slot and drive the Merkel tree find that route and send that with your with your proof which is much more lightweight um you find the the miracle

path and and you're proving that path in the tree uh this ex this uses as I mentioned the existing V layer stuff so it was very lightweight modification to improve it and yeah effectively this ensures that onchain has the exact same balance as we're proving in the circuit uh completely anonymously and it there there are other improvements that are a little bit less circuit specific so anonymity sets uh are very important I mentioned the 20,000 Anon tokens that 4,000 USD requirement to to be in the anonymity set was too high and so basically it meant that we only had like a handful of bits of entropy for participants so uh Ola who is one of the uh the

contributors to an non-cast uh Point pointed this out and they they basically just Shrunk the requirements of how many an non tokens you needed and that was sufficient to anonymize users I believe the original amount was 20,000 and the current amount is closer to 10,000 um and Ola has also been working on keeping the ethereum storage proofs up to date with the with the latest Noir uh he's there on the right with the beard so then what are this what what are some other things that we can do with token gating and Noir well we can do some things like whale gating apps we can do nft gating and then can do some group intersections for uh composable

group community building with with uh Noir contracts or Noir uh circuits so uh whale gating so the idea of this use case is you know that there are a lot of power users users that have a lot of funds they are extremely active in the community and they have a very uh obvious onchain presence often such users will have large balances of key tokens in your ecosystem they may have individual nft stock tokens that are very expensive but basically if you went on a block Explorer it would be really quite obvious that they were in this category the thing is they don't want to be the first person to have a public transaction with your app because that's

too much attention they don't want to answer questions about it they don't want they just want to try it they want to see if it's any good and you know ideally have that path a little bit greased so what you can do is make a circuit that checks your set of pre precondition it could be things like you must own this token you must have a sufficient balance of a governance token you must XYZ but really this could be just like a bullet point list of the types of power users that you're interested for your app and then you can token gate to guarantee that anybody who meets these conditions can participate completely anonymously without any onchain footprint so for example uh giving gas to let people try out your app or giving

Anonymous access tokens to try out your app so they can do it outside of where they're sending the proof uh similarly we can focus just on nft gating uh so for example if you have an East Denver poop here's another poop just for East Denver participants uh there are a lot of nft gated uh token communities but they tend to be gated from web to which requires you to always say who you were how much you paid for the nft uh that sort of thing uh but a lot of these like telegram group like trading groups type things could use you know lightweight Noir client side proofs for anonymity plus ensuring that somebody is in the membership set um and uh really we can just kind of

combine this and do multi-group so if you have an nft plus governance tokens if you have a poop before some time so you're an OG East Denver participant and you're also a member of Wyoming Dow hey maybe we really want to do more Wyoming Dow type things and we know we want to do a hackathon that's an easy way to get people interested in in your product because they have a free ticket they have you know some gas that they can spend or whatever else it might be uh and then future development so the an non-cast team has has realized that the original project was still fairly hackathon scope and the features would really be a completely separate product if they were to really amp it up so they

have launched a early stage uh development of this thing called a non- do world it's a social media app with privacy features uh for browsing and creating Anonymous posts with verified credentials the idea is that groups will agree on verified credentials and use them to post um all from the group um everything is backed by a token and uses zero knowledge proofs to generate Anonymous uh credentials and proofs of the use of those credentials uh though after that cark one of the founders that I mentioned earlier is joining farcaster so farcaster is a a little bit similar to a nonot world but it's a lot more established as I mentioned before one of

the places that you can post your social media thing through a non-cast is directly to forecaster and it it's meant to permission permissionless build and distribute social apps uh so they haven't publicly announced exactly what they might be doing with CK or they might be doing with something like this but I would just like to point out the the recent Tik Tok announcement that they are using ZK for secure attestation to to ensure that um they know where the content comes from and I imagine that forecaster could use something similar so in conclusion a non-cast is a very simple application of token gating that you can build something like it uh token gating is composable with existing

communities you don't have to start your your community from scratch you already know who's most likely to like your product you can build on top of an existing Community you can uh to client side privately proed membership in any one Key Community and offer access or other benefits though be sure that the number of people that you're offering these benefits to is sufficiently large so that you don't leak who you're offering it to for example if you require somebody to be in the top three owners of how much of a token balance they have for some governance token it's going to be really obvious that it's one of those three people and the likelihood of them revealing the the tiny little bit of data such as time zone that's required to get it down to one person is

very easy um so very important and it's not something that many Engineers are used to thinking about uh and finally Tooling in Noir allows simple token gating with low Dev cost uh 50 lines of code for the initial version and I think about 75 lines of code for the improved version uh of course you got to import some things so that the total size is a bit longer but uh very straightforward and very exciting what we can do with it and that's my talk are there any questions yes uh one thing I've wondered about this with the client side proving what prevents someone from like for the token gating let's say it's like a whale token gating why can't they generate 10 proofs client side as they transfer the

fund to different addresses and then sell the proofs or something yes uh so the question was why can't somebody hold a token generate a proof transfer the tokens and generate an additional proof uh so this is really a per token specific I'm not familiar with the the specific details of the an non token but the the most common solution I've seen is either one you expect that the cost of the transfer wipes out the benefit of having a second copy for free so for example for the $10 version the fees are going to wipe out any benefit uh and then the SEC second thing besides requiring a larger amount is really you just have a delay on transferring the tokens or you require stake tokens okay but if it was like whale or something

like that yeah that they can just recycle it okay so that that actually is something yes that is very important to consider yes uh are there any other questions all right thank you so much for joining and have a great one