<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>AniLog</title>
	<subtitle>Kumar Anirudha&#39;s personal blog</subtitle>
	
	<link href="https://blog.anirudha.dev/feed/feed.xml" rel="self"/>
	<link href="https://blog.anirudha.dev"/>
	<updated>2026-04-20T00:00:00Z</updated>
	<id>https://blog.anirudha.dev/</id>
	<author> 
		<name>Kumar Anirudha</name>
	</author>
	
	<entry>
		<title>Writing Your Own Claude Plugin and Shipping it to the World</title>
		<link href="https://blog.anirudha.dev/claude-plugin-getting-started/"/>
		<updated>2026-04-20T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/claude-plugin-getting-started/</id>
		<content type="html">&lt;p&gt;Claude Code has a plugin system now. Which means anyone, including you, can bundle up a bit of AI-assisted magic, put a pretty bow on it, and have it installed by strangers on the internet in two commands.&lt;/p&gt;
&lt;p&gt;Writing the plugin is the easy part. Getting people to actually install it is the part nobody tells you about.&lt;/p&gt;
&lt;p&gt;This post walks through the whole round trip: &lt;strong&gt;build a Claude plugin, publish it to GitHub, list it on &lt;a href=&quot;https://agenthub.nullorder.org/&quot;&gt;AgentHub&lt;/a&gt; (a community marketplace I built), and see the install from the user side&lt;/strong&gt;. We’ll do it with a tiny demo plugin so nothing gets in the way of the shape of the thing.&lt;/p&gt;
&lt;p&gt;Once you’ve everything set, you can install your plugin like:&lt;/p&gt;
&lt;terminal-block&gt;/plugin install your-plugin@agenthub&lt;/terminal-block&gt;&lt;h2 id=&quot;what-even-is-a-claude-plugin%3F&quot; tabindex=&quot;-1&quot;&gt;What even is a Claude plugin? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#what-even-is-a-claude-plugin%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A Claude plugin is a directory. That’s it. A directory with a manifest at &lt;code&gt;.claude-plugin/plugin.json&lt;/code&gt; and some combination of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/&quot;&gt;Skills&lt;/a&gt;&lt;/strong&gt; — markdown files Claude invokes when the task fits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Commands&lt;/strong&gt; — skills you call explicitly with &lt;code&gt;/plugin-name:command-name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agents&lt;/strong&gt; — full &lt;a href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/&quot;&gt;subagent definitions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hooks&lt;/strong&gt; — run scripts on events like &lt;code&gt;PostToolUse&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MCP servers&lt;/strong&gt; — wire in external tools&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LSP servers&lt;/strong&gt; — language intelligence for Claude&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can include one of these or all of them. The manifest is the glue.&lt;/p&gt;
&lt;p&gt;The official docs are excellent and you should keep them open in another tab:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://code.claude.com/docs/en/plugins&quot;&gt;Create plugins&lt;/a&gt; → the main guide&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://code.claude.com/docs/en/plugins-reference#plugin-manifest-schema&quot;&gt;Plugin manifest schema&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://code.claude.com/docs/en/plugin-marketplaces&quot;&gt;Plugin marketplaces&lt;/a&gt; — how distribution works&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://code.claude.com/docs/en/skills&quot;&gt;Skills&lt;/a&gt;, &lt;a href=&quot;https://code.claude.com/docs/en/hooks&quot;&gt;Hooks&lt;/a&gt;, &lt;a href=&quot;https://code.claude.com/docs/en/sub-agents&quot;&gt;Subagents&lt;/a&gt;, &lt;a href=&quot;https://code.claude.com/docs/en/mcp&quot;&gt;MCP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that you’ve acquainted with the basics, let’s build…&lt;/p&gt;
&lt;p&gt;Make sure that you got these setup first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Claude Code installed and you’re logged in. If &lt;code&gt;/plugin&lt;/code&gt; doesn’t exist in your session, update or upgrade.&lt;/li&gt;
&lt;li&gt;A GitHub account. Your plugin is going to live in a public repo.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;We’re building &lt;code&gt;claude-plugin-demo&lt;/code&gt;. One skill, called &lt;code&gt;greet&lt;/code&gt;. It takes a name, prints an ASCII-art banner of it via &lt;a href=&quot;http://www.figlet.org/&quot;&gt;figlet&lt;/a&gt; (because the CLI doesn’t need to be boring, right?), and follows up with a warm, slightly over-enthusiastic welcome. Nothing fancy. The point is the pipeline, not the payload. Make sure you have &lt;code&gt;figlet&lt;/code&gt; installed: &lt;code&gt;brew install figlet&lt;/code&gt;, &lt;code&gt;apt install figlet&lt;/code&gt;, or equivalent.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Once you’ve got the full pipeline working with a toy plugin, swapping &lt;code&gt;greet&lt;/code&gt; for something useful (a &lt;a href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/&quot;&gt;PR reviewer&lt;/a&gt;, a commit-message writer, a changelog formatter, whatever) is a mechanical exercise.&lt;/p&gt;
&lt;h2 id=&quot;lets-get-started&quot; tabindex=&quot;-1&quot;&gt;Lets get started &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#lets-get-started&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;terminal-block&gt;mkdir claude-plugin-demo
cd claude-plugin-demo
mkdir -p .claude-plugin skills/greet&lt;/terminal-block&gt;&lt;p&gt;Your tree now looks like this:&lt;/p&gt;
&lt;terminal-block mode=&quot;tree&quot;&gt;claude-plugin-demo/
├── .claude-plugin/
└── skills/
    └── greet/&lt;/terminal-block&gt;&lt;p&gt;One structural thing the docs call out and everyone gets wrong: &lt;strong&gt;only &lt;code&gt;plugin.json&lt;/code&gt; goes inside &lt;code&gt;.claude-plugin/&lt;/code&gt;&lt;/strong&gt;. Skills, agents, commands, and hooks all sit at the plugin root. If you nest them inside &lt;code&gt;.claude-plugin/&lt;/code&gt;, Claude Code silently ignores them and you spend 40 minutes wondering why. This was my first mistake when I was writing my first publishable skill.&lt;/p&gt;
&lt;h2 id=&quot;the-manifest&quot; tabindex=&quot;-1&quot;&gt;The Manifest &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#the-manifest&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’ve shipped anything on a package registry, you already know this shape. A Node package has &lt;code&gt;package.json&lt;/code&gt;. A Rust crate has &lt;code&gt;Cargo.toml&lt;/code&gt;. A Python project has &lt;code&gt;pyproject.toml&lt;/code&gt;. A VS Code extension has &lt;code&gt;package.json&lt;/code&gt; with a &lt;code&gt;contributes&lt;/code&gt; field. A browser extension has &lt;code&gt;manifest.json&lt;/code&gt;. Same idea every time: a small declarative file at a known path that tells the host &lt;em&gt;what this thing is, who made it, what version it’s at, and what surface it exposes&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;A Claude plugin’s manifest plays the same role. It lives at &lt;code&gt;.claude-plugin/plugin.json&lt;/code&gt;, and Claude Code reads it to figure out your plugin’s name (which becomes the skill namespace), its version (how &lt;code&gt;/plugin update&lt;/code&gt; decides there’s something new), its author, and the metadata that marketplaces like AgentHub use to list you. Unlike &lt;code&gt;package.json&lt;/code&gt;, it doesn’t declare dependencies or build scripts — the plugin &lt;em&gt;is&lt;/em&gt; the source; there’s nothing to compile. And unlike a VS Code &lt;code&gt;contributes&lt;/code&gt; block, you don’t enumerate every skill and command here. Claude Code discovers those by walking the directory. The manifest is intentionally thin: identity and metadata, nothing more.&lt;/p&gt;
&lt;p&gt;Create &lt;code&gt;.claude-plugin/plugin.json&lt;/code&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;claude-plugin-demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;A tiny demo plugin with one greeting skill. Use it as a template for your own.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1.0.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Ani&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://blog.anirudha.dev&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;homepage&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://github.com/anistark/claude-plugin-demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;repository&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://github.com/anistark/claude-plugin-demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MIT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;keywords&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;greeting&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tutorial&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Field-by-field, the ones that actually matter:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt; — kebab-case, becomes the skill namespace. Skills get called as &lt;code&gt;/claude-plugin-demo:greet&lt;/code&gt;. Pick something you won’t regret in six months.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;description&lt;/code&gt; — shows up in plugin browsers. Write it like a product tagline, not like an NPM readme.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;version&lt;/code&gt; — Follow &lt;a href=&quot;https://semver.org/&quot;&gt;semver&lt;/a&gt;. Bump it when you ship.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;author.name&lt;/code&gt; — attribution. Optional but put it in.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The full schema has a bunch more fields (&lt;code&gt;homepage&lt;/code&gt;, &lt;code&gt;icon&lt;/code&gt;, &lt;code&gt;settings&lt;/code&gt;, &lt;code&gt;commands&lt;/code&gt;, &lt;code&gt;agents&lt;/code&gt;, &lt;code&gt;skills&lt;/code&gt;, etc.). See the &lt;a href=&quot;https://code.claude.com/docs/en/plugins-reference#plugin-manifest-schema&quot;&gt;reference&lt;/a&gt; when you need them.&lt;/p&gt;
&lt;h2 id=&quot;the-skill&quot; tabindex=&quot;-1&quot;&gt;The Skill &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#the-skill&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Create &lt;code&gt;skills/greet/SKILL.md&lt;/code&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token front-matter-block&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token front-matter yaml language-yaml&quot;&gt;description: Greet a user by name with a figlet ASCII-art banner plus a warm welcome. Use when asked to say hi to someone, onboard a new person, or welcome someone to a project.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;#&lt;/span&gt; Greet&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The user wants you to greet &quot;$ARGUMENTS&quot;.&lt;br /&gt;&lt;br /&gt;Run this command to print an ASCII-art banner of their name:&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token code&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;```&lt;/span&gt;&lt;span class=&quot;token code-language&quot;&gt;sh&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token code-block language-sh&quot;&gt;figlet &quot;$ARGUMENTS&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;```&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`figlet`&lt;/span&gt; is not installed, tell the user to install it (&lt;span class=&quot;token code-snippet code keyword&quot;&gt;`brew install figlet`&lt;/span&gt; on macOS, &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`apt install figlet`&lt;/span&gt; on Debian/Ubuntu, &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`choco install figlet`&lt;/span&gt; on Windows) and stop.&lt;br /&gt;&lt;br /&gt;After the banner prints, write a short (2–3 sentence) welcome message below it. Be warm. Be slightly over the top. Throw in one genuinely useful offer of help — e.g. &quot;want me to set up your project skeleton?&quot; or &quot;shall I explain the codebase layout?&quot;.&lt;br /&gt;&lt;br /&gt;Do not include emoji unless the user&#39;s name already has one.&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;A few things to notice:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The YAML frontmatter’s &lt;code&gt;description&lt;/code&gt; is what Claude reads to decide whether to auto-invoke the skill. &lt;strong&gt;Write it like you’re writing to a very literal coworker.&lt;/strong&gt; Say what it does AND when to use it. Vague descriptions = skill never gets picked.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$ARGUMENTS&lt;/code&gt; captures everything the user types after the skill name. &lt;code&gt;/claude-plugin-demo:greet Priya&lt;/code&gt; → &lt;code&gt;$ARGUMENTS&lt;/code&gt; = &lt;code&gt;&amp;quot;Priya&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The body is the instruction. Claude treats it as a system prompt for that skill. Be specific about output format.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you want the skill to &lt;em&gt;never&lt;/em&gt; auto-invoke and only fire when the user explicitly calls it, add &lt;code&gt;disable-model-invocation: true&lt;/code&gt; to the frontmatter. Worth it for commands where accidental invocation would be annoying.&lt;/p&gt;
&lt;terminal-block mode=&quot;tree&quot;&gt;.
├── .claude-plugin
│   └── plugin.json
├── .gitignore
├── LICENSE
├── README.md
└── skills
    └── greet
        └── SKILL.md&lt;/terminal-block&gt;&lt;h2 id=&quot;testing&quot; tabindex=&quot;-1&quot;&gt;Testing &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#testing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Don’t publish yet. Run it against Claude Code on your machine first:&lt;/p&gt;
&lt;terminal-block&gt;claude --plugin-dir ./claude-plugin-demo&lt;/terminal-block&gt;&lt;p&gt;Then in the session:&lt;/p&gt;
&lt;terminal-block&gt;/claude-plugin-demo:greet Priya&lt;/terminal-block&gt;&lt;p&gt;Claude should shell out to &lt;code&gt;figlet&lt;/code&gt;, print an ASCII-art banner of &lt;code&gt;Priya&lt;/code&gt;, then write a warm welcome underneath. Tweak the &lt;code&gt;SKILL.md&lt;/code&gt;, run &lt;code&gt;/reload-plugins&lt;/code&gt; inside the same session, try again. No restart needed.&lt;/p&gt;
&lt;p&gt;If the skill doesn’t show up at all, check:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Your directories live at the plugin root, not inside &lt;code&gt;.claude-plugin/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The manifest parses (paste it into a JSON linter; trailing commas have ended careers)&lt;/li&gt;
&lt;li&gt;The skill folder name matches what you’re typing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/greet-ss.png&quot; alt=&quot;Claude Code terminal showing /claude-plugin-demo:greet Ani with the response&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;validating-skills&quot; tabindex=&quot;-1&quot;&gt;Validating Skills &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#validating-skills&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;“It works on my machine” is not a shipping criterion. Before you push, run your skill through a validator so the frontmatter, metadata, and structure are all sane. I use &lt;a href=&quot;https://github.com/anistark/sutras&quot;&gt;&lt;strong&gt;sutras&lt;/strong&gt;&lt;/a&gt; for this. A small devtool I built for the &lt;a href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/&quot;&gt;skill lifecycle&lt;/a&gt;: scaffolding, validation, evaluation, and packaging.&lt;/p&gt;
&lt;p&gt;Install it:&lt;/p&gt;
&lt;terminal-block&gt;pip install sutras&lt;/terminal-block&gt;&lt;p&gt;Then validate the skill you just wrote:&lt;/p&gt;
&lt;terminal-block&gt;sutras validate skills/greet&lt;/terminal-block&gt;&lt;p&gt;You’ll get back a report on the YAML frontmatter, required fields, description length, naming, and a bunch of quality checks you’d otherwise discover the hard way in someone else’s CI. Add &lt;code&gt;--strict&lt;/code&gt; to turn warnings into errors, or &lt;code&gt;--all&lt;/code&gt; to sweep every skill in the repo at once. Super useful once a plugin grows beyond one skill:&lt;/p&gt;
&lt;terminal-block&gt;sutras validate --all --path skills/ --strict&lt;/terminal-block&gt;&lt;h3 id=&quot;from-inside-claude-code-(via-pi)&quot; tabindex=&quot;-1&quot;&gt;From inside Claude Code (via pi) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#from-inside-claude-code-(via-pi)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you use &lt;a href=&quot;https://github.com/badlogic/pi&quot;&gt;pi&lt;/a&gt;, sutras ships an extension that exposes &lt;code&gt;/sutras&lt;/code&gt; commands directly in-session — validate, list, and inspect without leaving the editor:&lt;/p&gt;
&lt;terminal-block&gt;pi install npm:sutras&lt;/terminal-block&gt;&lt;h3 id=&quot;in-ci&quot; tabindex=&quot;-1&quot;&gt;In CI &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#in-ci&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The same check belongs on every push so a bad merge can’t sneak past. Sutras publishes a reusable GitHub Action:&lt;/p&gt;
&lt;code-block lang=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# .github/workflows/validate-skills.yml&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Validate Skills&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;push&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; pull_request&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token key atrule&quot;&gt;validate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ubuntu&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;latest&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; actions/checkout@v4&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/sutras@v0&lt;br /&gt;        &lt;span class=&quot;token key atrule&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token key atrule&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; skills/&lt;br /&gt;          &lt;span class=&quot;token key atrule&quot;&gt;strict&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Pin to a major tag (&lt;code&gt;@v0&lt;/code&gt;) for automatic patch updates, or to an exact release (&lt;code&gt;@v0.4.5&lt;/code&gt;) if you want full reproducibility. Either way, the validator runs on every PR and fails the build before AgentHub’s own checks ever see it.&lt;/p&gt;
&lt;p&gt;Treat validation the same way you treat linting or typechecking: cheap, local, automated, non-negotiable. If you want the longer argument for why skills deserve a proper lifecycle in the first place, I wrote about it here: &lt;a href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/&quot;&gt;&lt;strong&gt;Skills, Agents, and the Missing Middle&lt;/strong&gt;&lt;/a&gt;. That post is the “why.” This step is the “how.”&lt;/p&gt;
&lt;h2 id=&quot;ready-to-publish&quot; tabindex=&quot;-1&quot;&gt;Ready to publish &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#ready-to-publish&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Time to make this plugin real.&lt;/p&gt;
&lt;terminal-block&gt;git init
git add .
git commit -m &amp;quot;chore: init claude-plugin-demo v1.0.0&amp;quot;
gh repo create anistark/claude-plugin-demo --public --source=. --push&lt;/terminal-block&gt;&lt;p&gt;Add two more files before you call it done:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;README.md&lt;/code&gt; — what it does, install commands, a usage example. Don’t overthink it.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LICENSE&lt;/code&gt; — MIT is the default Sunday vibe. Pick whichever works for you, but pick &lt;em&gt;something&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tag the release if you want clean semver history:&lt;/p&gt;
&lt;terminal-block&gt;git tag v1.0.0
git push --tags&lt;/terminal-block&gt;&lt;p&gt;At this point your plugin already works. Anyone can install it directly from your repo:&lt;/p&gt;
&lt;terminal-block&gt;/plugin marketplace add anistark/claude-plugin-demo
/plugin install claude-plugin-demo&lt;/terminal-block&gt;&lt;p&gt;But asking every user to remember your GitHub handle and add your repo as a one-off marketplace is friction. We can do better.&lt;/p&gt;
&lt;p&gt;&lt;github-card repo=&quot;anistark/claude-plugin-demo&quot;&gt;&lt;/github-card&gt;&lt;/p&gt;
&lt;h2 id=&quot;meet-agenthub&quot; tabindex=&quot;-1&quot;&gt;Meet AgentHub &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#meet-agenthub&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://agenthub.nullorder.org/&quot;&gt;AgentHub&lt;/a&gt; is a community-driven marketplace for Claude Code plugins. I built it because the plugin ecosystem was coming in hot and there was no central place to discover what’s out there.&lt;/p&gt;
&lt;p&gt;The design is deliberately boring: &lt;strong&gt;your plugin code stays in your own repo&lt;/strong&gt;. AgentHub holds a catalog of references. You open a PR, we merge it, your plugin shows up when users run &lt;code&gt;/plugin&lt;/code&gt; and hit the Discover tab. You keep ownership, you keep your CI, you keep your license. We just do matchmaking.&lt;/p&gt;
&lt;p&gt;Users install AgentHub once:&lt;/p&gt;
&lt;terminal-block&gt;/plugin marketplace add nullorder/agenthub&lt;/terminal-block&gt;&lt;p&gt;After that, any plugin in the catalog is one command away:&lt;/p&gt;
&lt;terminal-block&gt;/plugin install &amp;lt;plugin-name&amp;gt;@agenthub&lt;/terminal-block&gt;&lt;p&gt;Right now there are &lt;strong&gt;300 plugins from 73 authors&lt;/strong&gt; and the catalog is growing fast. Your demo plugin can join that list in the next ten minutes.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://agenthub.nullorder.org/&quot;&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/agenthub-homepage.png&quot; alt=&quot;AgentHub homepage showing the plugin grid&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;distribute-your-plugin&quot; tabindex=&quot;-1&quot;&gt;Distribute your plugin &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#distribute-your-plugin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Fork &lt;a href=&quot;https://github.com/nullorder/agenthub&quot;&gt;&lt;code&gt;nullorder/agenthub&lt;/code&gt;&lt;/a&gt; on GitHub and clone your fork.&lt;/p&gt;
&lt;p&gt;Inside the repo, every plugin is a single JSON file under &lt;code&gt;plugins/&lt;/code&gt;. &lt;strong&gt;The filename must match the plugin name.&lt;/strong&gt; So for our demo:&lt;/p&gt;
&lt;terminal-block&gt;touch plugins/claude-plugin-demo.json&lt;/terminal-block&gt;&lt;p&gt;Fill it in:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;claude-plugin-demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;github&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;repo&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;anistark/claude-plugin-demo&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;A tiny demo plugin with one greeting skill. Great template for your own first plugin.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1.0.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;anistark&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;category&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;other&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MIT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tutorial&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;demo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;The rules, because rules have consequences:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; — kebab-case, no “claude” / “anthropic” / “official” in the name, must match the filename.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;source&lt;/code&gt;&lt;/strong&gt; — usually &lt;code&gt;github&lt;/code&gt; with &lt;code&gt;repo: &amp;quot;&amp;lt;user&amp;gt;/&amp;lt;repo&amp;gt;&amp;quot;&lt;/code&gt;. If your plugin lives on GitLab, is in a monorepo subdir, or ships via npm, there are three other source types. See &lt;a href=&quot;https://github.com/nullorder/agenthub/blob/main/CONTRIBUTING.md&quot;&gt;CONTRIBUTING.md&lt;/a&gt; for those.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;version&lt;/code&gt;&lt;/strong&gt; — must match the version in your plugin’s own &lt;code&gt;plugin.json&lt;/code&gt;. If the two drift, &lt;code&gt;/plugin update&lt;/code&gt; lies to users and tells them they’re up to date when they aren’t. Keep them in lockstep.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;category&lt;/code&gt;&lt;/strong&gt; — one of: &lt;code&gt;development&lt;/code&gt;, &lt;code&gt;testing&lt;/code&gt;, &lt;code&gt;devops&lt;/code&gt;, &lt;code&gt;security&lt;/code&gt;, &lt;code&gt;documentation&lt;/code&gt;, &lt;code&gt;productivity&lt;/code&gt;, &lt;code&gt;data&lt;/code&gt;, &lt;code&gt;design&lt;/code&gt;, &lt;code&gt;other&lt;/code&gt;. Pick honestly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;tags&lt;/code&gt;&lt;/strong&gt; — &lt;strong&gt;required&lt;/strong&gt;, and must include at least one &lt;em&gt;component type&lt;/em&gt; tag so users know what they’re getting: &lt;code&gt;skills&lt;/code&gt;, &lt;code&gt;agents&lt;/code&gt;, &lt;code&gt;commands&lt;/code&gt;, &lt;code&gt;hooks&lt;/code&gt;, &lt;code&gt;mcp-servers&lt;/code&gt;, &lt;code&gt;lsp-servers&lt;/code&gt;, &lt;code&gt;integration&lt;/code&gt;, or &lt;code&gt;other&lt;/code&gt;. You can add free-form tags after that (languages, frameworks, moods).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One thing worth underlining: &lt;strong&gt;don’t edit &lt;code&gt;.claude-plugin/marketplace.json&lt;/code&gt; directly.&lt;/strong&gt; That file is auto-generated from everything in &lt;code&gt;plugins/&lt;/code&gt; after your PR merges. If you touch it, the next build overwrites you and everyone’s annoyed.&lt;/p&gt;
&lt;h2 id=&quot;listing-on-agenthub&quot; tabindex=&quot;-1&quot;&gt;Listing on AgentHub &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#listing-on-agenthub&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;AgentHub is a public repo, so contributions go through the standard GitHub fork-and-PR flow. You don’t have write access to &lt;code&gt;nullorder/agenthub&lt;/code&gt; (and neither does anyone outside the maintainers). You open a PR from your own fork.&lt;/p&gt;
&lt;p&gt;If you haven’t already, fork &lt;a href=&quot;https://github.com/nullorder/agenthub&quot;&gt;&lt;code&gt;nullorder/agenthub&lt;/code&gt;&lt;/a&gt; from the GitHub UI, then clone your fork locally:&lt;/p&gt;
&lt;terminal-block&gt;gh repo fork nullorder/agenthub --clone
cd agenthub&lt;/terminal-block&gt;&lt;p&gt;Or, if you prefer the manual route: click &lt;strong&gt;Fork&lt;/strong&gt; on the GitHub page, then &lt;code&gt;git clone git@github.com:&amp;lt;your-username&amp;gt;/agenthub.git&lt;/code&gt;. Either way, add the upstream so you can pull new changes later:&lt;/p&gt;
&lt;terminal-block&gt;git remote add upstream https://github.com/nullorder/agenthub.git&lt;/terminal-block&gt;&lt;p&gt;Now create your manifest file (as in the previous section), then branch, commit, and push to your fork:&lt;/p&gt;
&lt;terminal-block&gt;git checkout -b add-claude-plugin-demo
git add plugins/claude-plugin-demo.json
git commit -m &amp;quot;Add claude-plugin-demo&amp;quot;
git push origin add-claude-plugin-demo&lt;/terminal-block&gt;&lt;p&gt;Then open a PR against &lt;code&gt;nullorder/agenthub:main&lt;/code&gt;. A good PR body looks like this:&lt;/p&gt;
&lt;code-block lang=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;###&lt;/span&gt; Plugin: claude-plugin-demo&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A tiny demo plugin with one greeting skill. Meant as a reference template&lt;br /&gt;for people writing their first Claude Code plugin.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Repo: https://github.com/anistark/claude-plugin-demo&lt;br /&gt;&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Version: 1.0.0&lt;br /&gt;&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Category: other&lt;br /&gt;&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Tags: skills, tutorial, demo&lt;br /&gt;&lt;br /&gt;Tested locally with &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`claude --plugin-dir ./claude-plugin-demo`&lt;/span&gt;.&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Keep it short. CI will run some validation (JSON schema, naming, required fields). If something’s off, the checks will tell you what. Fix, push, done.&lt;/p&gt;
&lt;p&gt;After a merge, the catalog regenerates and the site updates. Your plugin is now browsable by everyone using AgentHub.&lt;/p&gt;
&lt;h2 id=&quot;into-the-wild&quot; tabindex=&quot;-1&quot;&gt;Into the wild &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#into-the-wild&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Like the beautiful movie goes… with a little Eddie Vedder in background strumming along…Now, it’s time for a real plugin example…
I wrote &lt;a href=&quot;https://github.com/anistark/ani-skills&quot;&gt;&lt;strong&gt;ani-skills&lt;/strong&gt;&lt;/a&gt;, a small collection of agent skills I use every day: a commit message writer, a PR description writer, and an upstream-sync helper. Of course planning on adding more such skills to it. Listed on AgentHub as: &lt;code&gt;ani-skills@agenthub&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;github-card repo=&quot;anistark/ani-skills&quot;&gt;&lt;/github-card&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Inside the plugin’s own repo&lt;/strong&gt;, &lt;code&gt;.claude-plugin/plugin.json&lt;/code&gt; looks roughly like this:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ani-skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Reusable AI agent skills for Claude Code — commit messages, PR descriptions, upstream sync.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.3.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Ani&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://blog.anirudha.dev&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;homepage&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://github.com/anistark/ani-skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;repository&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://github.com/anistark/ani-skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MIT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;keywords&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;git&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;commit&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pr&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;development&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Inside the AgentHub marketplace&lt;/strong&gt;, &lt;code&gt;plugins/ani-skills.json&lt;/code&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ani-skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;github&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;repo&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;anistark/ani-skills&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Reusable AI agent skills for Claude Code — commit messages, PR descriptions, upstream sync.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.3.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;anistark&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;category&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;development&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;license&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MIT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;tags&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;skills&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;git&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;development&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Same &lt;code&gt;name&lt;/code&gt;, same &lt;code&gt;version&lt;/code&gt;, same &lt;code&gt;description&lt;/code&gt;. Two files, one source of truth. This is the version-pairing discipline I was yelling about earlier. Here it is in practice.&lt;/p&gt;
&lt;p&gt;The repo layout is the same pattern we’ve been building, just with three skills instead of one:&lt;/p&gt;
&lt;terminal-block mode=&quot;tree&quot;&gt;ani-skills/
├── .claude-plugin/
│   └── plugin.json
├── skills/
│   ├── commit-msg/
│   │   └── SKILL.md
│   ├── pr-msg/
│   │   └── SKILL.md
│   └── sync-upstream/
│       └── SKILL.md
├── README.md
└── LICENSE&lt;/terminal-block&gt;&lt;p&gt;Because it’s installed via the plugin system, each skill is namespaced under &lt;code&gt;ani-skills:&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/ani-skills:commit-msg&lt;/code&gt; — write a well-structured git commit message from staged changes&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/ani-skills:pr-msg&lt;/code&gt; — draft a PR title and description from the current branch’s commits and diff&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/ani-skills:sync-upstream&lt;/code&gt; — sync the current branch with upstream, resolving conflicts interactively&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/agenthub-ani-skills.png&quot; alt=&quot;ani-skills listed on AgentHub&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/ani-skills-plugin.png&quot; alt=&quot;ani-skills namespaced skills in Claude Code&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Want to try it right now instead of reading about it? Three commands, live:&lt;/p&gt;
&lt;terminal-block&gt;/plugin marketplace add nullorder/agenthub
/plugin install ani-skills@agenthub
/ani-skills:commit-msg&lt;/terminal-block&gt;&lt;p&gt;That’s the full round trip on a plugin that’s actually in production. Everything we’ve walked through so far (the manifest, the skill folders, the AgentHub entry, the PR) is what got that plugin on the shelf.&lt;/p&gt;
&lt;h2 id=&quot;using-plugin&quot; tabindex=&quot;-1&quot;&gt;Using Plugin &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#using-plugin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is the payoff. Imagine someone (a friend, a stranger, your future self) wants to use your plugin.&lt;/p&gt;
&lt;p&gt;They open Claude Code. They do this once, forever:&lt;/p&gt;
&lt;terminal-block&gt;/plugin marketplace add nullorder/agenthub&lt;/terminal-block&gt;&lt;p&gt;Then any time they want to install something:&lt;/p&gt;
&lt;terminal-block&gt;/plugin&lt;/terminal-block&gt;&lt;p&gt;That opens the plugin browser. They tap Discover, find &lt;code&gt;claude-plugin-demo&lt;/code&gt;, tap install. Or, if they’re terminal-pilled and know the name:&lt;/p&gt;
&lt;terminal-block&gt;/plugin install claude-plugin-demo@agenthub&lt;/terminal-block&gt;&lt;p&gt;Three seconds later:&lt;/p&gt;
&lt;terminal-block&gt;/claude-plugin-demo:greet Ani&lt;/terminal-block&gt;&lt;p&gt;Claude runs &lt;code&gt;figlet&lt;/code&gt; on their box, prints a chunky ASCII banner of the name, and writes a warm welcome underneath. Your plugin, running on someone else’s machine, doing the thing you wrote. Satisfying.&lt;/p&gt;
&lt;h2 id=&quot;shipping-updates&quot; tabindex=&quot;-1&quot;&gt;Shipping Updates &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#shipping-updates&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Your plugin is not a fossil. You’ll want to ship &lt;strong&gt;v1.1.0&lt;/strong&gt;, &lt;strong&gt;v1.2.0&lt;/strong&gt;, &lt;strong&gt;v2.0.0&lt;/strong&gt;, and so on…&lt;/p&gt;
&lt;p&gt;The update flow is a two-step because AgentHub pins to versions explicitly:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Ship in your own repo.&lt;/strong&gt; Make your changes, bump &lt;code&gt;version&lt;/code&gt; in &lt;code&gt;.claude-plugin/plugin.json&lt;/code&gt; (say, to &lt;code&gt;1.1.0&lt;/code&gt;), commit, push, tag.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open a PR to AgentHub&lt;/strong&gt; updating the &lt;code&gt;version&lt;/code&gt; field in &lt;code&gt;plugins/claude-plugin-demo.json&lt;/code&gt; to match.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Both versions must match. If your source repo says &lt;code&gt;1.1.0&lt;/code&gt; but the AgentHub entry still says &lt;code&gt;1.0.0&lt;/code&gt;, then &lt;code&gt;/plugin update claude-plugin-demo@agenthub&lt;/code&gt; will tell users they’re on the latest version. They won’t be. They’ll be annoyed. Don’t do that.&lt;/p&gt;
&lt;p&gt;If you’re only changing metadata (description, tags, category) and not shipping new plugin behavior, no version bump needed. Just edit the file in &lt;code&gt;plugins/&lt;/code&gt; and open a PR.&lt;/p&gt;
&lt;p&gt;On the user end, pulling the latest:&lt;/p&gt;
&lt;terminal-block&gt;/plugin marketplace update agenthub
/plugin update claude-plugin-demo@agenthub
/reload-plugins&lt;/terminal-block&gt;&lt;p&gt;Users can also update using by simple going in &lt;code&gt;/plugin&lt;/code&gt; and browsing through installed plugins and clicking on Update like:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/claude-plugin-update.png&quot; alt=&quot;Updating a plugin from the /plugin UI in Claude Code&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Do not forget to run &lt;code&gt;/reload-plugins&lt;/code&gt; or reload your claude code session for the effect to take.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;a-few-things-i-learned-the-hard-way&quot; tabindex=&quot;-1&quot;&gt;A few things I learned the hard way &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#a-few-things-i-learned-the-hard-way&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Skill descriptions are a product spec.&lt;/strong&gt; If Claude doesn’t reliably invoke your skill at the right moment, the description is almost always the culprit. Be concrete about trigger conditions. “Use when the user asks to review a PR, check code quality, or audit a diff” beats “code review skill”. The description is what Claude reads to decide whether to reach for your skill. Treat every word like it’s going on the back of a box.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do not nest anything inside &lt;code&gt;.claude-plugin/&lt;/code&gt;.&lt;/strong&gt; This is the #1 bug report. Only &lt;code&gt;plugin.json&lt;/code&gt; lives in &lt;code&gt;.claude-plugin/&lt;/code&gt;. Everything else (&lt;code&gt;skills/&lt;/code&gt;, &lt;code&gt;agents/&lt;/code&gt;, &lt;code&gt;hooks/&lt;/code&gt;, &lt;code&gt;commands/&lt;/code&gt;, &lt;code&gt;.mcp.json&lt;/code&gt;, &lt;code&gt;settings.json&lt;/code&gt;) sits at the plugin root. If you put &lt;code&gt;skills/&lt;/code&gt; inside &lt;code&gt;.claude-plugin/skills/&lt;/code&gt;, Claude Code silently ignores it, your skill never loads, and you burn an afternoon wondering why &lt;code&gt;/reload-plugins&lt;/code&gt; does nothing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Version drift is the silent killer.&lt;/strong&gt; The version in your plugin’s own &lt;code&gt;plugin.json&lt;/code&gt; and the version in &lt;code&gt;plugins/&amp;lt;your-plugin&amp;gt;.json&lt;/code&gt; on AgentHub must match. If they drift, &lt;code&gt;/plugin update&lt;/code&gt; tells users they’re on the latest version when they are emphatically not. You pushed v1.2.0 to your repo, bumped your manifest, tagged it, blogged about it, but forgot to open the AgentHub PR. Nobody gets the update. Nobody tells you. You just slowly gather confused issues.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;YAML frontmatter will humble you.&lt;/strong&gt; The YAML block at the top of &lt;code&gt;SKILL.md&lt;/code&gt; is strict. Trailing whitespace, tabs instead of spaces, unquoted colons in descriptions: any of these can make the whole skill invisible. When a skill isn’t loading, check the frontmatter parses as YAML before you suspect anything else.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The skill character budget is a real constraint.&lt;/strong&gt; Claude Code injects plugin skills into the system prompt with a default cap of about 15,000 characters. On a marketplace like AgentHub with 300+ plugins, if users install aggressively, some skills get silently truncated. Users can fix it by setting &lt;code&gt;SLASH_COMMAND_TOOL_CHAR_BUDGET=30000&lt;/code&gt; in their shell profile. Worth mentioning in your README if your plugin depends on long skill descriptions. Also a good argument for keeping your own skill descriptions tight.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;/reload-plugins&lt;/code&gt; is not a magic wand.&lt;/strong&gt; It reloads skills, agents, hooks, MCP servers, and LSP servers within a session. It does not always pick up changes to &lt;code&gt;plugin.json&lt;/code&gt; itself or to &lt;code&gt;settings.json&lt;/code&gt;. When you’re editing the manifest, restart the session. When you’re editing skill bodies, &lt;code&gt;/reload-plugins&lt;/code&gt; is fine.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;$ARGUMENTS&lt;/code&gt; is literal string substitution.&lt;/strong&gt; It’s not parsed, not validated, not escaped. If a user passes &lt;code&gt;&amp;quot;hi; rm -rf /&amp;quot;&lt;/code&gt;, your skill just sees that text. Which is fine for skills that only send it to Claude as context, but if your skill runs bash (via hooks or scripts) and interpolates &lt;code&gt;$ARGUMENTS&lt;/code&gt; directly, that’s a shell injection waiting for a bad day. Quote aggressively. Or better, use &lt;code&gt;jq&lt;/code&gt; to parse hook input on stdin rather than threading args through the shell.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Namespacing is your friend.&lt;/strong&gt; &lt;code&gt;/claude-plugin-demo:greet&lt;/code&gt; looks verbose the first time you see it. After your fourth plugin, when you realize three of them shipped with a &lt;code&gt;/hello&lt;/code&gt;, you’ll thank the designers. Do not try to fight the namespace by naming your plugin &lt;code&gt;h&lt;/code&gt; to keep invocations short. Your future self will hate you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Name your plugin like you’re stuck with it.&lt;/strong&gt; Renaming after launch is painful. Users have it installed under the old name, AgentHub’s entry is keyed to the name, your docs reference the name. And on AgentHub, the name must be unique across the whole catalog. Check &lt;a href=&quot;https://github.com/nullorder/agenthub/tree/main/plugins&quot;&gt;the plugins directory&lt;/a&gt; before you commit to one. If you pick something already taken, the PR gets rejected and you start over.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;License and README are not optional.&lt;/strong&gt; AgentHub’s &lt;a href=&quot;https://github.com/nullorder/agenthub/blob/main/CONTRIBUTING.md&quot;&gt;contributing guide&lt;/a&gt; requires both in your plugin repo. This catches people out constantly. A five-line MIT license and a README with install commands plus one usage example is the minimum. Do it before the PR, not after.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Don’t ship secrets.&lt;/strong&gt; If your plugin includes MCP server configs or hooks that call external APIs, resist the urge to hardcode tokens into &lt;code&gt;.mcp.json&lt;/code&gt; or hook scripts. Use environment variables and document what the user needs to set. The moment your plugin is popular, your hardcoded key is being lifted into a hundred other users’ setups.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Platform compatibility bites hook authors.&lt;/strong&gt; Bash one-liners in &lt;code&gt;hooks.json&lt;/code&gt; work great on your Mac. They die silently on a user’s Windows machine, or on a minimal Linux container without &lt;code&gt;jq&lt;/code&gt; installed. If your plugin is going to a general audience, either write hooks in something portable (Node, Python with a shebang) or list the required binaries in your README.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Read one real plugin before writing yours.&lt;/strong&gt; The &lt;a href=&quot;https://github.com/nullorder/agenthub/tree/main/plugins&quot;&gt;AgentHub &lt;code&gt;plugins/&lt;/code&gt; directory&lt;/a&gt; has 300 live examples. Clone a few source repos that do what you’re aiming for. Steal structure. A good reference saves more time than any doc page.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Add the badge.&lt;/strong&gt; If your plugin ships on AgentHub, drop this in your README:&lt;/p&gt;
&lt;code-block lang=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token url&quot;&gt;[&lt;span class=&quot;token content&quot;&gt;![AgentHub&lt;/span&gt;](&lt;span class=&quot;token url&quot;&gt;https://agenthub.nullorder.org/badge.svg&lt;/span&gt;)&lt;/span&gt;](https://agenthub.nullorder.org)&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Helps discoverability, helps the marketplace, helps other builders find it.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;That’s it!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Claude plugins are genuinely one of the more pleasant extension points I’ve built against in a while. The manifest is small, the local dev loop with &lt;code&gt;--plugin-dir&lt;/code&gt; is fast, and the distribution story through a marketplace like AgentHub is two JSON files and a PR.&lt;/p&gt;
&lt;p&gt;The era where “build a developer tool” meant shipping an npm package, a binary, a VS Code extension, and a config schema at the same time isn’t over, but it’s contracting. Now you can ship a folder.&lt;/p&gt;
&lt;p&gt;If you end up building one, &lt;a href=&quot;https://agenthub.nullorder.org/&quot;&gt;list it on AgentHub&lt;/a&gt;. If you hit a wall, the AgentHub &lt;a href=&quot;https://discord.gg/AJMEeFXxXy&quot;&gt;Discord&lt;/a&gt; is where the plugin authors hang out.&lt;/p&gt;
&lt;p&gt;Now go ship something.&lt;/p&gt;
&lt;h3 id=&quot;references&quot; tabindex=&quot;-1&quot;&gt;References &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/claude-plugin-getting-started/#references&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Demo repo&lt;/strong&gt; — &lt;a href=&quot;https://github.com/anistark/claude-plugin-demo&quot;&gt;anistark/claude-plugin-demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Real plugin on AgentHub&lt;/strong&gt; — &lt;a href=&quot;https://github.com/anistark/ani-skills&quot;&gt;anistark/ani-skills&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AgentHub&lt;/strong&gt; — &lt;a href=&quot;https://agenthub.nullorder.org/&quot;&gt;agenthub.nullorder.org&lt;/a&gt; · &lt;a href=&quot;https://github.com/nullorder/agenthub&quot;&gt;source&lt;/a&gt; · &lt;a href=&quot;https://github.com/nullorder/agenthub/blob/main/CONTRIBUTING.md&quot;&gt;contributing guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Official Claude Code plugin docs&lt;/strong&gt; — &lt;a href=&quot;https://code.claude.com/docs/en/plugins&quot;&gt;Create plugins&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/plugins-reference#plugin-manifest-schema&quot;&gt;Manifest schema&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/plugin-marketplaces&quot;&gt;Marketplaces&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/discover-plugins&quot;&gt;Discover and install&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related reading&lt;/strong&gt; — &lt;a href=&quot;https://code.claude.com/docs/en/skills&quot;&gt;Skills&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/hooks&quot;&gt;Hooks&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/sub-agents&quot;&gt;Subagents&lt;/a&gt; · &lt;a href=&quot;https://code.claude.com/docs/en/mcp&quot;&gt;MCP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>N Reviewers Walk Into a PR...</title>
		<link href="https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/"/>
		<updated>2026-04-02T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/</id>
		<content type="html">&lt;h2 id=&quot;a-story-you%E2%80%99ve-lived&quot; tabindex=&quot;-1&quot;&gt;A Story You’ve Lived &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#a-story-you%E2%80%99ve-lived&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It’s 4:47 PM. You open a pull request. It touches 12 files across 3 directories. CI is green. You tag one reviewer (the person who happens to be online) and close your laptop.&lt;/p&gt;
&lt;p&gt;Three days later, a bug makes it to production. Your reviewer missed a subtle interaction between two of those 12 files. Not their fault. They were one human reading a diff the size of a short story. In hindsight, a second pair of eyes would’ve caught it in five minutes.&lt;/p&gt;
&lt;p&gt;Sound familiar? Yeah, me too.&lt;/p&gt;
&lt;p&gt;The question &lt;em&gt;“how many reviewers does this PR actually need?”&lt;/em&gt; is one every engineering team answers by vibes. Small PR? One reviewer. Massive PR? Also one reviewer, because nobody wants to be &lt;em&gt;that person&lt;/em&gt; who requests three reviews on a Friday afternoon.&lt;/p&gt;
&lt;p&gt;Here’s the thing: &lt;strong&gt;vibes don’t scale&lt;/strong&gt;. Teams grow. Codebases get gnarlier. PRs stack up. And the cost of under-reviewing compounds silently… right up until it very loudly doesn’t.&lt;/p&gt;
&lt;h2 id=&quot;the-tools-available-(and-why-they-fall-short)&quot; tabindex=&quot;-1&quot;&gt;The Tools Available (And Why They Fall Short) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#the-tools-available-(and-why-they-fall-short)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;GitHub gives you a decent toolkit for review workflows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Branch protection rules&lt;/strong&gt;: require a minimum number of approvals. But it’s a flat number. A one-line typo fix and a 2000-line refactor both need… 2 approvals? Really?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CODEOWNERS&lt;/strong&gt;: auto-assigns reviewers based on file paths. Tells you &lt;em&gt;who&lt;/em&gt;, not &lt;em&gt;how many&lt;/em&gt;. Great at “Alice owns the frontend” but useless at “this PR is big enough to need Alice &lt;em&gt;and&lt;/em&gt; Bob.”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/actions/labeler&quot;&gt;actions/labeler&lt;/a&gt;&lt;/strong&gt;: GitHub’s official labeling action. Labels PRs by file paths and branch names (&lt;code&gt;frontend&lt;/code&gt;, &lt;code&gt;docs&lt;/code&gt;, &lt;code&gt;feature&lt;/code&gt;). Super useful, but it has zero concept of change &lt;em&gt;size&lt;/em&gt; or review &lt;em&gt;effort&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;None of these answer the fundamental question: &lt;em&gt;for this specific PR, with these specific changes, how many humans should look at it?&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;enter%3A-pr-reviewer-labeler&quot; tabindex=&quot;-1&quot;&gt;Enter: PR Reviewer Labeler &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#enter%3A-pr-reviewer-labeler&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;So I built &lt;a href=&quot;https://github.com/anistark/pr-reviewer-labeler&quot;&gt;pr-reviewer-labeler&lt;/a&gt;, a GitHub Action that looks at every PR and figures out the ideal number of reviewers. Automatically. No vibes required.&lt;/p&gt;
&lt;p&gt;Here’s what it does:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Counts total lines changed (additions + deletions)&lt;/li&gt;
&lt;li&gt;Optionally weighs different file types differently (because 100 lines of tests ≠ 100 lines of auth middleware)&lt;/li&gt;
&lt;li&gt;Maps the result against configurable thresholds&lt;/li&gt;
&lt;li&gt;Slaps a label on the PR (&lt;code&gt;reviewers: 2&lt;/code&gt;) and drops a summary comment&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Think of it as a bouncer for your PR queue. “This PR is a 500-liner touching core auth? Yeah, you’re gonna need at least 3 reviewers. Next!”&lt;/p&gt;
&lt;h3 id=&quot;zero-config-setup-(seriously%2C-it%E2%80%99s-this-easy)&quot; tabindex=&quot;-1&quot;&gt;Zero-Config Setup (Seriously, It’s This Easy) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#zero-config-setup-(seriously%2C-it%E2%80%99s-this-easy)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;yml&quot;&gt;&lt;pre class=&quot;language-yml&quot;&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Reviewer Labeler&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; pull_request_target&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token key atrule&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token key atrule&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;permissions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token key atrule&quot;&gt;contents&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; read&lt;br /&gt;      &lt;span class=&quot;token key atrule&quot;&gt;pull-requests&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; write&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ubuntu&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;latest&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/pr&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;labeler@v1&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;That’s it. Out of the box, it uses these defaults:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Lines Changed&lt;/th&gt;
&lt;th&gt;Reviewers You’ll Get&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt; 50&lt;/td&gt;
&lt;td&gt;1 (quick glance)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50-199&lt;/td&gt;
&lt;td&gt;1 (solid read)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;200-499&lt;/td&gt;
&lt;td&gt;2 (buddy system)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500-999&lt;/td&gt;
&lt;td&gt;3 (bring friends)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1000+&lt;/td&gt;
&lt;td&gt;4 (all hands)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Every PR gets labeled and commented. No config files to maintain. No YAML rabbit holes. Just plug and play.&lt;/p&gt;
&lt;h3 id=&quot;your-team%2C-your-rules&quot; tabindex=&quot;-1&quot;&gt;Your Team, Your Rules &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#your-team%2C-your-rules&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Of course, a team of 3 doesn’t need the same scale as a team of 20. Tune the thresholds to your taste:&lt;/p&gt;
&lt;code-block lang=&quot;yml&quot;&gt;&lt;pre class=&quot;language-yml&quot;&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/pr&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;labeler@v1&lt;br /&gt;  &lt;span class=&quot;token key atrule&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;thresholds&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token scalar string&quot;&gt;&lt;br /&gt;      - lines: 30&lt;br /&gt;        reviewers: 1&lt;br /&gt;      - lines: 150&lt;br /&gt;        reviewers: 2&lt;br /&gt;      - lines: 400&lt;br /&gt;        reviewers: 3&lt;br /&gt;      - lines: 800&lt;br /&gt;        reviewers: 4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;not-all-lines-are-born-equal&quot; tabindex=&quot;-1&quot;&gt;Not All Lines Are Born Equal &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#not-all-lines-are-born-equal&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Here’s where it gets fun. A 500-line PR that’s mostly test files? Probably fine with 2 reviewers. A 500-line PR rewriting your payment processing? You might want the whole team in the room.&lt;/p&gt;
&lt;p&gt;File-type weighting lets you express this:&lt;/p&gt;
&lt;code-block lang=&quot;yml&quot;&gt;&lt;pre class=&quot;language-yml&quot;&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/pr&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;labeler@v1&lt;br /&gt;  &lt;span class=&quot;token key atrule&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;file-weights&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token scalar string&quot;&gt;&lt;br /&gt;      - glob: &quot;**/*.test.*&quot;&lt;br /&gt;        weight: 0.5&lt;br /&gt;      - glob: &quot;**/*.md&quot;&lt;br /&gt;        weight: 0.25&lt;br /&gt;      - glob: &quot;src/core/**&quot;&lt;br /&gt;        weight: 1.5&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Translation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tests&lt;/strong&gt; count at half. Important, but rarely where the sneaky bugs hide&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Docs&lt;/strong&gt; count at quarter. A README typo doesn’t need a 3-person review committee&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Core source&lt;/strong&gt; counts at 1.5x. This is where you want extra eyeballs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The action calculates both raw and weighted line counts, so you always see the full picture.&lt;/p&gt;
&lt;h2 id=&quot;what-happens-under-the-hood&quot; tabindex=&quot;-1&quot;&gt;What Happens Under the Hood &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#what-happens-under-the-hood&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For the curious (I see you), here’s the flow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Fetch changed files&lt;/strong&gt;: hits the GitHub API to get every file in the PR with its additions and deletions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weigh the lines&lt;/strong&gt;: each file gets matched against your glob patterns. Match found? Multiply by the weight. No match? Weight of 1.0. Business as usual&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pick the reviewer count&lt;/strong&gt;: walks through your thresholds (sorted lowest to highest) and finds the right tier&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Label the PR&lt;/strong&gt;: removes any stale reviewer labels from previous runs, applies the fresh one. Your PR always shows the current recommendation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Drop a comment&lt;/strong&gt;: posts a clean summary table. If it already commented before, it updates the existing one. No spam. No duplicates&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Push more commits? The label and comment update automatically. It’s fully idempotent, a fancy way of saying “it won’t make a mess.”&lt;/p&gt;
&lt;h3 id=&quot;wire-it-into-your-workflow&quot; tabindex=&quot;-1&quot;&gt;Wire It Into Your Workflow &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#wire-it-into-your-workflow&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The action exposes outputs you can chain into other steps:&lt;/p&gt;
&lt;code-block lang=&quot;yml&quot;&gt;&lt;pre class=&quot;language-yml&quot;&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; reviewers&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/pr&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;labeler@v1&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; steps.reviewers.outputs.reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;count &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;= 3&lt;br /&gt;    &lt;span class=&quot;token key atrule&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; echo &quot;Big PR detected. Maybe consider splitting this one up.&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Available outputs: &lt;code&gt;reviewer-count&lt;/code&gt;, &lt;code&gt;total-lines&lt;/code&gt;, &lt;code&gt;weighted-lines&lt;/code&gt;, and &lt;code&gt;label&lt;/code&gt;. Build whatever automation you want on top.&lt;/p&gt;
&lt;h2 id=&quot;best-friends-with-actions%2Flabeler&quot; tabindex=&quot;-1&quot;&gt;Best Friends With actions/labeler &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#best-friends-with-actions%2Flabeler&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This isn’t a replacement for &lt;a href=&quot;https://github.com/actions/labeler&quot;&gt;actions/labeler&lt;/a&gt;. It’s the other half of the story. They answer different questions:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Answers&lt;/th&gt;
&lt;th&gt;Example Labels&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;actions/labeler&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;What&lt;/em&gt; changed?&lt;/td&gt;
&lt;td&gt;&lt;code&gt;frontend&lt;/code&gt;, &lt;code&gt;docs&lt;/code&gt;, &lt;code&gt;feature&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pr-reviewer-labeler&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;How much&lt;/em&gt; changed?&lt;/td&gt;
&lt;td&gt;&lt;code&gt;reviewers: 2&lt;/code&gt;, &lt;code&gt;reviewers: 3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Run them together:&lt;/p&gt;
&lt;code-block lang=&quot;yml&quot;&gt;&lt;pre class=&quot;language-yml&quot;&gt;&lt;code class=&quot;language-yml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# What changed?&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; actions/labeler@v6&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;# How much changed?&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; anistark/pr&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;reviewer&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;labeler@v1&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now a PR labeled &lt;code&gt;frontend&lt;/code&gt; + &lt;code&gt;reviewers: 1&lt;/code&gt; paints a very different picture than &lt;code&gt;frontend&lt;/code&gt; + &lt;code&gt;reviewers: 3&lt;/code&gt;. Context at a glance.&lt;/p&gt;
&lt;h2 id=&quot;the-roadmap-(a.k.a.-%E2%80%9Ci-have-ideas%E2%80%9D)&quot; tabindex=&quot;-1&quot;&gt;The Roadmap (a.k.a. “I Have Ideas”) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#the-roadmap-(a.k.a.-%E2%80%9Ci-have-ideas%E2%80%9D)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is v1. It handles the core job well: sizing PRs and recommending reviewer counts. But I’m just getting started.&lt;/p&gt;
&lt;h3 id=&quot;codeowners-integration&quot; tabindex=&quot;-1&quot;&gt;CODEOWNERS Integration &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#codeowners-integration&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Right now it tells you &lt;em&gt;how many&lt;/em&gt;. Next up: &lt;em&gt;who&lt;/em&gt;. Imagine the action reading your &lt;code&gt;CODEOWNERS&lt;/code&gt; file and suggesting “This PR needs 2 reviewers: @alice (owns &lt;code&gt;src/auth/&lt;/code&gt;) and @bob (owns &lt;code&gt;src/api/&lt;/code&gt;).” That’s the dream.&lt;/p&gt;
&lt;h3 id=&quot;complexity-scoring&quot; tabindex=&quot;-1&quot;&gt;Complexity Scoring &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#complexity-scoring&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Line count is a solid start, but it’s not the whole story. A 200-line change in one file hits different than 200 lines scattered across 15 files in 8 directories. I want to factor in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How many directories the PR touches&lt;/li&gt;
&lt;li&gt;New files vs edits to existing ones&lt;/li&gt;
&lt;li&gt;Whether the change spans architectural layers (frontend + backend + infra = buckle up)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;auto-request-reviewers&quot; tabindex=&quot;-1&quot;&gt;Auto-Request Reviewers &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/n-reviewers-walk-into-a-pr/#auto-request-reviewers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The endgame: don’t just &lt;em&gt;suggest&lt;/em&gt; reviewers. &lt;em&gt;Assign&lt;/em&gt; them. Pick from a configured pool, skip the PR author, respect existing assignments. Full automation, zero friction.&lt;/p&gt;
&lt;p&gt;All of these are tracked as &lt;a href=&quot;https://github.com/anistark/pr-reviewer-labeler/issues&quot;&gt;open issues on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/erwin-this-is-where-you-come-in.png&quot; alt=&quot;This is where you come in&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I built this to scratch my own itch, but I know every team’s review culture is different. Maybe you need reviewer recommendations based on commit count, not line count. Maybe you want Slack notifications when a PR needs 3+ reviewers. Maybe you have an idea I haven’t thought of yet.&lt;/p&gt;
&lt;p&gt;I’d love to hear it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Try it out&lt;/strong&gt;: install from the &lt;a href=&quot;https://github.com/marketplace/actions/pr-reviewer-labeler&quot;&gt;GitHub Marketplace&lt;/a&gt; or just add &lt;code&gt;anistark/pr-reviewer-labeler@v1&lt;/code&gt; to your workflow&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open an issue&lt;/strong&gt;: feature requests, bug reports, wild ideas, all welcome at &lt;a href=&quot;https://github.com/anistark/pr-reviewer-labeler/issues&quot;&gt;github.com/anistark/pr-reviewer-labeler/issues&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Send a PR&lt;/strong&gt;: the codebase is small, TypeScript, well-tested, and MIT licensed. Jump in&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Star the repo&lt;/strong&gt;: if you think this should exist, let me know with a star. It helps others find it too&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;github-card repo=&quot;anistark/pr-reviewer-labeler&quot;&gt;&lt;/github-card&gt;&lt;/p&gt;
&lt;p&gt;Because no PR should go under-reviewed just because someone didn’t want to bother a third person on a Friday.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Software Without Pause</title>
		<link href="https://blog.anirudha.dev/software-without-pause/"/>
		<updated>2026-03-28T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/software-without-pause/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;Move fast and break things. That was the old motto. Now, things break even if you stand still.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A founder I know spent six months building an AI writing product. Good team. Real traction. Paying users. Then one Tuesday morning, a foundation model company dropped a feature that did the same thing, for free, baked into a product with 100 million users.&lt;/p&gt;
&lt;p&gt;Six months of work. Obsolete by lunch.&lt;/p&gt;
&lt;p&gt;This isn’t a cautionary tale. It’s the new normal. And the uncomfortable truth is that almost every business rulebook we’ve inherited was written for a world that no longer exists.&lt;/p&gt;
&lt;p&gt;A new model every few months. Then every few weeks. Then every few days. New startups, new products, new announcements every other day. The ground beneath every company, whether you’re building with AI or just building &lt;em&gt;near&lt;/em&gt; AI, is shifting faster than anyone’s planning cycle can keep up with.&lt;/p&gt;
&lt;p&gt;Just checkout &lt;a href=&quot;https://www.productcompass.pm/p/claude-shipping-calendar&quot;&gt;this article&lt;/a&gt; about everything claude team shipped in 52 days.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/claude-shipping.png&quot; alt=&quot;Claude Shippig&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So here’s the question worth sitting with: if the old rules are dead, what replaces them?&lt;/p&gt;
&lt;h2 id=&quot;the-rulebook-that-got-us-here&quot; tabindex=&quot;-1&quot;&gt;The Rulebook That Got Us Here &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#the-rulebook-that-got-us-here&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For decades, building a technology company followed a recognizable script.&lt;/p&gt;
&lt;p&gt;You found a market gap. You raised money. You hired engineers. You built a product over 12 to 18 months. You launched. You iterated based on feedback. You scaled. If things went well, you raised more, hired more, built more.&lt;/p&gt;
&lt;p&gt;The whole system was calibrated for a world where change was fast, but &lt;em&gt;predictable&lt;/em&gt;. You could forecast quarters. You could define a two-year roadmap and actually execute against it. Competitive advantages were durable enough to defend: your data moat, your distribution, your engineering team, your brand.&lt;/p&gt;
&lt;p&gt;Y Combinator’s early doctrine, Paul Graham’s essays, the Lean Startup methodology, Blitzscaling… all of it assumed that the competitive landscape, while intense, moved at a pace you could &lt;em&gt;plan around&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;That assumption held for a long time. It doesn’t anymore.&lt;/p&gt;
&lt;h2 id=&quot;a-pattern-we%E2%80%99ve-seen-before&quot; tabindex=&quot;-1&quot;&gt;A Pattern We’ve Seen Before &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#a-pattern-we%E2%80%99ve-seen-before&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you zoom out, this moment starts to feel familiar.&lt;/p&gt;
&lt;p&gt;When James Watt patented the improved steam engine in 1769, it took nearly 60 years before railways connected British cities. The first factories appeared in the 1780s. Labor laws didn’t catch up until the 1830s. An entire generation was born, lived, and died inside just the &lt;em&gt;first act&lt;/em&gt; of the Industrial Revolution.&lt;/p&gt;
&lt;p&gt;The engine didn’t just make factories faster. It moved populations. Manchester went from a town of 25,000 to a city of 300,000 in under a century. New social classes formed. The concept of a “job” as we know it, showing up to a place, doing defined work, getting paid by the hour, was invented during this period. Entire ways of living were rewritten. But it unfolded over decades. Generations. Slow enough that society could metabolize the change, even if painfully.&lt;/p&gt;
&lt;p&gt;The businesses that thrived weren’t the ones that built the best steam engine. They were the ones that understood what steam &lt;em&gt;meant&lt;/em&gt;: that geography was no longer a constraint on production. The cotton mills of Lancashire didn’t win because they had better machines. They won because they reorganized &lt;em&gt;everything&lt;/em&gt;, supply chains, labor, logistics, around what steam made possible.&lt;/p&gt;
&lt;p&gt;Then came the internet.&lt;/p&gt;
&lt;p&gt;Information began to move at near-zero cost. But even the internet’s disruption had a tempo you could follow. Amazon was founded in 1994 and didn’t turn a consistent profit until the mid-2000s. It took Netflix a decade to pivot from DVDs to streaming. The iPhone launched in 2007, but the mobile-first economy didn’t fully mature until the mid-2010s. Twenty to thirty years of runway. Slow enough for companies to adapt. Slow enough for people to re-skill.&lt;/p&gt;
&lt;p&gt;The winners of the internet era weren’t the ones who built the best websites. They were the ones who understood what near-zero distribution costs &lt;em&gt;meant&lt;/em&gt;: that you could reach everyone, that the marginal cost of serving one more customer approached zero, that network effects would create winner-take-all dynamics. Amazon, Google, Facebook didn’t just use the internet. They built business models that &lt;em&gt;only made sense&lt;/em&gt; because of the internet.&lt;/p&gt;
&lt;p&gt;Now compare that to what leaders like Jensen Huang are pointing at when they describe AI as the “Intelligence Revolution”: a shift not in muscle or information, but in cognition itself.&lt;/p&gt;
&lt;p&gt;GPT-3 arrived in mid-2020. By 2023, AI was writing legal briefs, generating production code, and composing music that charted. By 2025, autonomous agents were shipping features, debugging pipelines, and running customer support at scale. That’s not a 30-year arc. That’s 5 years from “interesting demo” to “reshaping industries.”&lt;/p&gt;
&lt;p&gt;The pattern is the same. Every great technological shift creates a window where the old rules stop working and the new ones haven’t been written yet. The businesses and people who figure it out during that window are the ones who define the next era.&lt;/p&gt;
&lt;p&gt;But the timeline has collapsed. The window is narrower than ever. And we’re standing in the middle of it right now.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/tech_contrast_dark.png&quot; alt=&quot;Tech Contrast Dark&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/tech_pace.png&quot; alt=&quot;Tech Pace&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This pace of transformation is insane, if not for the fact that we’re living this life right now. It would sound like science fiction if you read it in a book ten years ago. But here we are, watching entire product categories get created and destroyed in the time it used to take to finalize a roadmap. The speed isn’t theoretical. It’s Tuesday morning. It’s the notification you just got about another launch, another model, another startup that didn’t exist last week doing what took your team a quarter. We don’t get the luxury of processing this from a distance. We’re inside the blast radius, building while the ground shifts, and somehow that’s just… the job now.&lt;/p&gt;
&lt;h2 id=&quot;when-intelligence-became-a-primitive&quot; tabindex=&quot;-1&quot;&gt;When Intelligence Became a Primitive &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#when-intelligence-became-a-primitive&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The real shift isn’t that software got faster. Or that products ship more frequently. Those are symptoms.&lt;/p&gt;
&lt;p&gt;The deeper thing that happened is that intelligence itself became programmable.&lt;/p&gt;
&lt;p&gt;For most of history, intelligence was a constraint. You could hire it, train it, organize it, but you couldn’t &lt;em&gt;instantiate&lt;/em&gt; it on demand. Every company in history, no matter how wealthy, was bottlenecked by the number of smart people it could recruit, retain, and coordinate. That’s why org charts exist. That’s why management is a discipline. The entire machinery of corporate structure was invented to &lt;em&gt;organize scarce cognition&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Now you can spin up intelligence like a container. Need legal analysis? Call an API. Need code review at 3am? It’s already running. Need to evaluate 10,000 customer support tickets for sentiment? That’s a five-minute job now, not a six-week project.&lt;/p&gt;
&lt;p&gt;And once intelligence becomes a primitive, like storage, compute, or bandwidth before it, everything built on top of it changes.&lt;/p&gt;
&lt;p&gt;This is the part that most businesses haven’t fully internalized. We’ve had decades of strategy built around the assumption that smart human labor is the bottleneck. Hiring plans. Training programs. Talent wars. Retention packages. Entire industries (consulting, outsourcing, recruiting) exist because human cognition was scarce and expensive.&lt;/p&gt;
&lt;p&gt;What happens to all of that when cognition becomes abundant?&lt;/p&gt;
&lt;p&gt;Products are no longer bundles of features. They are expressions of capability. Notion went from a note-taking app to something that drafts, summarizes, and connects your thinking. Figma added AI and the canvas started &lt;em&gt;suggesting&lt;/em&gt; layouts. Cursor and Claude Code turned the code editor from a place where you type into something that &lt;em&gt;builds alongside you&lt;/em&gt;, scaffolding entire features from a description, catching bugs before you do, refactoring with an understanding of your codebase.&lt;/p&gt;
&lt;p&gt;And that raises a question (brought up by a friend just today in a discussion) that would have sounded absurd two years ago: why pay for an editor when you can pay for the agent? The editor, the IDE, the interface, those used to be the product. Now they’re becoming the shell around the thing that actually does the work. Cursor, VS Code with Copilot, Zed, they’re all positioning as agent-first environments, because they’ve recognized the shift. The value isn’t in syntax highlighting or file management anymore. It’s in the intelligence layer that understands your intent and acts on it. The editor is becoming a viewport into an agent’s workspace, not the workspace itself. As &lt;a href=&quot;https://x.com/karpathy/status/1886192184808149383&quot;&gt;Andrej Karpathy put it&lt;/a&gt;, “The hottest new programming language is English,” and if that’s true, the tool you need isn’t a better text editor. It’s a better thinker.&lt;/p&gt;
&lt;p&gt;We are moving from software that &lt;strong&gt;executes instructions&lt;/strong&gt; to systems that &lt;strong&gt;participate in outcomes&lt;/strong&gt;. And every business built on the old assumption, that value comes from organizing human intelligence efficiently, needs to rethink its foundations.&lt;/p&gt;
&lt;h2 id=&quot;the-old-guard-vs.-the-new-movement&quot; tabindex=&quot;-1&quot;&gt;The Old Guard vs. The New Movement &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#the-old-guard-vs.-the-new-movement&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can already see two very different responses playing out.&lt;/p&gt;
&lt;p&gt;The old guard is trying to absorb AI into their existing framework. They’re adding “AI features” to existing products. They’re hiring “AI teams” within traditional org structures. They’re running 18-month transformation programs. They’re treating AI like a tool to bolt on, not a force that changes the shape of the game itself.&lt;/p&gt;
&lt;p&gt;And then there’s the new movement.&lt;/p&gt;
&lt;p&gt;Pieter Levels runs multiple profitable products, mostly solo. Andrej Karpathy left OpenAI and started building and shipping educational tools on his own. Indie hackers are launching SaaS products in a weekend that would have taken a small team six months two years ago. The “weekend project” has become a legitimate go-to-market strategy.&lt;/p&gt;
&lt;p&gt;What once required teams of engineers, months of development, and layers of coordination can now, in many cases, be prototyped by a single person in days. Not because problems got easier. Because leverage exploded.&lt;/p&gt;
&lt;p&gt;A single developer with good taste and an AI assistant now has the output capacity of a small team. Not in theory. In practice. Right now. AI is acting as a force multiplier on every layer of the stack: writing code, generating designs, conducting research, even helping with strategic thinking.&lt;/p&gt;
&lt;p&gt;Meanwhile, consider what’s happening to the incumbents. In 2022, the conventional wisdom was that AI couldn’t write reliable code. By mid-2024, Devin launched as the “first AI software engineer” and every tech company scrambled to respond. By 2025, AI-assisted coding was standard practice at most startups. Companies that spent 18 months building traditional developer tools watched their market assumptions evaporate in a quarter.&lt;/p&gt;
&lt;p&gt;Jasper raised $125M to build an AI writing tool, then watched OpenAI launch ChatGPT and obliterate their moat in weeks. Stability AI raised hundreds of millions, then struggled as open-source alternatives and platform-native features caught up. The old thinking says your moat is your data, your distribution, your team. But when a foundation model company can replicate your core value proposition as a feature update on a Tuesday afternoon, that moat is a puddle.&lt;/p&gt;
&lt;p&gt;Here’s the irony: it used to be that bigger companies moved slowly. That was the &lt;em&gt;feature&lt;/em&gt; of being a startup. You found the gap between what a large incumbent knew it should build and how long it took them to actually build it. That gap was your runway. Steve Blank, the godfather of lean startup methodology, &lt;a href=&quot;https://steveblank.com/2009/08/25/the-speed-of-the-startup/&quot;&gt;built his entire framework&lt;/a&gt; around this asymmetry: startups win not by outspending incumbents, but by outmaneuvering them while they’re stuck in committee. Clayton Christensen’s &lt;em&gt;The Innovator’s Dilemma&lt;/em&gt; documented the same pattern across decades of industry: big companies see the disruption coming and still can’t move fast enough because their own success holds them hostage.&lt;/p&gt;
&lt;p&gt;But AI has collapsed that gap from both directions. The big companies are moving faster, shipping AI features at startup speed because the cost of experimentation has plummeted, and the small companies are discovering that their nimbleness advantage has shrunk because &lt;em&gt;everyone&lt;/em&gt; can move fast now. When Google can prototype and ship an AI feature in weeks, and a solo founder can do the same in days, the old “big company slow, startup fast” playbook stops being a reliable edge. The new gap isn’t speed of execution. It’s speed of &lt;em&gt;insight&lt;/em&gt;, seeing what to build before anyone else does.&lt;/p&gt;
&lt;p&gt;Capabilities change faster than planning cycles. Competitors appear overnight. Entire markets shift direction between board meetings.&lt;/p&gt;
&lt;h2 id=&quot;the-new-economics&quot; tabindex=&quot;-1&quot;&gt;The New Economics &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#the-new-economics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every great technological shift reshapes economics by making something abundant that used to be scarce. Understanding &lt;em&gt;what becomes cheap&lt;/em&gt; is the key to understanding &lt;em&gt;what becomes valuable&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Factories made physical production cheap. A shirt that once took a tailor days could be stamped out in minutes. The value shifted from the craftsman’s hands to the factory owner’s capital. The people who understood this built empires. The ones who kept thinking in terms of craftsmanship got outscaled.&lt;/p&gt;
&lt;p&gt;The internet made distribution cheap. Sending information across the world went from expensive (fax machines, postal mail, phone calls) to effectively free. The value shifted from owning distribution channels to creating things worth distributing. The people who understood this built Google, YouTube, Spotify. The ones who kept thinking in terms of distribution gatekeeping (newspapers, record labels, broadcast networks) spent two decades in decline.&lt;/p&gt;
&lt;p&gt;AI is making &lt;em&gt;thinking&lt;/em&gt; cheap.&lt;/p&gt;
&lt;p&gt;Analysis that required a team of consultants and six weeks? An afternoon. Code that needed a senior engineer? A well-written prompt. A market research report? Minutes, not months.&lt;/p&gt;
&lt;p&gt;And when thinking becomes abundant, value shifts again. It moves away from &lt;em&gt;doing the work&lt;/em&gt; and toward &lt;em&gt;deciding what work matters&lt;/em&gt;. Strategy over execution. Curation over creation. Asking the right question over computing the answer.&lt;/p&gt;
&lt;p&gt;This is economics 101 playing out in real time: when supply explodes, price drops. The supply of cognitive labor is exploding. Which means the premium falls on the things AI &lt;em&gt;can’t&lt;/em&gt; easily replicate: &lt;strong&gt;taste, judgment, conviction, and the willingness to make a call when the data is ambiguous&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The founders and companies that understand this are already reorganizing around it. They’re not asking “how do we use AI to do what we already do, faster?” They’re asking “what becomes possible now that cognition is cheap?” Those are fundamentally different questions, and they lead to fundamentally different businesses.&lt;/p&gt;
&lt;h2 id=&quot;the-recursive-engine&quot; tabindex=&quot;-1&quot;&gt;The Recursive Engine &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#the-recursive-engine&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Perhaps the most unsettling part of this shift, and the reason it feels so different from anything before, is how recursive it is.&lt;/p&gt;
&lt;p&gt;AI is not just helping us build products. It is helping us build &lt;em&gt;better systems for building products&lt;/em&gt;. Which then accelerates how fast the next generation of products can be created. Which generates more data. Which makes AI better. Which…&lt;/p&gt;
&lt;p&gt;You see where this is going.&lt;/p&gt;
&lt;p&gt;It’s already happening concretely. AI models are being used to generate synthetic training data for the next generation of AI models. AI coding assistants are being used to write the code for better AI coding assistants. Anthropic used Claude to help build Claude. The tool is improving the toolmaker.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/ai_flywheel.png&quot; alt=&quot;Ai Flywheel&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Each cycle shorter than the last. Each iteration more powerful.&lt;/p&gt;
&lt;p&gt;Steam engines didn’t build better steam engines. The printing press didn’t write better books. The internet didn’t architect a better internet. But AI is actively involved in making AI better. That’s a fundamentally different kind of feedback loop, one that doesn’t just compound, but &lt;em&gt;accelerates its own compounding&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;For businesses, this means the competitive landscape isn’t just changing fast. It’s changing &lt;em&gt;faster every quarter&lt;/em&gt;. The pace of disruption itself is accelerating. A strategy that was brilliant six months ago might be irrelevant today, not because it was wrong, but because the world it was designed for no longer exists.&lt;/p&gt;
&lt;p&gt;Not just change, but &lt;strong&gt;change that gets better at changing&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;rethinking-the-fundamentals&quot; tabindex=&quot;-1&quot;&gt;Rethinking the Fundamentals &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#rethinking-the-fundamentals&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;So if the old rules are dead, what does the new approach look like?&lt;/p&gt;
&lt;p&gt;It’s still being written. But some patterns are emerging from the founders and companies that seem to be getting it right.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Think in weeks, not quarters.&lt;/strong&gt; The planning horizon has collapsed. Companies that thrive in this environment are running rapid experiments, not executing against 18-month roadmaps. They ship something, learn from it, and adjust, often within the same week. The question isn’t “what will we build this quarter?” It’s “what can we learn this week?”&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Optimize for learning velocity, not output.&lt;/strong&gt; The old metric was shipping speed: how fast can we build and launch? The new metric is learning speed: how fast can we understand what’s changing and adapt to it? The companies that look like research labs with a revenue model are outperforming the ones that look like traditional execution machines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Stay close to the frontier.&lt;/strong&gt; In a world where foundation model capabilities change every few weeks, the biggest risk isn’t building the wrong thing. It’s building the right thing on yesterday’s assumptions. The founders who spend time understanding what the latest models can actually do, not what the marketing says, but what they can &lt;em&gt;do&lt;/em&gt; in practice, have an enormous edge over those who treat the model as a black box.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Build for disposability.&lt;/strong&gt; This sounds counterintuitive, but the best companies in this environment aren’t building cathedrals. They’re building things they’re prepared to throw away and rebuild when the underlying capabilities shift. The cost of rebuilding has dropped dramatically. The cost of being stuck with the wrong architecture hasn’t.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Leverage over headcount.&lt;/strong&gt; The old logic said: to do more, hire more. The new logic says: to do more, multiply what you have. A small, sharp team with strong AI leverage can outpace a team ten times its size. The competitive advantage is no longer in the number of people you have, but in how much each person can do.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Judgment is the moat.&lt;/strong&gt; When execution is cheap, the differentiator is knowing &lt;em&gt;what to execute on&lt;/em&gt;. Taste. Strategy. The ability to read the landscape and make a call. The premium isn’t on building anymore. It’s on deciding what to build.&lt;/p&gt;
&lt;h2 id=&quot;getting-ahead-of-the-curve&quot; tabindex=&quot;-1&quot;&gt;Getting Ahead of the Curve &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/software-without-pause/#getting-ahead-of-the-curve&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every generation believes it is living through unprecedented change. Most of them are wrong.&lt;/p&gt;
&lt;p&gt;This time feels different. And I know, that’s exactly what someone living through any era would say. But consider the structural argument: every previous revolution amplified something &lt;em&gt;external&lt;/em&gt; to cognition. Muscles. Movement. Communication. The thing doing the &lt;em&gt;thinking about the revolution&lt;/em&gt;, the human mind, remained unchanged. It was always the constant in the equation.&lt;/p&gt;
&lt;p&gt;For the first time, the variable &lt;em&gt;is&lt;/em&gt; the mind.&lt;/p&gt;
&lt;p&gt;The Industrial Revolution gave us machines that amplified our bodies. The internet gave us systems that amplified our communication. AI is giving us something far more powerful: systems that amplify our minds. And once the thing that &lt;em&gt;drives&lt;/em&gt; progress is itself being accelerated, the pace doesn’t just increase. It escapes.&lt;/p&gt;
&lt;p&gt;Getting ahead of the curve doesn’t mean predicting the future. Nobody can do that right now, and anyone who claims otherwise is selling something. It means building the &lt;em&gt;capacity to respond&lt;/em&gt; faster than everyone else.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Arie de Geus, who studied corporate longevity at Shell, wrote that “the ability to learn faster than your competitors may be the only sustainable competitive advantage.” He wrote that in 1988. It’s never been more true than right now.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The founders who win won’t be the ones who made the best prediction about where AI is heading. They’ll be the ones who built organizations, products, and habits of mind that can absorb whatever comes next without breaking.&lt;/p&gt;
&lt;p&gt;Because when everything else is moving (the models, the tools, the platforms, the expectations, the economics), the only way to win is to move with it.&lt;/p&gt;
&lt;p&gt;And honestly? That’s the exciting part. We’re not watching this revolution from the outside. We’re building inside it. Every day. The tools are better than yesterday. The possibilities are wider than last week. And the thing we ship tomorrow will be built on capabilities that don’t exist yet today.&lt;/p&gt;
&lt;p&gt;Software without pause. Building without pause.&lt;/p&gt;
&lt;p&gt;That’s not a warning. That’s an invitation.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The Missing Playbook for AI Agents</title>
		<link href="https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/"/>
		<updated>2026-03-17T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/</id>
		<content type="html">&lt;p&gt;Recently I went to an AI conference and saw dozens of people demo their agents. Agents that could search the web, summarize documents, write code, book meetings, deploy to staging, you name it. The demos were impressive. But every time someone in the audience pushed back with a slightly unexpected question or asked the agent to chain two tasks together, things fell apart. Hallucinated tools. Made-up API arguments. Confident reports of success when nothing had actually happened.&lt;/p&gt;
&lt;p&gt;These weren’t hobbyists. These were solid engineers, people who know how to build reliable backend systems, design clean APIs, write thorough tests, and deploy with confidence. But the moment they started building agents, all of that discipline vanished. It was back to trial and error, vibes, and “let me tweak this prompt one more time.”&lt;/p&gt;
&lt;p&gt;Walking out of that conference, something crystallized for me:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We don’t have a tooling problem with agents. We have a &lt;strong&gt;methodology&lt;/strong&gt; problem.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Because an agent is not magic. It’s just an app where the control flow is partially owned by an LLM. And we already know how to build apps.&lt;/p&gt;
&lt;h2 id=&quot;the-core-parallel&quot; tabindex=&quot;-1&quot;&gt;The Core Parallel &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#the-core-parallel&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’ve built backend systems, you already understand agents. You just don’t realize it yet.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Building Apps&lt;/th&gt;
&lt;th&gt;Building Agents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Frontend / UI&lt;/td&gt;
&lt;td&gt;User Input / Chat Interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend Logic&lt;/td&gt;
&lt;td&gt;LLM Reasoning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;REST/GraphQL APIs&lt;/td&gt;
&lt;td&gt;Tools (functions the LLM can call)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;Memory (short-term and long-term)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Event Loop / Request Lifecycle&lt;/td&gt;
&lt;td&gt;Agent Loop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logs &amp;amp; Monitoring&lt;/td&gt;
&lt;td&gt;Traces &amp;amp; Evals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error Handling &amp;amp; Retries&lt;/td&gt;
&lt;td&gt;Guardrails &amp;amp; Fallbacks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The mapping might not be perfect, but it’s close enough to be useful. Every hard-won lesson from building distributed systems (separation of concerns, graceful degradation, observability, testing) applies directly to agents.&lt;/p&gt;
&lt;p&gt;The problem is that most people treat agent-building as a fundamentally new discipline. It isn’t. It’s systems engineering with a non-deterministic component in the middle.&lt;/p&gt;
&lt;h2 id=&quot;designing-an-agent-%3D-designing-a-system&quot; tabindex=&quot;-1&quot;&gt;Designing an Agent = Designing a System &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#designing-an-agent-%3D-designing-a-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you start a new backend service, you don’t jump straight into code. You ask:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What’s the user goal?&lt;/li&gt;
&lt;li&gt;What are the flows?&lt;/li&gt;
&lt;li&gt;What APIs do we need?&lt;/li&gt;
&lt;li&gt;What can go wrong?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Same exact process applies here. You might have your own process and own set of questions depending on what and how you want to build, for whom, so on. But there’ll be some design decisions that you need to take before you start building.&lt;/p&gt;
&lt;h3 id=&quot;1.-goal-clarity%3A-single-shot-vs-multi-step&quot; tabindex=&quot;-1&quot;&gt;1. Goal clarity: single-shot vs multi-step &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#1.-goal-clarity%3A-single-shot-vs-multi-step&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A single-shot agent takes a request and returns a response. Think: “Summarize this document.” A multi-step agent plans, executes, observes, and iterates. Think: “Research this topic, find relevant papers, compare their findings, and write a report.”&lt;/p&gt;
&lt;p&gt;Most people jump straight to multi-step because it feels more impressive. But single-shot agents are easier to test, cheaper to run, and more predictable. Start there. Upgrade when you have evidence that you need more.&lt;/p&gt;
&lt;h3 id=&quot;2.-control-style%3A-how-much-autonomy-does-the-llm-get%3F&quot; tabindex=&quot;-1&quot;&gt;2. Control style: how much autonomy does the LLM get? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#2.-control-style%3A-how-much-autonomy-does-the-llm-get%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is the architectural decision most people skip, and it’s the one that matters most.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reactive (ReAct)&lt;/strong&gt;: The LLM decides what to do at each step based on what it observes. Flexible, but hard to predict. Think of it like giving someone directions one turn at a time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Plan-then-execute&lt;/strong&gt;: The LLM creates a plan upfront, then executes it step by step. More predictable, but brittle when the plan hits reality. Like writing out all the directions before the trip.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hybrid&lt;/strong&gt;: Plan first, but allow re-planning when observations don’t match expectations. This is where most production agents end up.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;https://arxiv.org/abs/2210.03629&quot;&gt;ReAct paper&lt;/a&gt; by Yao and others formalized the reasoning + acting loop that most agent frameworks now implement. Worth reading if you want to understand the foundations.&lt;/p&gt;
&lt;h3 id=&quot;3.-tool-surface-area%3A-narrow-vs-wide&quot; tabindex=&quot;-1&quot;&gt;3. Tool surface area: narrow vs wide &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#3.-tool-surface-area%3A-narrow-vs-wide&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Every tool you give an agent is a degree of freedom. More tools means more capability, but also more ways to fail. A tool is essentially an API the LLM can call, and just like with microservices, the question isn’t “can we add another endpoint?” but “should we?”&lt;/p&gt;
&lt;p&gt;Start with 2-3 tools. Add more only when you can demonstrate the agent needs them. This isn’t minimalism for aesthetics, it’s minimalism for reliability.&lt;/p&gt;
&lt;h2 id=&quot;the-architecture-shift&quot; tabindex=&quot;-1&quot;&gt;The Architecture Shift &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#the-architecture-shift&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In a traditional app:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/app-architecture.png&quot; alt=&quot;Traditional App Architecture&quot; /&gt;&lt;/p&gt;
&lt;p&gt;You control every step. The flow is deterministic. If something breaks, you can trace exactly where.&lt;/p&gt;
&lt;p&gt;In an agent system:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/agent-architecture.png&quot; alt=&quot;Agent Architecture&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The key shift you’d notice by now is that in apps, you control the flow. In agents, you design the &lt;strong&gt;boundaries&lt;/strong&gt; of control. You decide which tools exist, what they can do, how much context the LLM sees, and when to stop. The LLM decides everything else within those boundaries.&lt;/p&gt;
&lt;p&gt;This is why agent design is closer to API design than to prompt engineering. You’re defining an interface and a contract, not writing instructions.&lt;/p&gt;
&lt;h2 id=&quot;building-the-agent&quot; tabindex=&quot;-1&quot;&gt;Building the Agent &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#building-the-agent&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In app development, the implementation phase is: pick your stack, wire your APIs, implement your logic. In agents, it’s: pick your model, define your tools, define your loop.&lt;/p&gt;
&lt;h3 id=&quot;the-minimal-agent-loop&quot; tabindex=&quot;-1&quot;&gt;The Minimal Agent Loop &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#the-minimal-agent-loop&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Every agent, regardless of framework, follows this pattern:&lt;/p&gt;
&lt;pre class=&quot;mermaid&quot;&gt;flowchart TD
    A[User Input] --&gt; B[LLM Planner]
    B --&gt; C{Need a Tool?}
    C -- Yes --&gt; D[Tool Call]
    D --&gt; E[Tool Result]
    E --&gt; B
    C -- No --&gt; F[Final Answer]
&lt;/pre&gt;&lt;p&gt;Here’s what that looks like in practice with a simple Python implementation:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; anthropic&lt;br /&gt;&lt;br /&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; anthropic&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Anthropic&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;tools &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;search_docs&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Search internal documentation for relevant information&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;input_schema&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;object&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;properties&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;query&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Search query&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;required&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;query&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_agent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user_message&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; max_steps&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    messages &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; user_message&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; step &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;max_steps&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;claude-sonnet-4-6&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            max_tokens&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            tools&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;tools&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            messages&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;messages&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;# If the model wants to use a tool&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;stop_reason &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_use&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            tool_block &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; b &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_use&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            tool_result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; execute_tool&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;assistant&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;tool_use_id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; tool_result&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token comment&quot;&gt;# Model is done, return the final response&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;text&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Agent reached maximum steps without completing.&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;That’s it. That’s a working agent. No framework, no abstractions. Just a loop that lets an LLM call tools and reason about results.&lt;/p&gt;
&lt;h3 id=&quot;start-small%2C-then-expand&quot; tabindex=&quot;-1&quot;&gt;Start Small, Then Expand &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#start-small%2C-then-expand&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Most people overbuild agents.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I’ve seen teams start with 15 tools, a vector database for memory, a planning module, a reflection step, and a custom evaluation pipeline, all before they’ve validated that the agent can reliably do the one thing it’s supposed to do.&lt;/p&gt;
&lt;p&gt;Start with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 model&lt;/li&gt;
&lt;li&gt;2-3 tools&lt;/li&gt;
&lt;li&gt;No memory&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Get that working reliably. Then add complexity one piece at a time, measuring the impact of each addition. This is the same advice we give for microservices: start with a monolith, extract services when you have a reason to.&lt;/p&gt;
&lt;h3 id=&quot;skills%3A-the-building-blocks&quot; tabindex=&quot;-1&quot;&gt;Skills: The Building Blocks &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#skills%3A-the-building-blocks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As your agent grows beyond a few tools, you’ll notice something. The interesting behavior isn’t in the agent loop itself, it’s in the capabilities the agent calls. Searching, summarizing, classifying, extracting, judging. These are &lt;strong&gt;skills&lt;/strong&gt;, the smallest units of intelligence that actually produce outcomes.&lt;/p&gt;
&lt;p&gt;Most teams embed skills directly into prompts or tool wrappers, tightly coupled to a specific agent. That works early on, but it doesn’t scale. When a skill is buried inside a prompt, you can’t test it in isolation, you can’t reuse it across agents, and you can’t improve it without risking regressions elsewhere.&lt;/p&gt;
&lt;p&gt;The better approach is to treat skills as first-class artifacts. A skill has a clear interface, it can run independently, and its behavior can be measured. Think of it like the difference between inline code and a well-defined function with a contract. The agent decides &lt;em&gt;what&lt;/em&gt; to do. The skill defines &lt;em&gt;how&lt;/em&gt; it gets done.&lt;/p&gt;
&lt;p&gt;This separation pays off quickly. Agents become simpler because they’re just orchestration. Debugging gets easier because you can isolate which skill misbehaved. And reuse becomes real, not just theoretical. A summarization skill that works for your research agent can plug into your customer support agent without rewriting anything.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills&quot;&gt;Anthropic’s agent skills framework&lt;/a&gt; formalizes this idea, treating skills as discoverable, composable units rather than implicit prompt logic. I’ve been building on this with &lt;a href=&quot;https://github.com/anistark/sutras&quot;&gt;Sutras&lt;/a&gt;, a CLI that handles the lifecycle around skills: authoring, validation, evaluation, versioning, and distribution. Because having a spec for what a skill is doesn’t help much if you can’t test it, version it, or share it. &lt;a href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/&quot;&gt;Here’s&lt;/a&gt; a detailed article on Skills and Sutras.&lt;/p&gt;
&lt;p&gt;If you’re building agents that need to do more than one or two things well, start thinking in skills early. It’ll save you from the “giant prompt that does everything” trap.&lt;/p&gt;
&lt;h3 id=&quot;frameworks-and-when-to-use-them&quot; tabindex=&quot;-1&quot;&gt;Frameworks and When to Use Them &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#frameworks-and-when-to-use-them&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you’re building something simple, you probably don’t need a framework. The code above is ~30 lines. But as complexity grows, frameworks help with orchestration, state management, and tool registration.&lt;/p&gt;
&lt;p&gt;Some worth knowing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/langchain-ai/langgraph&quot;&gt;LangGraph&lt;/a&gt;: Graph-based agent orchestration from LangChain. Good for complex multi-step workflows where you need explicit control over the execution graph.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/crewAIInc/crewAI&quot;&gt;CrewAI&lt;/a&gt;: Multi-agent collaboration framework. Useful when your problem naturally decomposes into roles (researcher, writer, reviewer).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/anthropics/anthropic-sdk-python&quot;&gt;Anthropic’s Agent SDK&lt;/a&gt;: Lightweight, close-to-the-metal. Good when you want control without too much abstraction.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/microsoft/autogen&quot;&gt;Autogen&lt;/a&gt;: Microsoft’s multi-agent framework. Strong on conversation patterns between agents.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The right choice depends on your use case, not on what’s trending on Linkedin or X(Twitter). A single-agent tool-use loop doesn’t need LangGraph. A multi-agent research pipeline probably does.&lt;/p&gt;
&lt;h2 id=&quot;testing-agents%3A-the-missing-discipline&quot; tabindex=&quot;-1&quot;&gt;Testing Agents: The Missing Discipline &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#testing-agents%3A-the-missing-discipline&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is where the gap between “app thinking” and “agent thinking” is widest.&lt;/p&gt;
&lt;p&gt;In app development, we have decades of established practice: unit tests, integration tests, end-to-end tests, staging environments, CI/CD pipelines. In the agent world? Mostly vibes. Someone runs the agent a few times, eyeballs the output, and calls it good.&lt;/p&gt;
&lt;p&gt;That’s not engineering. That’s a demo.&lt;/p&gt;
&lt;h3 id=&quot;the-agent-testing-stack&quot; tabindex=&quot;-1&quot;&gt;The Agent Testing Stack &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#the-agent-testing-stack&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent Testing&lt;/th&gt;
&lt;th&gt;App Equivalent&lt;/th&gt;
&lt;th&gt;What It Catches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tool unit tests&lt;/td&gt;
&lt;td&gt;Unit tests&lt;/td&gt;
&lt;td&gt;Broken tools, bad schemas&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Single-step evals&lt;/td&gt;
&lt;td&gt;Function tests&lt;/td&gt;
&lt;td&gt;Wrong tool selection, bad arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-step trajectory evals&lt;/td&gt;
&lt;td&gt;Integration tests&lt;/td&gt;
&lt;td&gt;Planning failures, loops, dead ends&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prompt injection tests&lt;/td&gt;
&lt;td&gt;Security testing&lt;/td&gt;
&lt;td&gt;Adversarial manipulation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Eval datasets with scoring&lt;/td&gt;
&lt;td&gt;Regression testing&lt;/td&gt;
&lt;td&gt;Quality degradation over time&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I’ve written about &lt;a href=&quot;https://blog.anirudha.dev/ai-evals/&quot;&gt;evals&lt;/a&gt; and &lt;a href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/&quot;&gt;building trustworthy AI tools&lt;/a&gt; before, and everything in those posts applies here. But agents add a new dimension: you’re not just evaluating a single output, you’re evaluating a &lt;strong&gt;trajectory&lt;/strong&gt;, the sequence of decisions the agent made to get there.&lt;/p&gt;
&lt;h3 id=&quot;evaluating-trajectories%2C-not-just-outputs&quot; tabindex=&quot;-1&quot;&gt;Evaluating Trajectories, Not Just Outputs &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#evaluating-trajectories%2C-not-just-outputs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A wrong answer that came from a reasonable chain of reasoning is very different from a right answer that came from lucky hallucination. You need to evaluate both.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;collections &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Faithfulness&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;llms &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; llm_factory&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Works with any supported model: gpt-4o-mini, claude-sonnet, gemini-pro, etc.&lt;/span&gt;&lt;br /&gt;llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;faithfulness &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Faithfulness&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Evaluate whether the agent&#39;s final answer is grounded in what its tools returned&lt;/span&gt;&lt;br /&gt;result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; faithfulness&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    user_input&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;What were our Q4 sales?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;agent_final_answer&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    retrieved_contexts&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;tool_results_from_agent_run&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Score: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;# e.g. 0.85&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Reason: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;reason&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;# explanation of the score&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;The &lt;code&gt;MetricResult&lt;/code&gt; object gives you both a score and a reason, so you know not just &lt;em&gt;how faithful&lt;/em&gt; the answer is but &lt;em&gt;why&lt;/em&gt; it scored that way. This tells you whether the agent’s answer is grounded in the information it actually retrieved, not whether it sounds plausible.&lt;/p&gt;
&lt;h3 id=&quot;the-eval-mindset&quot; tabindex=&quot;-1&quot;&gt;The Eval Mindset &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#the-eval-mindset&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;pre class=&quot;mermaid&quot;&gt;flowchart TD
    A[Test Dataset] --&gt; B[Agent Runs]
    B --&gt; C[Outputs + Trajectories]
    C --&gt; D[Scoring: Correctness, Faithfulness, Tool Use]
    D --&gt; E[Pass/Fail + Metrics Dashboard]
    E --&gt; F{Regression?}
    F -- Yes --&gt; G[Investigate &amp; Fix]
    F -- No --&gt; H[Ship It]
&lt;/pre&gt;&lt;blockquote&gt;
&lt;p&gt;If you’re not running evals, you don’t have an agent. You have a demo.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I keep coming back to this because it’s the single biggest gap I see. Teams spend weeks building agent capabilities and zero hours building agent evals. Then they’re surprised when the agent breaks in production.&lt;/p&gt;
&lt;p&gt;If you need help getting started with evals, &lt;a href=&quot;https://ragas.io/&quot;&gt;Ragas&lt;/a&gt; is a solid starting point. For more on the philosophy, the &lt;a href=&quot;https://docs.anthropic.com/en/docs/build-with-claude/develop-tests&quot;&gt;Anthropic guide to evaluations&lt;/a&gt; is excellent.&lt;/p&gt;
&lt;h2 id=&quot;running-agents&quot; tabindex=&quot;-1&quot;&gt;Running Agents &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#running-agents&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Traditional apps follow a clean request/response cycle. A request comes in, business logic runs, a response goes out. Stateless, predictable, well-understood.&lt;/p&gt;
&lt;p&gt;Agents break this model in several ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;They loop.&lt;/em&gt; An agent might make 3 tool calls or 30, depending on the task.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;They’re stateful.&lt;/em&gt; Context accumulates across steps within a single run.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;They’re slow.&lt;/em&gt; A multi-step agent might take 30 seconds or 3 minutes to complete.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;They’re expensive.&lt;/em&gt; Each step consumes tokens, and tokens cost money.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;runtime-patterns&quot; tabindex=&quot;-1&quot;&gt;Runtime Patterns &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#runtime-patterns&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Short-lived agents&lt;/strong&gt;: Synchronous, request/response. The user waits. Good for simple tool-use (under 10 seconds). This is your starting point.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Long-running agents&lt;/strong&gt;: Async, queue-based. The user submits a task and checks back later. Necessary when the agent might run for minutes. Think: research tasks, code generation with testing, data analysis pipelines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Streaming agents&lt;/strong&gt;: Partial outputs as the agent works. The user sees progress. Good for chat interfaces where you want to show the agent’s reasoning in real-time. Most modern APIs (Claude, GPT, Gemini, Mistral, GLM) support streaming natively.&lt;/p&gt;
&lt;h3 id=&quot;failure-modes-you-must-handle&quot; tabindex=&quot;-1&quot;&gt;Failure Modes You Must Handle &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#failure-modes-you-must-handle&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is where agent systems diverge sharply from traditional apps. In a normal API, if a request fails, you return a 500 and the client retries. In an agent, failures are more insidious:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tool failures&lt;/strong&gt;: An API is down, a database query times out. The agent needs to know how to handle this gracefully: retry, skip, or ask the user.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hallucinated tool arguments&lt;/strong&gt;: The LLM invents parameters that don’t exist or passes the wrong types. This is the agent equivalent of a type error, except your type system is a prompt.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Infinite loops&lt;/strong&gt;: The agent keeps calling the same tool with the same arguments, expecting different results. Without a step limit, you burn through tokens and patience.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Context window overflow&lt;/strong&gt;: In long-running agents, the conversation history grows until it exceeds the model’s context window. You need a strategy for summarizing or truncating.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Handling these isn’t optional. It’s the difference between a demo and a product.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_agent_with_guardrails&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user_message&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    max_steps &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;15&lt;/span&gt;&lt;br /&gt;    max_consecutive_errors &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;br /&gt;    error_count &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    messages &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; user_message&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; step &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;max_steps&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;                model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;claude-sonnet-4-6&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                max_tokens&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                tools&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;tools&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                messages&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;messages&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            error_count &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Reset on success&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;stop_reason &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_use&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                tool_block &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;b &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; b &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; b&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_use&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; execute_tool&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; ToolExecutionError &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Tool error: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;. Try a different approach.&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;assistant&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;                messages&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_result&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tool_use_id&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; tool_block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;text&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; Exception &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            error_count &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; error_count &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; max_consecutive_errors&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Agent stopped after &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;max_consecutive_errors&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; consecutive errors: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Agent reached step limit. Partial progress may be available.&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;making-it-real&quot; tabindex=&quot;-1&quot;&gt;Making It Real &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#making-it-real&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Deploying an agent is deploying a backend service, plus extra concerns unique to LLM-based systems.&lt;/p&gt;
&lt;h3 id=&quot;cost&quot; tabindex=&quot;-1&quot;&gt;Cost &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#cost&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Every agent step is an API call. Every API call costs tokens. A multi-step agent that makes 10 tool calls per request can easily cost 10-50x more than a single LLM call. You need to budget for this.&lt;/p&gt;
&lt;p&gt;Practical strategies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use cheaper models (Claude Haiku, GPT-4o-mini, Gemini Flash, Qwen-turbo) for simple steps, expensive models (Claude Opus, GPT-4, Gemini Pro, Mistral Large) for complex reasoning.&lt;/li&gt;
&lt;li&gt;Cache tool results aggressively. If two users ask about the same data, don’t re-fetch.&lt;/li&gt;
&lt;li&gt;Set hard token budgets per agent run.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;latency&quot; tabindex=&quot;-1&quot;&gt;Latency &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#latency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Multi-step agents are inherently slow. Each step requires a round-trip to the model API. A 5-step agent with 2-second API latency takes at minimum 10 seconds.&lt;/p&gt;
&lt;p&gt;Strategies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parallelize independent tool calls where possible.&lt;/li&gt;
&lt;li&gt;Stream partial outputs so the user sees progress.&lt;/li&gt;
&lt;li&gt;Set user expectations. A loading spinner that says “Researching…” is better than a blank screen for 30 seconds.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;observability&quot; tabindex=&quot;-1&quot;&gt;Observability &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#observability&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is where &lt;a href=&quot;https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching&quot;&gt;traces&lt;/a&gt; become critical. Logs tell you &lt;em&gt;what&lt;/em&gt; happened. Traces tell you &lt;em&gt;why&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;For every agent run, you want to capture:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The user’s original request&lt;/li&gt;
&lt;li&gt;Each LLM call (input, output, model, latency, token usage)&lt;/li&gt;
&lt;li&gt;Each tool call (name, arguments, result, duration)&lt;/li&gt;
&lt;li&gt;The final output&lt;/li&gt;
&lt;li&gt;Total cost and duration&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;mermaid&quot;&gt;flowchart TD
    A[User Query] --&gt; B[Agent Run]
    B --&gt; C[Tool Calls]
    B --&gt; D[LLM Reasoning Steps]
    C --&gt; E[Structured Logs]
    D --&gt; E
    E --&gt; F[Tracing Dashboard]
    F --&gt; G[Cost Tracking]
    F --&gt; H[Latency Analysis]
    F --&gt; I[Error Patterns]
&lt;/pre&gt;&lt;p&gt;Tools like &lt;a href=&quot;https://langfuse.com/&quot;&gt;Langfuse&lt;/a&gt;, &lt;a href=&quot;https://braintrustdata.com/&quot;&gt;Braintrust&lt;/a&gt;, and &lt;a href=&quot;https://phoenix.arize.com/&quot;&gt;Arize Phoenix&lt;/a&gt; are purpose-built for this. If you’re already using Datadog or Grafana, you can pipe agent traces there too.&lt;/p&gt;
&lt;h2 id=&quot;memory%3A-the-state-management-problem&quot; tabindex=&quot;-1&quot;&gt;Memory: The State Management Problem &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#memory%3A-the-state-management-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Memory in agents maps directly to state management in apps. And just like in apps, getting it wrong leads to subtle, hard-to-debug issues.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Short-term memory&lt;/strong&gt; is the conversation history within a single agent run. This is your working context. Every message, tool call, and result accumulates here. The challenge is context window management, since you can’t keep everything forever.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Long-term memory&lt;/strong&gt; is persistent state across runs. User preferences, past interactions, learned facts. This is your database. The challenge is retrieval: how does the agent know what’s relevant from thousands of past interactions?&lt;/p&gt;
&lt;p&gt;Most agents don’t need long-term memory at first. Start without it. Add it when users complain that the agent “forgets” important context.&lt;/p&gt;
&lt;p&gt;If you do need memory, vector databases (Pinecone, Weaviate, Qdrant) are the standard approach for semantic retrieval. But don’t underestimate simpler approaches. A SQLite database with structured metadata can go surprisingly far.&lt;/p&gt;
&lt;h3 id=&quot;context-management&quot; tabindex=&quot;-1&quot;&gt;Context Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#context-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Context is the single most important resource an agent has. Every decision the LLM makes is based on what’s in its context window. Feed it too little and it makes uninformed choices. Feed it too much and it drowns in noise, misses key details, or hits token limits mid-run. For a multi-step agent that accumulates tool calls and results over 10-15 steps, context bloat isn’t a theoretical risk, it’s the default outcome.&lt;/p&gt;
&lt;p&gt;This matters more for agents than for simple chat applications. In a chatbot, a bad context window means a slightly off response. In an agent, it means the wrong tool gets called, the wrong arguments get passed, and the entire trajectory goes sideways. The LLM’s ability to plan and reason degrades as context fills up with irrelevant information.&lt;/p&gt;
&lt;h4 id=&quot;sliding-window&quot; tabindex=&quot;-1&quot;&gt;Sliding window &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#sliding-window&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Keep only the last N messages or tokens. Simple and predictable, but you lose early context that might still be relevant. Works well for short-lived agents where early steps don’t inform later ones.&lt;/p&gt;
&lt;h4 id=&quot;summarization&quot; tabindex=&quot;-1&quot;&gt;Summarization &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#summarization&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Periodically compress older messages into a summary and replace them. The agent retains the gist without carrying the full weight. This is the most common pattern for long-running agents. The tradeoff is that summarization itself costs tokens and can lose nuance.&lt;/p&gt;
&lt;h4 id=&quot;selective-injection&quot; tabindex=&quot;-1&quot;&gt;Selective injection &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#selective-injection&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Don’t carry everything forward. Instead, store tool results and past reasoning externally, then use RAG to pull in only what’s relevant for the current step. This is the most scalable approach but adds retrieval latency and complexity.&lt;/p&gt;
&lt;h4 id=&quot;structured-context&quot; tabindex=&quot;-1&quot;&gt;Structured context &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#structured-context&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Instead of dumping raw tool outputs into the conversation, format them into concise structured summaries before adding them to context. A 500-line API response becomes a 10-line summary of the fields that matter. This is cheap to implement and often the highest-impact optimization.&lt;/p&gt;
&lt;p&gt;As your agent handles longer tasks or serves more users concurrently, context management becomes a scaling bottleneck. Each agent run holds its own context in memory. Longer contexts mean more tokens per API call, which means higher cost and latency. At scale, the practical strategies are: keep individual agent runs short and focused, break complex tasks into sub-agents with their own scoped context, and invest in good summarization so context stays lean. The agents that scale well aren’t the ones with the biggest context windows, they’re the ones that are smartest about what goes into the window in the first place.&lt;/p&gt;
&lt;h2 id=&quot;distribution&quot; tabindex=&quot;-1&quot;&gt;Distribution &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#distribution&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is where agents and traditional apps truly diverge.&lt;/p&gt;
&lt;p&gt;Apps distribute through well-understood channels: App Store, web, desktop. Agents have more options, and the right distribution model fundamentally shapes how you build.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;API-first agents&lt;/strong&gt;: Your agent is a service that other developers integrate. Think: a code review agent that plugs into GitHub via webhooks.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chat/UI agents&lt;/strong&gt;: Embedded in a conversational interface. The most common pattern today.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CLI agents&lt;/strong&gt;: For developer tools and power users. &lt;a href=&quot;https://docs.anthropic.com/en/docs/claude-code/overview&quot;&gt;Claude Code&lt;/a&gt; is a good example, a full agent that lives in the terminal.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Embedded agents&lt;/strong&gt;: Inside existing products, triggered by user actions. Not a standalone “AI feature” but intelligence woven into the product flow.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And then there’s composability. With protocols like &lt;a href=&quot;https://modelcontextprotocol.io/&quot;&gt;Model Context Protocol (MCP)&lt;/a&gt;, agents can discover and use tools dynamically. This shifts distribution from “ship a complete agent” to “ship capabilities that any agent can use.” I’ve been &lt;a href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/&quot;&gt;building skills as composable units&lt;/a&gt; for exactly this reason. The future isn’t monolithic agents, it’s an ecosystem of interoperable capabilities.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The best agent doesn’t win. The most &lt;strong&gt;accessible&lt;/strong&gt; agent does.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is true for apps and doubly true for agents. An agent that’s 80% as capable but available inside the tool your users already live in will beat a 100% capable agent that requires switching contexts.&lt;/p&gt;
&lt;h2 id=&quot;putting-it-all-together&quot; tabindex=&quot;-1&quot;&gt;Putting It All Together &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#putting-it-all-together&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s trace through a real example. Say you’re building an agent that helps developers understand unfamiliar codebases. Given a GitHub repo URL, it parses the structure, identifies key patterns, and produces a visual summary.&lt;/p&gt;
&lt;h3 id=&quot;design-phase&quot; tabindex=&quot;-1&quot;&gt;Design Phase &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#design-phase&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Goal&lt;/strong&gt;: Single repo → structured explanation with visual&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Control style&lt;/strong&gt;: Plan-then-execute (the steps are predictable)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tools&lt;/strong&gt;: repo cloner, file reader, code summarizer, diagram generator&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory&lt;/strong&gt;: None needed (each request is independent)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;implementation&quot; tabindex=&quot;-1&quot;&gt;Implementation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#implementation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;pre class=&quot;mermaid&quot;&gt;flowchart TD
    A[GitHub Repo URL] --&gt; B[Clone &amp; Parse Structure]
    B --&gt; C[Identify Key Files &amp; Patterns]
    C --&gt; D[LLM: Summarize Architecture]
    D --&gt; E[Generate Visual Diagram]
    E --&gt; F[Return Summary + Diagram]
&lt;/pre&gt;&lt;h3 id=&quot;testing&quot; tabindex=&quot;-1&quot;&gt;Testing &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#testing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tool tests&lt;/strong&gt;: Does the repo cloner handle private repos? Large repos? Monorepos?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Single-step evals&lt;/strong&gt;: Given a known repo, does the summarizer identify the right architectural patterns?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;End-to-end evals&lt;/strong&gt;: For 50 popular open-source repos, are the summaries accurate and the diagrams useful?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prompt injection&lt;/strong&gt;: What if the repo’s README contains instructions to the LLM?&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;where-people-mess-up&quot; tabindex=&quot;-1&quot;&gt;Where People Mess Up &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#where-people-mess-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No evals&lt;/strong&gt; → inconsistent outputs that they don’t notice until users complain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Too many tools&lt;/strong&gt; → the LLM gets confused about which to use, or invents parameters&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No constraints&lt;/strong&gt; → the agent tries to read every file in a 10,000-file monorepo&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No cost limits&lt;/strong&gt; → a single request triggers hundreds of LLM calls parsing files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Every one of these is preventable with the same engineering discipline we apply to regular apps.&lt;/p&gt;
&lt;h2 id=&quot;takeaways&quot; tabindex=&quot;-1&quot;&gt;Takeaways &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#takeaways&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you take one thing from this post, let it be this: &lt;strong&gt;agents are not a new paradigm. They’re a new runtime for the same engineering principles we’ve always used.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Design agents like systems, not like prompts&lt;/li&gt;
&lt;li&gt;Most agent failures are design failures, not model failures&lt;/li&gt;
&lt;li&gt;Testing and evals are the biggest missing piece. &lt;a href=&quot;https://blog.anirudha.dev/ai-evals/&quot;&gt;Invest in them early&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Start simple: 1 model, 2-3 tools, no memory. Expand with evidence.&lt;/li&gt;
&lt;li&gt;Observability isn’t optional. You need to know what your agent did and why.&lt;/li&gt;
&lt;li&gt;Distribution and accessibility will decide winners, not raw capability&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;We don’t need better prompts. We need better &lt;strong&gt;systems thinking&lt;/strong&gt; for agents.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;em&gt;The playbook already exists. We just need to open it.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;references-%26-further-reading&quot; tabindex=&quot;-1&quot;&gt;References &amp;amp; Further Reading &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-missing-playbook-for-ai-agents/#references-%26-further-reading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2210.03629&quot;&gt;ReAct: Synergizing Reasoning and Acting in Language Models&lt;/a&gt;, the foundational paper on the reason-then-act loop&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.anthropic.com/engineering/building-effective-agents&quot;&gt;Anthropic: Building Effective Agents&lt;/a&gt;, practical patterns from Anthropic’s research&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.anthropic.com/en/docs/build-with-claude/develop-tests&quot;&gt;Anthropic: Guide to Evaluations&lt;/a&gt;, how to test LLM-based systems properly&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://modelcontextprotocol.io/&quot;&gt;Model Context Protocol&lt;/a&gt;, open standard for connecting LLMs to tools and data&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://langchain-ai.github.io/langgraph/&quot;&gt;LangGraph Documentation&lt;/a&gt;, graph-based agent orchestration&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ragas.io/&quot;&gt;Ragas&lt;/a&gt;, evaluation framework for LLM applications&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://langfuse.com/&quot;&gt;Langfuse&lt;/a&gt;, open-source observability for LLM apps&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://lilianweng.github.io/posts/2023-06-23-agent/&quot;&gt;Lilian Weng: LLM Powered Autonomous Agents&lt;/a&gt;, one of the best technical overviews of agent architectures&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2409.02977&quot;&gt;The Landscape of Emerging AI Agent Architectures&lt;/a&gt;, survey of agent design patterns&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>Skills, Agents, and the Missing Middle</title>
		<link href="https://blog.anirudha.dev/skills-agents-and-sutras/"/>
		<updated>2026-01-09T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/skills-agents-and-sutras/</id>
		<content type="html">&lt;p&gt;If you’ve been building with LLMs for a while, you’ve probably built an agent at some point.&lt;/p&gt;
&lt;p&gt;You give the model a role. You add a few tools. You maybe throw in memory, some planning logic, and a carefully tuned system prompt. It works. Until it doesn’t. And when it doesn’t, it’s usually hard to explain why.&lt;/p&gt;
&lt;p&gt;At first, it’s tempting to blame the model. Or the prompt. Or the framework. But after building a few of these systems, a pattern starts to emerge: the problem isn’t reasoning, it’s structure.&lt;/p&gt;
&lt;h2 id=&quot;what-we-actually-mean-by-%E2%80%9Cskills%E2%80%9D&quot; tabindex=&quot;-1&quot;&gt;What We Actually Mean by “Skills” &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/#what-we-actually-mean-by-%E2%80%9Cskills%E2%80%9D&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When we talk about agent skills, we usually mean something very intuitive. A skill is something an agent can do. Search, summarize, classify, judge, decide, extract. These are the building blocks agents rely on to interact with the world.&lt;/p&gt;
&lt;p&gt;In practice, though, most skills today don’t really exist as things of their own. They’re embedded inside prompts, scattered across tool wrappers, or tightly coupled to a specific agent loop. They’re hard to see, harder to test in isolation, and almost impossible to reuse cleanly.&lt;/p&gt;
&lt;p&gt;We call them skills, but they behave more like side effects of prompt engineering.&lt;/p&gt;
&lt;p&gt;Agents get most of the attention, but agents are mostly coordination. They decide what to do next and which capability to invoke. The actual behavior. The thing that produces correct or incorrect outcomes, lives inside the skills themselves.&lt;/p&gt;
&lt;p&gt;If a skill is unreliable, the agent will be unreliable. If a skill improves, the entire system improves. Skills are the smallest unit of intelligence that actually moves the needle.&lt;/p&gt;
&lt;p&gt;That suggests something important. If we want better agent systems, we need to take skills seriously as first-class artifacts. We need to be able to define them clearly, run them independently, measure how they behave, improve them over time, and reuse them across agents.&lt;/p&gt;
&lt;p&gt;That’s still surprisingly rare.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills&quot;&gt;Read more: Equipping Agents for the Real World with Agent Skills&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One of the more promising directions here is the work around &lt;strong&gt;Agent Skills&lt;/strong&gt;, particularly the way Anthropic has framed them. Treating skills as explicit, discoverable units instead of implicit prompt logic is a big step forward. It gives us a shared vocabulary and a starting point for interoperability.&lt;/p&gt;
&lt;p&gt;But a specification alone isn’t enough. Knowing what a skill is doesn’t automatically tell you how to build one well, how to test it, or how to evolve it without breaking everything downstream.&lt;/p&gt;
&lt;p&gt;This is where most real-world systems start to struggle. Most issues with agent systems aren’t caused by missing tools or clever reasoning tricks. They come from unmanaged skill lifecycle.&lt;/p&gt;
&lt;p&gt;A skill gets tweaked. Something improves somewhere else. A regression sneaks in. No one knows which change caused it or why. Over time, skills accumulate complexity, but there’s no clear boundary where you can stop, inspect, and say: “This thing works, and here’s how we know.”&lt;/p&gt;
&lt;p&gt;Without that boundary, iteration becomes guesswork.&lt;/p&gt;
&lt;h2 id=&quot;introducing-sutras&quot; tabindex=&quot;-1&quot;&gt;Introducing Sutras &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/#introducing-sutras&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/anistark/sutras&quot;&gt;View Sutras on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is the gap &lt;strong&gt;Sutras&lt;/strong&gt; is trying to fill.&lt;/p&gt;
&lt;p&gt;Sutras help build skills which are a concise, structured, executable unit of capability. It has a clear interface. It can be run on its own. Its behavior can be measured. And it has a lifecycle that doesn’t depend on a specific agent or framework.&lt;/p&gt;
&lt;p&gt;Sutras builds on the emerging agent skill model, but shifts the focus to everything that happens around invocation: authoring, validation, evaluation, iteration, versioning, and distribution. The goal isn’t to replace agent frameworks or invent a new abstraction. It’s to give skills a proper car to drive to your agent home.&lt;/p&gt;
&lt;p&gt;Once skills become explicit artifacts, a few things get easier. Agents become simpler because they don’t need to carry so much hidden logic. Failures become easier to reason about because you can isolate behavior. Reuse stops being an afterthought.&lt;/p&gt;
&lt;p&gt;Agents decide what to do. Sutras define what can be done. More about how Sutras work and it’s capabilities in the next article. 🫶&lt;/p&gt;
&lt;p&gt;That separation doesn’t solve every problem, but it turns a messy prompt-driven system into something closer to software you can reason about.&lt;/p&gt;
&lt;h2 id=&quot;what%E2%80%99s-next&quot; tabindex=&quot;-1&quot;&gt;What’s Next &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/skills-agents-and-sutras/#what%E2%80%99s-next&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Skills are still early. The current focus is on getting the foundations right: aligning with emerging skill standards, keeping the model small, and making lifecycle discipline the default instead of an afterthought. Anthropic suggests to segregate skills in 3 main categories, but I guess we’ll see how it evolves.&lt;/p&gt;
&lt;p&gt;There’s a lot more to explore, from richer evaluation loops to better ways of sharing and composing skills. None of that should be designed in isolation.&lt;/p&gt;
&lt;p&gt;If you’ve ever felt that skills deserve more structure than they get today, you’re already thinking along the same lines. Sutras is an attempt to turn that instinct into something concrete, and it’s very much a work in progress.&lt;/p&gt;
&lt;p&gt;More to come, and if this resonates, the best way to shape it is together with the community. Let me what you think about it. Open an issue to request a feature or maybe just leave us a star. 🙌&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Building AI Tools You Can Trust</title>
		<link href="https://blog.anirudha.dev/building-ai-tools-you-can-trust/"/>
		<updated>2025-11-16T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/building-ai-tools-you-can-trust/</id>
		<content type="html">&lt;p&gt;You want to build an AI application. Something useful. Something your users can rely on.&lt;/p&gt;
&lt;p&gt;But here’s the problem: &lt;strong&gt;How do you know it’s actually good?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can build an app that generates summaries, answers questions, or writes emails. It works. Your tests pass. But is it &lt;em&gt;reliable&lt;/em&gt;? Does it hallucinate? Does it miss important information? Is it actually trustworthy?&lt;/p&gt;
&lt;p&gt;The philosophy is simple:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can’t improve what you don’t measure.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let me paint a realistic scenario:&lt;/p&gt;
&lt;p&gt;You’ve built a summarization app. Users love the interface. The summaries look great. But then:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A news outlet tries your app and finds the summary omits a crucial financial number&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A researcher uses it and discovers the summary makes a claim that’s not in the original paper&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A student uses it and the summary misrepresents the nuance of the source material&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sound familiar? This happens &lt;strong&gt;all the time&lt;/strong&gt; in full-stack AI apps because people build features without measuring quality.&lt;/p&gt;
&lt;p&gt;The difference between a hobby project and a professional tool is this: &lt;strong&gt;Professional tools measure themselves.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;our-journey%3A-building-a-trustworthy-summarization-tool&quot; tabindex=&quot;-1&quot;&gt;Our Journey: Building a Trustworthy Summarization Tool &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#our-journey%3A-building-a-trustworthy-summarization-tool&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s start 🚀&lt;/p&gt;
&lt;p&gt;If you want to follow along, here the &lt;a href=&quot;https://github.com/anistark/ai-summarisation&quot;&gt;repo&lt;/a&gt;. There’s also a notebook which has everything I’ll be covering in this article.&lt;/p&gt;
&lt;h3 id=&quot;run-in-google-colab&quot; tabindex=&quot;-1&quot;&gt;Run in Google Colab &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#run-in-google-colab&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;No installation. No setup. Just click and start:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://colab.research.google.com/github/anistark/ai-summarisation/blob/main/summarisation_demo.ipynb&quot;&gt;&lt;img src=&quot;https://colab.research.google.com/assets/colab-badge.svg&quot; alt=&quot;Open In Colab&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Quick start:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Click the button above&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the first cell (installs dependencies)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add your OpenAI API key to Colab Secrets (click 🔑 icon)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the remaining cells&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;See your evaluation scores&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Experiment with optimization strategies&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;%F0%9F%8F%A0-run-locally&quot; tabindex=&quot;-1&quot;&gt;🏠 Run Locally &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#%F0%9F%8F%A0-run-locally&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;git clone https://github.com/anistark/ai-summarisation.git
cd ai-summarisation
uv sync
jupyter notebook summarisation_demo.ipynb&lt;/terminal-block&gt;&lt;p&gt;Then follow the cells to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Generate summaries&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run evaluations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compare strategies&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Understand your metrics&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;step-1%3A-setting-up&quot; tabindex=&quot;-1&quot;&gt;Step 1: Setting Up &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#step-1%3A-setting-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;First, install the dependencies:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;pip install ragas&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;.9&lt;/span&gt; langchain&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;openai langchain&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;core python&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;dotenv&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;These packages give us:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ragas&lt;/strong&gt; - The evaluation framework&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;langchain-openai&lt;/strong&gt; - Access to GPT models&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;python-dotenv&lt;/strong&gt; - Manage API keys safely&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now let’s initialize everything:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; os&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; asyncio&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; typing &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Optional&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; dotenv &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; load_dotenv&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Load environment variables&lt;/span&gt;&lt;br /&gt;load_dotenv&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;api_key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;OPENAI_API_KEY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;llm_model &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;LLM_MODEL&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Initialize OpenAI client&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; openai &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; AsyncOpenAI&lt;br /&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;api_key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;api_key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Setup RAGAS for evaluation&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;llms &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; llm_factory&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;collections &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; SummaryScore&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Faithfulness&lt;br /&gt;&lt;br /&gt;llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;llm_model&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; client&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;✅ Setup complete!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;step-2%3A-load-an-article&quot; tabindex=&quot;-1&quot;&gt;Step 2: Load an Article &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#step-2%3A-load-an-article&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Let’s load some content to summarize:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;article &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;&lt;br /&gt;Apple announced on Tuesday that it will invest $1 billion in new AI research centers&lt;br /&gt;across the United States over the next five years. The company plans to hire 500 new&lt;br /&gt;researchers and engineers specifically for AI development. CEO Tim Cook stated that&lt;br /&gt;artificial intelligence is central to the company&#39;s future product strategy. The investment&lt;br /&gt;will focus on areas like natural language processing, computer vision, and machine learning&lt;br /&gt;efficiency. Apple will establish research hubs in San Francisco, Boston, and Seattle.&lt;br /&gt;The company already employs over 10,000 AI researchers globally.&lt;br /&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;📰 Article: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;split&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; words&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;step-3%3A-generate-a-summary&quot; tabindex=&quot;-1&quot;&gt;Step 3: Generate a Summary &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#step-3%3A-generate-a-summary&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Now let’s actually summarize it using an LLM:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; langchain_openai &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; ChatOpenAI&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; langchain_core&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prompts &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; PromptTemplate&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Initialize the summarizer&lt;/span&gt;&lt;br /&gt;summarizer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; temperature&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Create a prompt&lt;/span&gt;&lt;br /&gt;summarization_prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; PromptTemplate&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    input_variables&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    template&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Summarize the following text in 2-3 sentences.&lt;br /&gt;Focus on the main points and key details.&lt;br /&gt;&lt;br /&gt;Text:&lt;br /&gt;{text}&lt;br /&gt;&lt;br /&gt;Summary:&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Generate the summary&lt;/span&gt;&lt;br /&gt;chain &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; summarization_prompt &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; summarizer&lt;br /&gt;response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; chain&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;invoke&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; article&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;generated_summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;✍️ Generated Summary:&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generated_summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This gives us something like:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“Apple is investing $1 billion in AI research over five years, planning to hire 500 researchers across three US cities. The investment focuses on natural language processing, computer vision, and machine learning efficiency.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Looks good, right? But &lt;strong&gt;is it actually good?&lt;/strong&gt; That’s the question.&lt;/p&gt;
&lt;p&gt;This is where things get interesting.&lt;/p&gt;
&lt;p&gt;Instead of relying on intuition, we’re going to measure the summary using objective metrics.&lt;/p&gt;
&lt;h3 id=&quot;understanding-metric-%231%3A-summary-score&quot; tabindex=&quot;-1&quot;&gt;Understanding Metric #1: Summary Score &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#understanding-metric-%231%3A-summary-score&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;What it measures:&lt;/strong&gt; Does your summary capture the important information from the source?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;RAGAS extracts key phrases from the original article&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It generates questions about those key phrases&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It checks if your summary answers those questions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The score is the percentage of questions answered correctly&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; You could have a summary that sounds good but actually misses critical details. If the original article mentions “$1 billion” and your summary skips it, the Summary Score will reflect that loss.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What the scores mean:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.8-1.0&lt;/strong&gt; ✅ Excellent - You’ve captured essential information&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.6-0.8&lt;/strong&gt; ✅ Good - Main points are present&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.4-0.6&lt;/strong&gt; ⚠️ Fair - Missing important details&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;lt;0.4&lt;/strong&gt; ❌ Poor - Significant information loss&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;terminal-block&gt;Original: &amp;quot;Company investing $1B, hiring 500 people, 3 locations&amp;quot;
Bad Summary: &amp;quot;Company investing in AI&amp;quot;
Result: Summary Score drops because numbers are missing&lt;/terminal-block&gt;&lt;h3 id=&quot;understanding-metric-%232%3A-faithfulness&quot; tabindex=&quot;-1&quot;&gt;Understanding Metric #2: Faithfulness &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#understanding-metric-%232%3A-faithfulness&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;What it measures:&lt;/strong&gt; Is your summary making stuff up? Is it hallucinating?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;RAGAS breaks down the summary into individual claims&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For each claim, it checks: “Is this claim supported by the source?”&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It flags claims that don’t appear in the original text&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The score is the percentage of claims that are grounded in the source&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; A hallucinated fact is worse than a missing fact. If your summary invents information, you’re not just losing accuracy, you’re actively spreading misinformation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What the scores mean:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.9-1.0&lt;/strong&gt; ✅ Excellent - Fully grounded, no hallucinations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.7-0.9&lt;/strong&gt; ✅ Good - Mostly accurate&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;0.5-0.7&lt;/strong&gt; ⚠️ Fair - Some ungrounded claims&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&amp;lt;0.5&lt;/strong&gt; ❌ Poor - Contains hallucinations&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;terminal-block&gt;Original: &amp;quot;Apple invests in AI research&amp;quot;
Bad Summary: &amp;quot;Apple is developing self-driving cars and robots&amp;quot;
Result: Faithfulness drops because those claims aren&#39;t in the source&lt;/terminal-block&gt;&lt;h3 id=&quot;choosing-your-metrics%3A-not-all-use-cases-are-the-same&quot; tabindex=&quot;-1&quot;&gt;Choosing Your Metrics: Not All Use Cases Are the Same &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#choosing-your-metrics%3A-not-all-use-cases-are-the-same&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Different applications need different priorities:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th&gt;Summary Score&lt;/th&gt;
&lt;th&gt;Faithfulness&lt;/th&gt;
&lt;th&gt;Why?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;News articles&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;30% weight&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70% weight&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Accuracy is everything. Missing a detail is okay if what’s there is true.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Research papers&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70% weight&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;30% weight&lt;/td&gt;
&lt;td&gt;Completeness matters. You need the findings. Hallucination is bad but rarer in structured text.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Financial reports&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;40% weight&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;60% weight&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One false number can cost millions. Accuracy &amp;gt; completeness.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Learning materials&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;50% weight&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;50% weight&lt;/td&gt;
&lt;td&gt;Students need both complete AND accurate summaries.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Social media&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;80% weight&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;20% weight&lt;/td&gt;
&lt;td&gt;Engagement and quick takeaway. Perfection isn’t necessary.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The key: &lt;strong&gt;Decide your priorities before you build.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let’s actually measure our summary:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Initialize the evaluation metrics&lt;/span&gt;&lt;br /&gt;summary_score_metric &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; SummaryScore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;faithfulness_metric &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Faithfulness&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;evaluate_summary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Evaluate the summary I just created&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;🔍 Evaluating summary...&#92;n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;# Metric 1: Summary Score&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;⏳ Computing Summary Score...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        summary_result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_score_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            reference_contexts&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# The original article&lt;/span&gt;&lt;br /&gt;            response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;generated_summary      &lt;span class=&quot;token comment&quot;&gt;# Our summary&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        summary_score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary_result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;   ✅ Summary Score: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;summary_score&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;      Captures &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;summary_score&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.0f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;% of key information&#92;n&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;# Metric 2: Faithfulness&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;⏳ Computing Faithfulness...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        faithfulness_result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; faithfulness_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            user_input&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;generated_summary&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            retrieved_contexts&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        faithfulness &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;faithfulness_result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;   ✅ Faithfulness: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;faithfulness&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;      &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;faithfulness&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.0f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;% of claims are grounded in source&#92;n&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;summary_score&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; summary_score&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;faithfulness&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; faithfulness&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; Exception &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;❌ Error: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Run the evaluation&lt;/span&gt;&lt;br /&gt;results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Here’s what just happened:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You sent your summary to an LLM evaluator&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The evaluator analyzed it against the original article&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You got objective scores that tell you exactly how good your summary is&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You now have &lt;strong&gt;data&lt;/strong&gt; instead of vibes&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is the difference between guessing and knowing.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/bb430dbe-f047-43f7-aa5e-9eeb8e5e9502.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Here, we got a good score on faithfulness. However summary score says it’s got lots of room for improvement.&lt;/p&gt;
&lt;p&gt;The beauty of having metrics is that you can &lt;strong&gt;test different approaches&lt;/strong&gt; and see which works best:&lt;/p&gt;
&lt;h3 id=&quot;strategy-1%3A-longer-summaries&quot; tabindex=&quot;-1&quot;&gt;Strategy 1: Longer Summaries &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#strategy-1%3A-longer-summaries&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Maybe 2-3 sentences isn’t enough. Let’s try 5-7:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;longer_prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; PromptTemplate&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    input_variables&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    template&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Summarize the following text in 5-7 sentences.&lt;br /&gt;Capture all key points, numbers, and important details.&lt;br /&gt;&lt;br /&gt;Text:&lt;br /&gt;{text}&lt;br /&gt;&lt;br /&gt;Summary:&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;chain &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; longer_prompt &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; summarizer&lt;br /&gt;longer_summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; chain&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;invoke&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; article&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Trade-off:&lt;/strong&gt; Longer summaries usually score higher on Summary Score (more information), but you lose compression and some readers might not read it all.&lt;/p&gt;
&lt;h3 id=&quot;strategy-2%3A-structured-prompt&quot; tabindex=&quot;-1&quot;&gt;Strategy 2: Structured Prompt &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#strategy-2%3A-structured-prompt&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Guide the LLM to focus on specific aspects:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;structured_prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; PromptTemplate&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    input_variables&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    template&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Summarize focusing on:&lt;br /&gt;- WHAT (the action/announcement)&lt;br /&gt;- WHY (the reason/motivation)&lt;br /&gt;- WHERE (locations involved)&lt;br /&gt;- HOW MUCH (numbers and scale)&lt;br /&gt;- WHO (the organization)&lt;br /&gt;&lt;br /&gt;Text:&lt;br /&gt;{text}&lt;br /&gt;&lt;br /&gt;Summary:&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;chain &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; structured_prompt &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; summarizer&lt;br /&gt;structured_summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; chain&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;invoke&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; article&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; By explicitly asking for key details, the LLM is less likely to skip them.&lt;/p&gt;
&lt;h3 id=&quot;strategy-3%3A-bullet-points&quot; tabindex=&quot;-1&quot;&gt;Strategy 3: Bullet Points &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#strategy-3%3A-bullet-points&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Sometimes format matters:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;bullet_prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; PromptTemplate&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    input_variables&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    template&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Summarize as 4-5 bullet points.&lt;br /&gt;Each bullet should state ONE key fact.&lt;br /&gt;&lt;br /&gt;Text:&lt;br /&gt;{text}&lt;br /&gt;&lt;br /&gt;Summary:&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;chain &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; bullet_prompt &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; summarizer&lt;br /&gt;bullet_summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; chain&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;invoke&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; article&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Evaluate all three and see which one wins:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;compare_strategies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Compare different summarization approaches&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;    strategies &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&#39;longer&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; longer_summary&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&#39;structured&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; structured_summary&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&#39;bullets&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bullet_summary&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Testing different strategies...&#92;n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; summary &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; strategies&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;items&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Evaluating: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_score_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            reference_contexts&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;summary&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        faith &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; faithfulness_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            user_input&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            retrieved_contexts&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&#39;summary_score&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&#39;faithfulness&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;faith&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&#39;combined&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;faith&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;  Summary Score: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;summary_score&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;  Faithfulness: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;faithfulness&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;  Combined: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;combined&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#92;n&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Find the winner&lt;/span&gt;&lt;br /&gt;    best &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;items&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;lambda&lt;/span&gt; x&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; x&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;combined&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;🏆 Winner: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;best&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;upper&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;   Combined Score: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;best&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;combined&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; results&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Run it&lt;/span&gt;&lt;br /&gt;comparison_results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; compare_strategies&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This is &lt;strong&gt;empirical optimization&lt;/strong&gt;. You’re not guessing which approach is best, you’re measuring and letting data decide.&lt;/p&gt;
&lt;p&gt;Here’s what we’ve built so far:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/27330fa0-b0eb-4c70-ab9e-9a11d55e1bfc.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This workflow is powerful because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Objective feedback&lt;/strong&gt; - No subjective opinions, just scores&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Continuous improvement&lt;/strong&gt; - You can always test new approaches&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quality gates&lt;/strong&gt; - You can set minimum scores before publishing&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Learning loop&lt;/strong&gt; - Over time, you understand what works for your use case&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that you understand how evaluation works, here are practical guidelines for building production systems:&lt;/p&gt;
&lt;h3 id=&quot;%E2%9C%85-do%E2%80%99s&quot; tabindex=&quot;-1&quot;&gt;✅ DO’s &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#%E2%9C%85-do%E2%80%99s&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id=&quot;1.-do-set-minimum-score-thresholds&quot; tabindex=&quot;-1&quot;&gt;1. DO Set Minimum Score Thresholds &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#1.-do-set-minimum-score-thresholds&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Define what “good enough” means before you deploy:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;SUMMARY_SCORE_THRESHOLD &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.75&lt;/span&gt;&lt;br /&gt;FAITHFULNESS_THRESHOLD &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.90&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;is_summary_publishable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;summary_score&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; SUMMARY_SCORE_THRESHOLD &lt;span class=&quot;token keyword&quot;&gt;and&lt;/span&gt;&lt;br /&gt;            results&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;faithfulness&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; FAITHFULNESS_THRESHOLD&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; is_summary_publishable&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    publish_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    flag_for_manual_review&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Different use cases need different thresholds:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;News outlets: 0.85+ (accuracy critical)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Research papers: 0.80+ (completeness critical)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Social media: 0.60+ (engagement over perfection)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Learning platforms: 0.75+ (balance needed)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;2.-do-test-multiple-models&quot; tabindex=&quot;-1&quot;&gt;2. DO Test Multiple Models &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#2.-do-test-multiple-models&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Different models produce different quality:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;models &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gpt-4&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; model &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; models&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    summarizer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;model&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; generate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; summarizer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;model&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;score&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.3f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Pick the best performer&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;GPT-3.5 is cheap. GPT-4 is better. GPT-4o-mini is the sweet spot for many use cases. &lt;strong&gt;Let metrics decide.&lt;/strong&gt;&lt;/p&gt;
&lt;h4 id=&quot;3.-do-monitor-evaluation-costs&quot; tabindex=&quot;-1&quot;&gt;3. DO Monitor Evaluation Costs &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#3.-do-monitor-evaluation-costs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Evaluations cost money. Budget accordingly:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Track costs&lt;/span&gt;&lt;br /&gt;EVAL_COST_PER_SUMMARY &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.004&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Rough estimate&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Sample evaluation, don&#39;t evaluate everything&lt;/span&gt;&lt;br /&gt;sample_size &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;all_summaries&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Sample 100 or all&lt;/span&gt;&lt;br /&gt;eval_cost &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sample_size &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; EVAL_COST_PER_SUMMARY&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Evaluating &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;sample_size&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; summaries will cost: $&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;eval_cost&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.2f&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;For production: sample 10% of summaries. For critical content: evaluate 100%. For bulk operations: sample even less.&lt;/p&gt;
&lt;h4 id=&quot;4.-do-create-a-feedback-loop&quot; tabindex=&quot;-1&quot;&gt;4. DO Create a Feedback Loop &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#4.-do-create-a-feedback-loop&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Use metrics to continuously improve:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Log everything&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; json&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; datetime &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; datetime&lt;br /&gt;&lt;br /&gt;log_entry &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;timestamp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; datetime&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;now&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isoformat&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;article_length&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;split&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;model&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;summary_score&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.82&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;faithfulness&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.93&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;strategy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;structured_prompt&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;evaluation_log.jsonl&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; f&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    f&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;write&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dumps&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;log_entry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&#92;n&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Later: analyze patterns&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# - Which prompts work best?&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# - Do long articles score lower?&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# - Is there seasonality?&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;5.-do-test-with-real-data&quot; tabindex=&quot;-1&quot;&gt;5. DO Test With Real Data &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#5.-do-test-with-real-data&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Example articles are for learning. Test with your actual content:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Load your real articles&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; pathlib &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Path&lt;br /&gt;&lt;br /&gt;your_articles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; Path&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/path/to/articles&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;glob&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;*.txt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; f&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        your_articles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;f&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;read&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Evaluate on real data&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; article &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; your_articles&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    summary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; generate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;article&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Analyze real-world performance&lt;/span&gt;&lt;br /&gt;    avg_score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;r&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;summary_score&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; r &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;6.-do-document-your-decisions&quot; tabindex=&quot;-1&quot;&gt;6. DO Document Your Decisions &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#6.-do-document-your-decisions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Future you will thank present you:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;&lt;br /&gt;Summarization System Configuration&lt;br /&gt;===================================&lt;br /&gt;Created: 2025-01-15&lt;br /&gt;Purpose: Production summarization service&lt;br /&gt;&lt;br /&gt;Decisions:&lt;br /&gt;- Model: gpt-4o-mini (cost/quality balance)&lt;br /&gt;- Summary Length: 3-5 sentences&lt;br /&gt;- Minimum Thresholds:&lt;br /&gt;  * Summary Score: 0.75&lt;br /&gt;  * Faithfulness: 0.85&lt;br /&gt;- Rejection Strategy: Flag for manual review&lt;br /&gt;&lt;br /&gt;Trade-offs:&lt;br /&gt;- Not using GPT-4 to save costs&lt;br /&gt;- Accepting 78% info preservation for speed&lt;br /&gt;- Manual review for edge cases&lt;br /&gt;&lt;br /&gt;Review Date: 2025-02-15&lt;br /&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;7.-do-handle-errors-gracefully&quot; tabindex=&quot;-1&quot;&gt;7. DO Handle Errors Gracefully &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#7.-do-handle-errors-gracefully&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;APIs fail. Networks go down. Budget runs out:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; RateLimitError&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;warning&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Rate limited, retrying...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sleep&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; APIError &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;API error: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    flag_for_manual_review&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;%E2%9D%8C-don%E2%80%99ts&quot; tabindex=&quot;-1&quot;&gt;❌ DON’Ts &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#%E2%9D%8C-don%E2%80%99ts&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id=&quot;1.-don%E2%80%99t-trust-metrics-blindly&quot; tabindex=&quot;-1&quot;&gt;1. DON’T Trust Metrics Blindly &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#1.-don%E2%80%99t-trust-metrics-blindly&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Metrics are tools, not oracles. Always have humans review:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# BAD: Automate based purely on score&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; summary_score &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    publish_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌ Wrong!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD: Use metrics as a guide&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; summary_score &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    send_to_human_review&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Human has final say&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;2.-don%E2%80%99t-ignore-faithfulness-for-speed&quot; tabindex=&quot;-1&quot;&gt;2. DON’T Ignore Faithfulness for Speed &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#2.-don%E2%80%99t-ignore-faithfulness-for-speed&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Don’t optimize only for Summary Score at the expense of Faithfulness:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# BAD: Chasing higher Summary Score by any means&lt;/span&gt;&lt;br /&gt;prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Include EVERY DETAIL from the article&quot;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Result: Longer summaries, higher Summary Score, but hallucinations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD: Balance both&lt;/span&gt;&lt;br /&gt;prompt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Summarize accurately without adding new information&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Hallucinations destroy trust. One false claim tanks your credibility.&lt;/p&gt;
&lt;h4 id=&quot;3.-don%E2%80%99t-hardcode-api-keys&quot; tabindex=&quot;-1&quot;&gt;3. DON’T Hardcode API Keys &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#3.-don%E2%80%99t-hardcode-api-keys&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Never, ever, ever:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# TERRIBLE&lt;/span&gt;&lt;br /&gt;api_key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sk-proj-abc123xyz...&quot;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌❌❌&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD&lt;/span&gt;&lt;br /&gt;load_dotenv&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;api_key &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;OPENAI_API_KEY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Add &lt;code&gt;.env&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;. Make this a habit.&lt;/p&gt;
&lt;h4 id=&quot;4.-don%E2%80%99t-evaluate-everything&quot; tabindex=&quot;-1&quot;&gt;4. DON’T Evaluate Everything &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#4.-don%E2%80%99t-evaluate-everything&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Evaluations cost money. Be strategic:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# BAD: Evaluate all 10,000 summaries ($40+)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; summary &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; all_summaries&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌ Expensive&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD: Statistical sampling&lt;/span&gt;&lt;br /&gt;sample &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; random&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sample&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;all_summaries&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; k&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# 1% sample&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; summary &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; sample&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ✅ Cheap, representative&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;5.-don%E2%80%99t-use-metrics-as-your-only-quality-gate&quot; tabindex=&quot;-1&quot;&gt;5. DON’T Use Metrics As Your Only Quality Gate &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#5.-don%E2%80%99t-use-metrics-as-your-only-quality-gate&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Metrics are one dimension. Add more layers:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# BAD: Only checking metrics&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; summary_score &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    publish_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD: Multiple checks&lt;/span&gt;&lt;br /&gt;quality_checks &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;metrics&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;       &lt;span class=&quot;token comment&quot;&gt;# Objective&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;human_review&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; manual_review&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;# Subjective&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;guidelines&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; check_brand_guidelines&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Policy&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;safety&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; toxicity_check&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;           &lt;span class=&quot;token comment&quot;&gt;# Safety&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;passed &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; c &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; quality_checks&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;values&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    publish_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ✅&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;6.-don%E2%80%99t-use-the-same-model-for-summarization-and-evaluation&quot; tabindex=&quot;-1&quot;&gt;6. DON’T Use the Same Model for Summarization and Evaluation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#6.-don%E2%80%99t-use-the-same-model-for-summarization-and-evaluation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;It’s like asking a student to grade their own homework:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# AVOID: Self-grading bias&lt;/span&gt;&lt;br /&gt;summarizer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;evaluator &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Bias!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# BETTER: Different models&lt;/span&gt;&lt;br /&gt;summarizer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-3.5-turbo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Fast, cheap&lt;/span&gt;&lt;br /&gt;evaluator &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ChatOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;            &lt;span class=&quot;token comment&quot;&gt;# Rigorous&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h4 id=&quot;7.-don%E2%80%99t-assume-one-evaluation-equals-truth&quot; tabindex=&quot;-1&quot;&gt;7. DON’T Assume One Evaluation Equals Truth &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#7.-don%E2%80%99t-assume-one-evaluation-equals-truth&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;LLM evaluations have variance. Run multiple times for important decisions:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# BAD: Single evaluation&lt;/span&gt;&lt;br /&gt;score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; score &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    reject_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ❌ What if this was an anomaly?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# GOOD: Multiple runs&lt;/span&gt;&lt;br /&gt;scores &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; _ &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; summary_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    scores&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;avg_score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;scores&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;scores&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; avg_score &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    reject_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# ✅ More reliable&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;common-pitfalls-%26-how-to-avoid-them&quot; tabindex=&quot;-1&quot;&gt;Common Pitfalls &amp;amp; How to Avoid Them &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#common-pitfalls-%26-how-to-avoid-them&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;pitfall-%231%3A-the-score-plateau&quot; tabindex=&quot;-1&quot;&gt;Pitfall #1: The Score Plateau &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#pitfall-%231%3A-the-score-plateau&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Your Summary Score hits 0.75 and won’t improve.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; You’ve hit the architectural limits of your approach.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Try a completely different prompt (not tweaks, but fundamentally different)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch to a more capable model (GPT-4 instead of 3.5)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Increase summary length (allows more information)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;pitfall-%232%3A-the-faithfulness-trap&quot; tabindex=&quot;-1&quot;&gt;Pitfall #2: The Faithfulness Trap &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#pitfall-%232%3A-the-faithfulness-trap&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Faithfulness is 0.95 but users say summaries are useless.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; You’re being so cautious you lose nuance. Or metrics don’t match user expectations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Add human feedback alongside metrics&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Verify that metrics actually align with user satisfaction&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Faithfulness ≠ usefulness&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;pitfall-%233%3A-runaway-costs&quot; tabindex=&quot;-1&quot;&gt;Pitfall #3: Runaway Costs &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#pitfall-%233%3A-runaway-costs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Your evaluation budget exploded unexpectedly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Evaluated too much, used expensive models, pricing changed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;BUDGET &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# $100/month&lt;/span&gt;&lt;br /&gt;COST_PER_EVAL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.004&lt;/span&gt;&lt;br /&gt;MAX_EVALS &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;BUDGET &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; COST_PER_EVAL&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# 25,000&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;eval_count &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; summary &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; summaries&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; eval_count &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; MAX_EVALS&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;warning&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Budget limit reached&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;br /&gt;    evaluate_summary&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;summary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    eval_count &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;pitfall-%234%3A-model-drift&quot; tabindex=&quot;-1&quot;&gt;Pitfall #4: Model Drift &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#pitfall-%234%3A-model-drift&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Your system worked for 3 months, then scores dropped mysteriously.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; OpenAI updated their model, or your data changed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Set a baseline&lt;/span&gt;&lt;br /&gt;baseline &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;date&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2025-01-15&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;model&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;avg_score&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.78&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Monthly check-in&lt;/span&gt;&lt;br /&gt;current &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; evaluate_sample&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; current&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;avg_score&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; baseline&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;avg_score&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.95&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    alert&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Score degradation detected!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;learn-more&quot; tabindex=&quot;-1&quot;&gt;Learn More &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-ai-tools-you-can-trust/#learn-more&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Want to dive deeper?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.ragas.io/&quot;&gt;&lt;strong&gt;RAGAS Documentation&lt;/strong&gt;&lt;/a&gt; - Official docs with all metrics explained&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/summarization_score&quot;&gt;&lt;strong&gt;Summary Score Details&lt;/strong&gt;&lt;/a&gt; - How Summary Score works under the hood&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.ragas.io/en/stable/concepts/metrics/available_metrics/faithfulness&quot;&gt;&lt;strong&gt;Faithfulness Metric&lt;/strong&gt;&lt;/a&gt; - Deep dive into hallucination detection&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://python.langchain.com/&quot;&gt;&lt;strong&gt;LangChain Documentation&lt;/strong&gt;&lt;/a&gt; - Building LLM applications&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://platform.openai.com/docs/guides/prompt-engineering&quot;&gt;&lt;strong&gt;Prompt Engineering Best Practices&lt;/strong&gt;&lt;/a&gt; - OpenAI’s guide to writing better prompts&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also use more latest gpt-5 series of course or other providers like claude, gemini, etc.&lt;/p&gt;
&lt;p&gt;Building AI applications is easy. Building &lt;strong&gt;trustworthy&lt;/strong&gt; AI applications is harder, but not impossibly so.&lt;/p&gt;
&lt;p&gt;The difference is measurement. Metrics. Data.&lt;/p&gt;
&lt;p&gt;Every time someone asks you, “How do you know your AI summaries are accurate?” you can now answer confidently:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Because I measure it. Every single time. With objective metrics. And I continuously optimize based on those measurements.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That’s what separates hobby projects from professional tools.&lt;/p&gt;
&lt;p&gt;You now have everything you need to build AI you can trust.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Questions? Found a bug? Have ideas?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/anistark/ai-summarisation/issues&quot;&gt;Open an issue on GitHub&lt;/a&gt; and let’s build better AI together.&lt;/p&gt;
&lt;p&gt;Happy building! 🚀&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Teaching AI to Grade Other AI</title>
		<link href="https://blog.anirudha.dev/llm-as-judge/"/>
		<updated>2025-11-09T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/llm-as-judge/</id>
		<content type="html">&lt;p&gt;If you’ve been following the world of AI development, you might’ve heard the phrase &lt;strong&gt;“LLM-as-Judge.”&lt;/strong&gt;&lt;br /&gt;
It sounds dramatic, like some sci-fi overlord where one AI passes judgment on another. But it’s actually one of the most important evolutions in evaluating large language models (LLMs).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;LLM-as-Judge&lt;/strong&gt; means using a &lt;strong&gt;language model itself to evaluate&lt;/strong&gt; the quality of another model’s responses.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Traditionally, human annotators graded model outputs. Checking if an answer was factual, polite, relevant, or well-reasoned. But as models got more capable and outputs more nuanced, this manual process became slow, expensive, and inconsistent.&lt;/p&gt;
&lt;p&gt;So, researchers began asking, &lt;em&gt;Can we train (or prompt) a model to act like a human evaluator?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Turns out, yes, quite effectively.&lt;/p&gt;
&lt;p&gt;The idea is simple:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/c3e4e7fe-d2c5-466a-8e2b-f8e06345d1f6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It’s like using one AI to peer-review another. Evaluation is the backbone of AI progress. Without it, we wouldn’t know if newer models are actually &lt;em&gt;better&lt;/em&gt;, or just different. Human evaluation doesn’t scale. Imagine evaluating thousands of answers for correctness, reasoning, and tone across 10+ benchmarks.&lt;br /&gt;
That’s days of work for humans, but minutes for an LLM.&lt;/p&gt;
&lt;p&gt;You now suddenly have the super power to run thousands of comparisons in minutes. Reduce human bias, enable rapid iteration and explore subjective criteria like “creativity” or “helpfulness” where metrics alone fall short.&lt;/p&gt;
&lt;p&gt;LLM-based judging has already become a norm in multiple domains:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Model benchmarking&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Frameworks like &lt;a href=&quot;https://lmsys.org/blog/2024-04-19-arena-hard/&quot;&gt;Arena Hard&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/2306.05685&quot;&gt;MT-Bench&lt;/a&gt; use GPT-4 as the judge to rank models.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Eval pipelines&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tools like &lt;a href=&quot;https://github.com/explodinggradients/ragas&quot;&gt;Ragas&lt;/a&gt; and &lt;a href=&quot;https://www.trulens.org/&quot;&gt;TruLens&lt;/a&gt; integrate LLM-judging to score faithfulness, coherence, and relevance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fine-tuning and alignment&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Reinforcement Learning from AI Feedback (RLAIF) replaces human feedback with LLM judgments to train new models.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Automated grading systems&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Education and coding platforms use LLMs to grade free-text answers or code explanations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;LLM-as-Judge solves for critical limitations with traditional evaluation metrics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Captures nuance&lt;/strong&gt;: Evaluates semantic quality, not just string overlap&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scales human judgment&lt;/strong&gt;: Automates what would otherwise require manual review&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Flexible criteria&lt;/strong&gt;: Define any custom evaluation criteria&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Domain-aware&lt;/strong&gt;: Adapts to specific use cases (medical, legal, finance, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interpretable&lt;/strong&gt;: Provides reasoning for verdicts, not just scores&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Without scalable evaluation, progress slows down. Model quality becomes subjective. Everyone claims their model is “better,” but without consistent evals, it’s marketing, not science. Human fatigue and cost make it impossible to iterate fast. Bias creeps in. Different annotators interpret “good” differently. An LLM judge can apply consistent criteria across thousands of examples.&lt;/p&gt;
&lt;p&gt;In short, without a judge, the AI ecosystem risks &lt;strong&gt;flying blind.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Think of the evaluation as a &lt;strong&gt;comparison pipeline:&lt;/strong&gt;&lt;/p&gt;
&lt;terminal-block&gt;Question: &amp;quot;Explain quantum computing to a 5-year-old.&amp;quot;

Model A → &amp;quot;It’s like magic computers that can do many things at once.&amp;quot;
Model B → &amp;quot;It’s a special computer that can try all possibilities at once.&amp;quot;

Judge LLM → &amp;quot;Model B’s answer is clearer and more accurate for a child audience.&amp;quot;
Score: Model B wins&lt;/terminal-block&gt;&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/5d8b9564-feff-4363-a5c2-6442ed3e0833.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Before your LLM judge can reliably evaluate your system, it must first &lt;strong&gt;align with your ground truth&lt;/strong&gt; (human expert judgments). A misaligned judge is like a compass pointing the wrong way—every improvement based on its guidance moves you further from your goal. Ragas provides a powerful, production-ready framework for implementing LLM-as-Judge evaluation.&lt;/p&gt;
&lt;p&gt;Let’s talk about the alignment process. First, you start by creating a baseline judge using a straightforward prompt. Then, you evaluate it against human-labeled ground truth to see how it measures up. Next, you look for patterns where the judge disagrees with the human experts. Based on these patterns, you tweak and improve the judge’s prompt. After that, you re-evaluate to see if there’s any improvement. You keep repeating this process until the alignment either levels off or reaches the standard you’re aiming for.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;strictness&lt;/code&gt; parameter controls consistency by running multiple evaluations with majority voting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Value&lt;/strong&gt;: Number of independent LLM evaluations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mechanism&lt;/strong&gt;: Majority voting combines results&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Auto-adjustment&lt;/strong&gt;: Automatically converts to odd numbers (1, 3, 5, 7…)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Use 2-4 for production, balancing cost and consistency.&lt;/p&gt;
&lt;p&gt;Think of DiscreteMetric as the Swiss Army knife of LLM-based evaluation. Need to evaluate responses as “excellent,” “good,” “mediocre,” or “poor”? DiscreteMetric handles it. Want to categorize code reviews as “passes linting,” “needs minor fixes,” or “major refactoring required”? You’ve got it. The key insight is that DiscreteMetric lets you define both the evaluation prompt AND the allowed output values, making it incredibly flexible for nuanced evaluations that don’t fit neatly into binary or numeric scoring.&lt;/p&gt;
&lt;p&gt;What makes DiscreteMetric particularly powerful is that you don’t need to subclass anything or write complex metric implementations. You just provide a prompt template (with variables you define), specify what categorical values the LLM can return, and you’re done. The LLM does the actual evaluation work using your custom prompt, and returns one of your predefined categories. This is perfect for domain-specific evaluation criteria where you need more granularity than binary but want to avoid the complexity of numeric scores.&lt;/p&gt;
&lt;p&gt;For example, if you’re evaluating financial advice, you might want categories like “financially sound,” “incomplete,” “contains risk,” or “dangerous advice” — each with different implications for your system. Or for content moderation, you might use “safe,” “borderline,” “needs review,” and “block.” DiscreteMetric adapts to whatever categorical scheme your business needs.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; asyncio&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; openai &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; AsyncOpenAI&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;llms &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; llm_factory&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; DiscreteMetric&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; os&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Setup&lt;/span&gt;&lt;br /&gt;    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;api_key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;OPENAI_API_KEY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; client&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Define metric&lt;/span&gt;&lt;br /&gt;    accuracy_metric &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; DiscreteMetric&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;accuracy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        prompt&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&quot;Check &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; the response contains points &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; the grading&lt;br /&gt;notes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&#92;n&#92;nResponse&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&#92;nGrading Notes&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;grading_notes&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&quot;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        allowed_values&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Evaluate&lt;/span&gt;&lt;br /&gt;    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; accuracy_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&quot;The model discussion covers DCF&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; comparable analysis&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;and&lt;/span&gt; VC&lt;br /&gt;methods&quot;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        grading_notes&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&quot;Must cover&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; DCF method&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; comparable analysis&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; VC method&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;founder impact&quot;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Verdict: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# &quot;pass&quot; or &quot;fail&quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Reason: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;reason&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Run&lt;/span&gt;&lt;br /&gt;asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;main&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now that we understand &lt;code&gt;DiscreteMetric&lt;/code&gt;, let’s build a complete judge evaluation pipeline from scratch.&lt;/p&gt;
&lt;h3 id=&quot;define-your-evaluation-criteria&quot; tabindex=&quot;-1&quot;&gt;Define Your Evaluation Criteria &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#define-your-evaluation-criteria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Start by clearly defining what “good” means for your use case.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Example: Evaluating financial advice quality&lt;/span&gt;&lt;br /&gt;judge_definition &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;&lt;br /&gt;Evaluate if the response provides sound financial advice that covers:&lt;br /&gt;1. Clear explanation of key concepts&lt;br /&gt;2. Relevant metrics and calculations&lt;br /&gt;3. Risk considerations&lt;br /&gt;4. Tax implications where applicable&lt;br /&gt;5. Practical actionable steps&lt;br /&gt;&lt;br /&gt;Return &#39;pass&#39; if all major points are covered, &#39;fail&#39; if critical topics are missing.&lt;br /&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;create-a-baseline-judge&quot; tabindex=&quot;-1&quot;&gt;Create a Baseline Judge &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#create-a-baseline-judge&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Start with a simple baseline judge helps you understand the problem.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; DiscreteMetric&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; openai &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; AsyncOpenAI&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;llms &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; llm_factory&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Initialize LLM&lt;/span&gt;&lt;br /&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;api_key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;sk-...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; client&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Create baseline judge&lt;/span&gt;&lt;br /&gt;baseline_judge &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; DiscreteMetric&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;financial_advice_quality&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    prompt&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Does the response provide sound financial advice? Check for key concepts, calculations, risks, and actionable steps.&#92;n&#92;nResponse: {response}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    allowed_values&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;prepare-ground-truth-data&quot; tabindex=&quot;-1&quot;&gt;Prepare Ground Truth Data &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#prepare-ground-truth-data&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You need human-labeled examples to measure alignment.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; pandas &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; pd&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Dataset&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Load your annotated data&lt;/span&gt;&lt;br /&gt;df &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; pd&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;read_csv&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;expert_labels.csv&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Expected columns: question, response, expert_judgment&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;dataset &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Dataset&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;judge_alignment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; backend&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;local/csv&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; _&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; row &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; df&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;iterrows&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    dataset&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;append&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;question&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;question&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;target&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;expert_judgment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;create-alignment-metric&quot; tabindex=&quot;-1&quot;&gt;Create Alignment Metric &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#create-alignment-metric&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Define how you measure judge alignment.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;discrete &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; discrete_metric&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metrics&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;result &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; MetricResult&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;@discrete_metric&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;judge_alignment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; allowed_values&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;judge_alignment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;judge_label&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; human_label&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; MetricResult&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Compare judge decision with human label.&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;    judge &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; judge_label&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lower&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    human &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; human_label&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lower&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; judge &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; human&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MetricResult&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            value&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            reason&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Judge=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;judge&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;; Human=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;human&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MetricResult&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        value&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        reason&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Judge=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;judge&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;; Human=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;human&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;define-experiment-function&quot; tabindex=&quot;-1&quot;&gt;Define Experiment Function &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#define-experiment-function&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Orchestrate the evaluation pipeline.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; ragas &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; experiment&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; typing &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; Dict&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Any&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;@experiment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;judge_experiment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    row&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dict&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Any&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    judge_metric&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; DiscreteMetric&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    llm&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Run complete evaluation: Judge → Compare with human.&quot;&quot;&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    judge_score &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; judge_metric&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ascore&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        question&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;question&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        response&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;response&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    alignment &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; judge_alignment&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;score&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        judge_label&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;judge_score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        human_label&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;target&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;judge_label&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; judge_score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;judge_reason&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; judge_score&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;reason&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;alignment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; alignment&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;run-baseline-evaluation&quot; tabindex=&quot;-1&quot;&gt;Run Baseline Evaluation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#run-baseline-evaluation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Execute the evaluation pipeline.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; asyncio&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; os&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_baseline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Load dataset&lt;/span&gt;&lt;br /&gt;    dataset &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; load_dataset&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Loaded &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dataset&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; samples&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Initialize LLM&lt;/span&gt;&lt;br /&gt;    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;api_key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;OPENAI_API_KEY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; client&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Run experiment&lt;/span&gt;&lt;br /&gt;    results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; judge_experiment&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;arun&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        dataset&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;judge_baseline_v1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        judge_metric&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;baseline_judge&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Calculate alignment&lt;/span&gt;&lt;br /&gt;    passed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; r &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; results &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; r&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;alignment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    total &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Alignment: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;passed&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;total&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;passed&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;total&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.1%&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;)&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; results&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Execute&lt;/span&gt;&lt;br /&gt;results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;run_baseline&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;analyze-errors&quot; tabindex=&quot;-1&quot;&gt;Analyze Errors &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#analyze-errors&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Identify patterns in judge errors.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; pandas &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; pd&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Load results&lt;/span&gt;&lt;br /&gt;df &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; pd&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;read_csv&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;judge_baseline_v1.csv&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Analyze misalignments&lt;/span&gt;&lt;br /&gt;false_positives &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;judge_label&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;pass&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;target&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;fail&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;false_negatives &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;judge_label&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;fail&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;target&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;pass&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;False positives (too lenient): &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;false_positives&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;False negatives (too strict): &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;false_negatives&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Look at specific error examples&lt;/span&gt;&lt;br /&gt;errors &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;df&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;alignment&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;fail&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; idx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; row &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; errors&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;head&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;iterrows&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;&#92;nQuestion: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;question&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Judge: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;judge_label&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, Human: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;target&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Reason: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;row&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;judge_reason&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;improve-judge-prompt&quot; tabindex=&quot;-1&quot;&gt;Improve Judge Prompt &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#improve-judge-prompt&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Based on error patterns, create an improved judge.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Improved prompt addressing identified issues&lt;/span&gt;&lt;br /&gt;improved_judge &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; DiscreteMetric&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;financial_advice_quality_v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    prompt&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token triple-quoted-string string&quot;&gt;&quot;&quot;&quot;Evaluate if the response provides comprehensive financial advice.&lt;br /&gt;&lt;br /&gt;CRITERIA:&lt;br /&gt;1. ✓ Must clearly explain key financial concepts&lt;br /&gt;2. ✓ Must include relevant calculations or metrics&lt;br /&gt;3. ✓ Must discuss risks and tax implications&lt;br /&gt;4. ✓ Must provide actionable next steps&lt;br /&gt;5. ✓ Must avoid generic advice without specifics&lt;br /&gt;&lt;br /&gt;IMPORTANT:&lt;br /&gt;- Require ALL 5 criteria to be present&lt;br /&gt;- Do NOT accept vague or general statements&lt;br /&gt;- Accept paraphrased concepts (different wording is OK)&lt;br /&gt;- If even one criterion is missing or vague, return &#39;fail&#39;&lt;br /&gt;&lt;br /&gt;Response: {response}&lt;br /&gt;&lt;br /&gt;Are all 5 criteria clearly met in the response? Answer &#39;pass&#39; or &#39;fail&#39;.&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    allowed_values&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fail&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;re-run-with-improved-judge&quot; tabindex=&quot;-1&quot;&gt;Re-run with Improved Judge &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#re-run-with-improved-judge&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Execute with the improved version.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_improved&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    dataset &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; load_dataset&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;api_key&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;os&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;environ&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;OPENAI_API_KEY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    llm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; llm_factory&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4o-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; client&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;# Use improved judge&lt;/span&gt;&lt;br /&gt;    results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; judge_experiment&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;arun&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        dataset&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;judge_improved_v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        judge_metric&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;improved_judge&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        llm&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;llm&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    passed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; r &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; results &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; r&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;alignment&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    total &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;results&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string-interpolation&quot;&gt;&lt;span class=&quot;token string&quot;&gt;f&quot;Improved alignment: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;passed&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;total&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;passed&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;total&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token format-spec&quot;&gt;.1%&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;)&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; results&lt;br /&gt;&lt;br /&gt;results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;run_improved&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;It’s of course not a simple single step process. You gotta at least do it a few times. Keep iterating till you find that sweet spot.&lt;/p&gt;
&lt;p&gt;You can also run multiple judges and combine results, evaluate the entire conversation flow or create your metric implementation. I’ll leave that to you to figure out. A super tip that helped me learn faster was to include examples in prompts to improve judge accuracy. Make it as verbose as you can. Avoid jargons or explain any jargons that you’re using. For example, LLM might not know what &lt;em&gt;ARR&lt;/em&gt; means.&lt;/p&gt;
&lt;h2 id=&quot;best-practices&quot; tabindex=&quot;-1&quot;&gt;Best Practices &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#best-practices&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Start with Domain Experts - Ground truth quality is critical&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Document Evaluation Criteria - Clear criteria prevents ambiguity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Measure Inter-Rater Reliability - Use multiple annotators to validate ground truth&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Analyze Judge Performance by Category - Break down alignment by different data types&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Version Control Judge Prompts - Track prompt changes for reproducibility&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you’ve more good practices to follow, add below in comments. Would love to learn more.&lt;/p&gt;
&lt;p&gt;But Wait, Can We Trust the Judge?&lt;br /&gt;
LLM judges are &lt;strong&gt;not perfect&lt;/strong&gt;. They inherit biases from their own training. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A GPT-4 judge might favor GPT-style phrasing over open-source models.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Judges can be “prompt-sensitive”. Small wording changes may affect verdicts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;They might hallucinate reasoning for why one answer is better.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hence, follow the best practices and keep iterating to improve your judge.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.prod.website-files.com/660ef16a9e0687d9cc27474a/66db3980c17b8cda52071c1d_00_llm_judge_tutorial-min.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The next wave of evaluation focuses on &lt;strong&gt;meta-judging&lt;/strong&gt;, evaluating the evaluators themselves.&lt;/p&gt;
&lt;p&gt;Some emerging ideas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi-LLM consensus&lt;/strong&gt;: Multiple judges vote or debate before giving a verdict.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Grounded evals&lt;/strong&gt;: Judges verify outputs against real data or APIs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Human-AI hybrid evaluation&lt;/strong&gt;: Humans handle edge cases; LLMs handle scale.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As open-source models get stronger, expect to see &lt;strong&gt;judge models fine-tuned for fairness and domain expertise&lt;/strong&gt;, like “MedJudge” for medical LLMs or “CodeJudge” for programming tasks.&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%93%9A-references-%26-further-reading&quot; tabindex=&quot;-1&quot;&gt;📚 References &amp;amp; Further Reading &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/llm-as-judge/#%F0%9F%93%9A-references-%26-further-reading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/2306.05685&quot;&gt;MT-Bench: Multi-turn Benchmark for LLMs&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.ragas.io/en/stable/howtos/applications/align-llm-as-judge/&quot;&gt;&lt;strong&gt;Judge Alignment Guide&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://lmsys.org/blog/2024-04-19-arena-hard/&quot;&gt;Arena Hard Benchmark&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/explodinggradients/ragas&quot;&gt;Ragas- Evaluation Framework for RAG Pipelines&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.trulens.org/&quot;&gt;TruLens- Evaluating LLM Apps&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/2309.00267&quot;&gt;Anthropic: RLAIF Paper&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The LLM-as-Judge approach is not about replacing humans. It’s about &lt;strong&gt;accelerating truth-finding.&lt;/strong&gt;&lt;br /&gt;
As models grow in complexity, human evaluation alone can’t keep up. Using LLMs as judges gives us a powerful mirror, one that helps us see how far we’ve come, and how much further we can go.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“To build better intelligence, we need better ways to measure it.”&lt;br /&gt;
— That’s exactly what LLM-as-Judge brings to the table.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here’s a simple diagram showing how &lt;strong&gt;LLM-as-Judge&lt;/strong&gt; fits into the AI evaluation loop:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/e8d06811-fa5f-47f0-9806-4ddbb72cc138.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;A user or testbench sends an &lt;strong&gt;input or question&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;One or more &lt;strong&gt;models&lt;/strong&gt; generate responses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A &lt;strong&gt;judge LLM&lt;/strong&gt; compares or evaluates these responses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;verdict or score&lt;/strong&gt; is recorded for metrics or training.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Feedback loops back to improve the model, thus closing the evaluation cycle.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;The key to success is treating judge alignment as a first-class problem: invest time in understanding your data, clarifying evaluation criteria with domain experts, and systematically improving your judge prompts based on actual error patterns.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With an aligned judge as your foundation, you can confidently scale evaluation of RAG systems, agents, and any LLM application, knowing that improvements in metrics translate to real improvements in quality.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Unit Tests for Intelligence</title>
		<link href="https://blog.anirudha.dev/ai-evals/"/>
		<updated>2025-10-26T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/ai-evals/</id>
		<content type="html">&lt;p&gt;A few months ago, as I was exploring machine learning while working on a project, one of my models kept behaving in a weird way. I had built a classifier to detect cats in images. During training, accuracy was awesome, near 99%. But in production, it failed miserably. The reason? Some of my “cat” photos had the same watermark on the corner. The model wasn’t learning cats, it was learning the watermark.&lt;/p&gt;
&lt;p&gt;It hit me then: We had &lt;strong&gt;no proper way to test &lt;em&gt;what&lt;/em&gt; the model had learned&lt;/strong&gt;. We were measuring &lt;em&gt;accuracy&lt;/em&gt;, but not &lt;em&gt;intelligence&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;And that’s where the concept of &lt;strong&gt;AI Evals&lt;/strong&gt; comes in, the &lt;strong&gt;unit tests for intelligence&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;what-are-%E2%80%9Cevals%E2%80%9D%3F&quot; tabindex=&quot;-1&quot;&gt;What Are “Evals”? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#what-are-%E2%80%9Cevals%E2%80%9D%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Evals (short for &lt;em&gt;evaluations&lt;/em&gt;) are structured tests designed to measure how well an AI model performs on specific kinds of reasoning, understanding, or behavior.&lt;/p&gt;
&lt;p&gt;Just like unit tests verify your functions do what you expect, &lt;strong&gt;evals verify your model thinks how you expect&lt;/strong&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;th&gt;Traditional Software&lt;/th&gt;
&lt;th&gt;AI Systems&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Input&lt;/td&gt;
&lt;td&gt;Function arguments&lt;/td&gt;
&lt;td&gt;Prompt / Input text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logic&lt;/td&gt;
&lt;td&gt;Deterministic code&lt;/td&gt;
&lt;td&gt;Model reasoning (latent)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;Return value&lt;/td&gt;
&lt;td&gt;Generated response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test&lt;/td&gt;
&lt;td&gt;Assert conditions&lt;/td&gt;
&lt;td&gt;Evaluate metrics / compare ideal outputs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;You wouldn’t ship code without tests. So why ship a model without evals?&lt;/p&gt;
&lt;h3 id=&quot;why-evals-matter&quot; tabindex=&quot;-1&quot;&gt;Why Evals Matter &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#why-evals-matter&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;AI models, especially large language models (LLMs), aren’t deterministic. You can’t just run them once and say “it works.” They need to be &lt;strong&gt;probed&lt;/strong&gt;, &lt;strong&gt;benchmarked&lt;/strong&gt;, and &lt;strong&gt;stress-tested&lt;/strong&gt; like any intelligent system.&lt;/p&gt;
&lt;p&gt;Evals help you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Detect regressions between model versions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Understand reasoning strengths and blind spots&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Quantify subjective traits (helpfulness, creativity, bias, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Track improvements as you fine-tune or change prompts&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;They’re not just about performance. They’re about &lt;em&gt;understanding intelligence behaviorally&lt;/em&gt;.&lt;/p&gt;
&lt;h3 id=&quot;visualizing-the-flow&quot; tabindex=&quot;-1&quot;&gt;Visualizing the Flow &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#visualizing-the-flow&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Let’s picture an eval as a mini experiment:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/009f4b9f-3997-4405-b55b-7267dc5e73d3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; what you feed the model (prompt, image, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reasoning:&lt;/strong&gt; the model’s internal “thought” (hidden weights, attention)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Output Check:&lt;/strong&gt; compare the output to an expected or reference result&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can think of it like &lt;code&gt;assert output == expected&lt;/code&gt;, but smarter. Because “expected” might not be a single string, it could be a semantic similarity, a rubric score, or a human judgment.&lt;/p&gt;
&lt;h3 id=&quot;a-tiny-example%3A-logic-eval&quot; tabindex=&quot;-1&quot;&gt;A Tiny Example: Logic Eval &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#a-tiny-example%3A-logic-eval&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Let’s take a toy case.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; openai &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; OpenAI&lt;br /&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; OpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;logic_eval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;question&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; expected_answer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;        model&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gpt-4.1-mini&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;question&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    answer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;output_text&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;strip&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    passed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;answer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lower&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; expected_answer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lower&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;question&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; question&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;model_answer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; answer&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;passed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; passed&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;tests &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;If all cats are animals and some animals are not cats, are all animals cats?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;No&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;If A implies B and A is true, what about B?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;True&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; t &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; tests&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;logic_eval&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;t&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;terminal-block&gt;{&#39;question&#39;: &#39;If all cats...&#39;, &#39;model_answer&#39;: &#39;No&#39;, &#39;passed&#39;: True}
{&#39;question&#39;: &#39;If A implies B...&#39;, &#39;model_answer&#39;: &#39;True&#39;, &#39;passed&#39;: True}&lt;/terminal-block&gt;&lt;p&gt;That’s a &lt;strong&gt;simple eval&lt;/strong&gt;, a “unit test” for reasoning logic. But unlike code tests, this checks &lt;em&gt;semantic understanding&lt;/em&gt;, not strict syntax.&lt;/p&gt;
&lt;p&gt;Lets go a bit deeper…&lt;/p&gt;
&lt;h3 id=&quot;behavioral-evals&quot; tabindex=&quot;-1&quot;&gt;Behavioral Evals &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#behavioral-evals&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Modern evals go beyond right/wrong answers. They measure &lt;strong&gt;how&lt;/strong&gt; and &lt;strong&gt;why&lt;/strong&gt; a model responds.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Safety evals:&lt;/strong&gt; “Does the model refuse unsafe instructions?”&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Helpfulness evals:&lt;/strong&gt; “Does it give contextually useful advice?”&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bias evals:&lt;/strong&gt; “Does it favor certain groups or ideas?”&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Creativity evals:&lt;/strong&gt; “Can it reimagine a concept in a novel way?”&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You might score them with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Direct comparison to a reference answer (string match)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;LLM-as-a-judge scoring (“rate from 1–5”)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rule-based scripts&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Embedding similarity metrics&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So instead of just “assert true”, you now have &lt;em&gt;graded&lt;/em&gt; intelligence.&lt;/p&gt;
&lt;h3 id=&quot;the-evals-mindset&quot; tabindex=&quot;-1&quot;&gt;The Evals Mindset &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#the-evals-mindset&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you start thinking in evals, you stop asking &lt;em&gt;“&lt;strong&gt;&lt;strong&gt;Is my model smart?&lt;/strong&gt;&lt;/strong&gt;”&lt;/em&gt; and start asking &lt;em&gt;“&lt;strong&gt;&lt;strong&gt;How is my model smart and where does it fail?&lt;/strong&gt;&lt;/strong&gt;”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That shift is huge. It turns AI development from a black box into a scientific process.&lt;/p&gt;
&lt;h3 id=&quot;building-your-own-evals&quot; tabindex=&quot;-1&quot;&gt;Building Your Own Evals &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#building-your-own-evals&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can start simple:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Define what to test.&lt;/strong&gt; (reasoning, math, factual accuracy, tone)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create a testset.&lt;/strong&gt; (small JSON or CSV of prompt → expected)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Automate evaluation.&lt;/strong&gt; (script or framework)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Track performance.&lt;/strong&gt; (store metrics per model/version)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Example JSON testset:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;logic_001&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;If X &gt; Y and Y &gt; Z, is X &gt; Z?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;expected&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Yes&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;math_002&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;What’s 12 * 8?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;expected&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;96&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Then, a script that runs through each item and logs results. You can even compare models side by side, just like &lt;code&gt;pytest&lt;/code&gt; results.&lt;/p&gt;
&lt;h3 id=&quot;frameworks-to-explore&quot; tabindex=&quot;-1&quot;&gt;Frameworks to Explore &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#frameworks-to-explore&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Some great open-source tools already exist:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://ragas.io/&quot;&gt;Ragas&lt;/a&gt; - one of the leading evals today and wide range of llm options, integrations and metrics available. (Don’t just take my word for it cause I’m working on it. Really, give it a try!)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;OpenAI Evals&lt;/strong&gt; – the eval harness used to test GPT models&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;HELM&lt;/strong&gt; (by Stanford CRFM) – holistic evaluation across domains&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;LangSmith / TruLens&lt;/strong&gt; – track evals with visual dashboards&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But you don’t need fancy infrastructure to start. A CSV and a few lines of Python are enough to make your first evals suite.&lt;/p&gt;
&lt;h3 id=&quot;the-big-picture&quot; tabindex=&quot;-1&quot;&gt;The Big Picture &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/ai-evals/#the-big-picture&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Evals are how we &lt;strong&gt;bring engineering discipline to AI&lt;/strong&gt;. They don’t just tell us if a model is “good”. They tell us &lt;em&gt;how&lt;/em&gt; it behaves, &lt;em&gt;where&lt;/em&gt; it fails, and &lt;em&gt;why&lt;/em&gt; it improves.&lt;/p&gt;
&lt;p&gt;In other words, evals are &lt;strong&gt;unit tests for intelligence&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;And if the future of AI is about aligning machines with human values, then evals are how we write those values, in code.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://hamel.dev/blog/posts/evals/&quot;&gt;&lt;img src=&quot;https://hamel.dev/blog/posts/evals/images/diagram-cover.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let me know how you’re exploring evals and how you see them as. 👋&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Run your code anywhere</title>
		<link href="https://blog.anirudha.dev/wasmrun-os/"/>
		<updated>2025-10-12T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/wasmrun-os/</id>
		<content type="html">&lt;p&gt;Let me tell you about Vani. She’s a web development instructor teaching Node.js to a class of 30 students. Every semester, she spends the first two weeks just getting everyone’s environment set up. Some students have Windows, others have Mac, and a few brave souls are on Linux. Half of them struggle with npm permissions, a quarter get stuck with PATH issues, and there’s always that one student whose antivirus blocks Node.js installation entirely.&lt;/p&gt;
&lt;p&gt;By the time everyone can run &lt;code&gt;npm install&lt;/code&gt; successfully, Vani has lost two weeks of actual teaching time. And that’s just for one language. If she wants to teach Python next semester, the whole circus starts again.&lt;/p&gt;
&lt;p&gt;Or consider Jiwan, a senior developer at a startup. He works on three different projects: a legacy app on Node.js v12, the current production app on v20, and a new experimental project on v24. He’s constantly switching between them using nvm, but sometimes he forgets to switch, and suddenly his v18 app breaks because he’s running it on v14. He’s tried Docker, but the overhead is annoying, and his M1 Mac makes Docker even slower.&lt;/p&gt;
&lt;p&gt;Then there’s the open-source maintainer who wants to add a “Try it now” button to their project’s README. They want people to click and immediately play with the code, no installation required. But setting up a server to run user code safely is expensive and complicated. How do you sandbox untrusted code? How do you prevent someone from mining Bitcoin on your servers? How do you prevent some hidden script to steal all your passwords and if you’ve wallet linked, all your hard earned money? How do you scale when your project goes viral on Hacker News?&lt;/p&gt;
&lt;p&gt;These aren’t edge cases. These are everyday problems that developers face. We’ve been solving them the same way for decades: install runtimes locally, manage versions manually, hope nothing conflicts, and pray that “works on my machine” actually works on theirs too.&lt;/p&gt;
&lt;p&gt;A simple solution came up in the form of containers. Docker is almost a household tool found in every other project and sometimes too often as recommended way to develop. Various orchestration have come up in the recent years and the entire devops heavy infra became a norm, of which we’re part of today. I’m not saying dockers of this world are a pain, but I can tell you no dev, while building wants to run heavy containers just to keep checking if it’s compatible in various machines.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://x.com/solomonstre/status/1111004913222324225&quot;&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/84868000-d973-4d4d-8807-0b0ca47289b8.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-if-code-could-just-run%3F&quot; tabindex=&quot;-1&quot;&gt;What if Code Could Just Run? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#what-if-code-could-just-run%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine opening a browser and running any project without installing anything. No Node.js download, no Python virtual environments, no Go toolchain, no dependency hell. Just open a URL and start coding.&lt;/p&gt;
&lt;p&gt;Sounds like science fiction? It’s not. StackBlitz already does this with their &lt;a href=&quot;https://webcontainers.io/&quot;&gt;WebContainers&lt;/a&gt;. You can run full Node.js applications entirely in your browser. The server just serves static files. Everything executes client-side in WebAssembly.&lt;/p&gt;
&lt;p&gt;But WebContainers are proprietary and focused on their IDE. What if we could have this capability as a standalone tool? What if it worked for any language, not just JavaScript? What if it was open source and you could either build or request the community for features specific to your needs?&lt;/p&gt;
&lt;p&gt;That’s why we’re building &lt;a href=&quot;https://github.com/anistark/wasmrun&quot;&gt;wasmrun OS&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;the-teacher%E2%80%99s-dream&quot; tabindex=&quot;-1&quot;&gt;The Teacher’s Dream &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-teacher%E2%80%99s-dream&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Remember Vani? With wasmrun OS mode, she could teach Python next semester by just changing one parameter. The same environment, the same interface, different language. Her students could focus on learning programming, not fighting with their computers.&lt;/p&gt;
&lt;p&gt;One student doesn’t have a laptop? They can use the library computer. Another student’s computer is locked down by corporate IT? Doesn’t matter - it runs in the browser. The playing field is level.&lt;/p&gt;
&lt;h3 id=&quot;the-developer%E2%80%99s-sanity&quot; tabindex=&quot;-1&quot;&gt;The Developer’s Sanity &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-developer%E2%80%99s-sanity&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Jiwan’s life gets simpler too. Each project specifies its Node.js version in &lt;code&gt;package.json&lt;/code&gt;. wasmrun OS mode reads it and loads exactly that version - v14, v18, v20, whatever. No more nvm, no more “which version am I on again?”, no more conflicts.&lt;/p&gt;
&lt;p&gt;He opens his legacy project, it runs on v14. He switches to production, it automatically loads v18. He experiments with the new features, v20 is there. Different projects, different versions, zero mental overhead.&lt;/p&gt;
&lt;p&gt;Better yet, everything runs in isolation. If his experimental project crashes spectacularly, it doesn’t affect anything else. No stray processes, no port conflicts, no leftover node_modules pollution. Clean slate every time.&lt;/p&gt;
&lt;h3 id=&quot;play-around-with-code-more&quot; tabindex=&quot;-1&quot;&gt;Play around with code more &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#play-around-with-code-more&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;First-time contributor wants to fix a bug in an open source project? Run it with wasmrun, see the code running, make their changes, verify the fix works, submit a PR. They never installed anything. The barrier to contribution just dropped to almost zero.&lt;/p&gt;
&lt;h3 id=&quot;the-student-learning-to-code&quot; tabindex=&quot;-1&quot;&gt;The Student Learning to Code &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-student-learning-to-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Ankita is learning web development. She’s 16 and uses her school’s Chromebook. She can’t install anything. The device is locked down. But she can open a browser.&lt;/p&gt;
&lt;p&gt;Her online course uses wasmrun OS. She’s building a REST API in Node.js. She’s never touched Node.js before. She doesn’t know what npm is. She doesn’t need to. The environment handles it. She can focus on learning Express routes, not fighting with npm or bun or pnpm or yarn debate.&lt;/p&gt;
&lt;p&gt;Next week, she’s learning Python and Flask. Same environment, same interface, different language. No cognitive load from different tools. Just learning.&lt;/p&gt;
&lt;h3 id=&quot;the-company-running-code-safely&quot; tabindex=&quot;-1&quot;&gt;The Company Running Code Safely &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-company-running-code-safely&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A startup builds a platform where users submit data processing scripts. These scripts need to run, but they’re untrusted code. What if someone writes an infinite loop? What if they try to access the file system? What if they attempt to make network requests to exfiltrate data?&lt;/p&gt;
&lt;p&gt;Traditional solution: spin up Docker containers, set strict resource limits, monitor everything, deal with cold starts, pay for idle containers, hope your sandboxing is bulletproof.&lt;/p&gt;
&lt;p&gt;With wasmrun OS: user submits code, it runs in a WebAssembly sandbox in their own browser. It has zero access to the host system. It can’t make network requests unless explicitly allowed. It can’t access real files. When it’s done, it’s gone. No servers strained, no security nightmares, no infrastructure costs for running user code.&lt;/p&gt;
&lt;p&gt;The startup’s servers? They just coordinate and store results. The heavy lifting happens client-side.&lt;/p&gt;
&lt;h3 id=&quot;the-conference-workshop&quot; tabindex=&quot;-1&quot;&gt;The Conference Workshop &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-conference-workshop&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Arko is running a workshop at a developer conference. He’s teaching 200 people how to build microservices with Go. In the past, he’d spend the first 30 minutes helping people install Go, set GOPATH, troubleshoot compiler errors on Windows.&lt;/p&gt;
&lt;p&gt;Now? “Everyone run with wasmrun.” That’s it. Two minutes later, everyone has an identical Go development environment. Different laptops, different operating systems, same environment.&lt;/p&gt;
&lt;p&gt;Halfway through, he realizes he should have used a different Go version. He updates one configuration file, tells everyone to refresh. Done. Everything rebuilds as per the new specs now.&lt;/p&gt;
&lt;h3 id=&quot;the-offline-developer&quot; tabindex=&quot;-1&quot;&gt;The Offline Developer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-offline-developer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Puja is an adventure junkie programmer. She’s currently in a cabin in rural Vietnam with spotty internet. She’s gonna go for a deep dive the next morning. She loaded wasmrun OS mode yesterday when she had good wifi in the city. The browser cached the Node.js v20 runtime - all 50MB of it.&lt;/p&gt;
&lt;p&gt;Now she’s offline, but she’s still coding. The runtime is cached, her project files are in the browser, and everything works. She’s building a REST API, running tests, seeing live results. No internet required.&lt;/p&gt;
&lt;p&gt;When she gets back to civilization, she’ll push her code to GitHub. But for now, she’s productive in the middle of nowhere.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So, how does wasmrun OS actually work?&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-traditional-way&quot; tabindex=&quot;-1&quot;&gt;The Traditional Way &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-traditional-way&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Normally, when you run Node.js code:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You install Node.js on your operating system&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your code runs as a process managed by your OS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It accesses your real file system&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It makes real network requests&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It can do anything your user account can do&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This works, but it’s heavy and risky. Heavy because you need the full runtime installed. Risky because the code has real access to your system.&lt;/p&gt;
&lt;h3 id=&quot;the-wasmrun-way&quot; tabindex=&quot;-1&quot;&gt;The wasmrun Way &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-wasmrun-way&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;With wasmrun OS mode:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The browser downloads a tiny kernel (2-3MB of WebAssembly)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This kernel is like a mini operating system running in your browser&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When you run a Node.js project, the kernel downloads the Node.js runtime (50MB, but cached)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your code runs inside this Node.js runtime, which runs inside the kernel, which runs in WebAssembly, which runs in your browser. (No, I wasn’t thinking of inception, you were!)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It’s sandboxed at every level&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Think of it like Russian nesting dolls, but for code execution environments. Best part, you don’t even need to think about any of it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/06ffc418-e559-4686-a7a9-ccc7427aaa0d.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The kernel is the brain. It manages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Processes&lt;/strong&gt;: Each project you run gets a unique process ID, just like in a real OS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;File system&lt;/strong&gt;: A virtual file system that exists only in browser memory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scheduling&lt;/strong&gt;: If you run multiple projects, it schedules CPU time between them&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Syscalls&lt;/strong&gt;: When your code wants to read a file or make a network request, the kernel handles it&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s written in Rust and compiled to WebAssembly. It’s tiny, fast, and secure. All development is in public built as open source project.&lt;/p&gt;
&lt;p&gt;The kernel doesn’t run your JavaScript or Python directly. It loads language-specific runtimes:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Node.js runtime&lt;/strong&gt;: A full Node.js environment compiled to WebAssembly. It includes V8 (the JavaScript engine), the Node.js APIs (fs, http, etc.), and npm support. When it needs to read a file, it asks the kernel. When it needs to make a network request, the kernel intercepts it and uses browser’s APIs like capability APIs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Python runtime&lt;/strong&gt;: CPython compiled to WebAssembly, with pip support. Same idea - it talks to the kernel for system operations. Kinda similar to how &lt;a href=&quot;https://pyodide.org/en/stable/&quot;&gt;pyodide&lt;/a&gt; works, but we’re running inside a controlled container, so the runtime approach is quite different and configurable with a range of language plugins.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go runtime&lt;/strong&gt;: Go programs (&lt;a href=&quot;https://tinygo.org/&quot;&gt;tinygo&lt;/a&gt;) can already compile to WebAssembly, so this one’s simpler. The Go code compiles directly, and the kernel provides the syscall interface.&lt;/p&gt;
&lt;h3 id=&quot;version-management&quot; tabindex=&quot;-1&quot;&gt;Version Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#version-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Here’s the clever part: your &lt;code&gt;package.json&lt;/code&gt; might say:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;engines&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;node&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&gt;=18.0.0&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;wasmrun OS mode reads this. It checks what Node.js versions are available. It picks v20 (the latest LTS that satisfies &amp;gt;=18). It checks if v20 is cached in your browser. If yes, loads it instantly. If no, downloads it once and caches it forever. Of course you can clear the cache anytime you want. &lt;em&gt;I’d not want to keep nodejs v8 till today myself.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Next time you run any project that needs v20, it’s instant - already cached.&lt;/p&gt;
&lt;p&gt;If you run a project that needs v18, it downloads and caches v18 separately. Now you have both cached. Switching between projects with different versions? Instant. No nvm, no version management, it just works.&lt;/p&gt;
&lt;h3 id=&quot;the-file-system&quot; tabindex=&quot;-1&quot;&gt;The File System &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-file-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Your project has files. Your code reads and writes them. But there’s no real file system in a browser.&lt;/p&gt;
&lt;p&gt;wasmrun OS mode creates a virtual file system that connects with your original files using a variation of &lt;a href=&quot;https://github.com/WebAssembly/wasi-filesystem&quot;&gt;wasi filesystem&lt;/a&gt;. It’s just data structures in memory. When you mount your project, it loads all your files into this virtual FS. When your code does &lt;code&gt;fs.readFile(&#39;package.json&#39;)&lt;/code&gt;, the kernel intercepts it and reads from virtual memory.&lt;/p&gt;
&lt;p&gt;You can edit files in the browser UI, and your code sees the changes immediately. Anytime the code is edited, it hooks to the original code and updates that immediately as well.&lt;/p&gt;
&lt;p&gt;For persistence, it can sync to IndexedDB. Close the browser, come back tomorrow, your files are still there.&lt;/p&gt;
&lt;p&gt;If you don’t like browser UI, edit with neovim or vs code or cursor. If you edit the original code directly, the hot-loading will immediately serve the new build. wasmrun is currenty based on &lt;strong&gt;AOT&lt;/strong&gt;(&lt;strong&gt;Ahead-of-Time)&lt;/strong&gt; compiler. However, some interest in JIT compilers is under discussion and consideration.&lt;/p&gt;
&lt;h3 id=&quot;the-security-model&quot; tabindex=&quot;-1&quot;&gt;The Security Model &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-security-model&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Everything runs in WebAssembly. WebAssembly is sandboxed by design - it can’t escape the browser. Your code can’t:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Access your real file system&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make arbitrary network requests (unless the kernel allows it)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run system commands&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Access your webcam or microphone&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Steal your cookies&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s as secure as running code can be. Even if you run malicious code, it’s trapped in the WebAssembly sandbox. When you close the tab, it’s gone.&lt;/p&gt;
&lt;h2 id=&quot;the-current-state%3A-experimental-and-evolving&quot; tabindex=&quot;-1&quot;&gt;The Current State: Experimental and Evolving &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-current-state%3A-experimental-and-evolving&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s be honest: this is ambitious. We’re essentially building an operating system in WebAssembly. We’re not done yet.&lt;/p&gt;
&lt;h3 id=&quot;what-works-today&quot; tabindex=&quot;-1&quot;&gt;What Works Today &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#what-works-today&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you try wasmrun OS mode right now with latest &lt;a href=&quot;https://crates.io/crates/wasmrun/0.13.0&quot;&gt;&lt;strong&gt;wasmrun v0.13.0&lt;/strong&gt;&lt;/a&gt;, you’ll get:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A working micro-kernel with process management&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A virtual WASI file system you can browse&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Project auto-detection (Node.js, Python, Go, Rust)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A development server that starts for your project&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A browser UI with file explorer and kernel dashboard&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;HTTP proxying to your running application&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It works. You can run a project, see it execute, browse files, and interact with it.&lt;/p&gt;
&lt;h2 id=&quot;why-open-source-matters&quot; tabindex=&quot;-1&quot;&gt;Why Open Source Matters &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#why-open-source-matters&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;wasmrun is open source. The entire OS mode implementation is on GitHub. You can read every line of code. You can see exactly how it works.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/238cb9a0-5344-49f2-b1be-4c4a4f2a2ea2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This matters because:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Trust&lt;/strong&gt;: You’re running code in your browser. You should be able to verify it’s safe.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Collaboration&lt;/strong&gt;: This is a big project. We need help. Maybe you’re good at WebAssembly. Maybe you know how Node.js internals work. Maybe you’re amazing at documentation. There’s a place for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Innovation&lt;/strong&gt;: The best ideas come from diverse perspectives. We’ve designed it one way, but maybe you see a better approach. Open source means you can propose it, implement it, and improve it for everyone.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Longevity&lt;/strong&gt;: Companies pivot. Projects get abandoned. Open source means wasmrun will live as long as people find it useful.&lt;/p&gt;
&lt;p&gt;We’re actively developing this, and we’d love your help.&lt;/p&gt;
&lt;h3 id=&quot;if-you%E2%80%99re-a-developer&quot; tabindex=&quot;-1&quot;&gt;If You’re a Developer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#if-you%E2%80%99re-a-developer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Contribute code&lt;/strong&gt;: Check the GitHub issues. There’s lots to build.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Review architecture&lt;/strong&gt;: Read the code and tell us where we can improve.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test it&lt;/strong&gt;: Try breaking it. Find bugs. Report them.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Integrate runtimes&lt;/strong&gt;: Know how to get Node.js running in WASM? We need that expertise.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optimize performance&lt;/strong&gt;: Make it faster. Every millisecond counts.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-you%E2%80%99re-a-tech-writer&quot; tabindex=&quot;-1&quot;&gt;If You’re a Tech Writer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#if-you%E2%80%99re-a-tech-writer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: We need clear guides for users and contributors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tutorials&lt;/strong&gt;: “Build a REST API with wasmrun OS mode” - someone needs to write this.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Architecture docs&lt;/strong&gt;: Explain the system in ways people can understand.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-you%E2%80%99re-a-designer&quot; tabindex=&quot;-1&quot;&gt;If You’re a Designer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#if-you%E2%80%99re-a-designer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;UI/UX improvements&lt;/strong&gt;: The browser interface works, but it could be beautiful.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Branding&lt;/strong&gt;: Help us look professional.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: Make sure everyone can use it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-you%E2%80%99re-an-educator&quot; tabindex=&quot;-1&quot;&gt;If You’re an Educator &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#if-you%E2%80%99re-an-educator&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Try it in your class&lt;/strong&gt;: Give us feedback on what works and what doesn’t.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create courses&lt;/strong&gt;: Build educational content using wasmrun OS mode.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Spread the word&lt;/strong&gt;: Tell other teachers about it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-you%E2%80%99re-a-user&quot; tabindex=&quot;-1&quot;&gt;If You’re a User &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#if-you%E2%80%99re-a-user&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Star the repo&lt;/strong&gt;: GitHub stars help with visibility.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Share your story&lt;/strong&gt;: How would wasmrun OS mode help you?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Report issues&lt;/strong&gt;: Found a bug? Tell us.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feature requests&lt;/strong&gt;: What do you need that we haven’t built yet?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-vision-forward&quot; tabindex=&quot;-1&quot;&gt;The Vision Forward &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-os/#the-vision-forward&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine a world where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;“Install Node.js” is no longer step one of every tutorial&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Code examples in documentation are runnable with one click&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Students learn programming without fighting their environment&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Developers switch between projects and versions effortlessly&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Running untrusted code is safe by default&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Every computer with a browser is a full development environment&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This isn’t fantasy. The technology exists. WebAssembly is here. Browsers are powerful. We just need to wire it all together.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;wasmrun&lt;/strong&gt; is our attempt to build this future. It’s experimental, it’s ambitious, and it’s not done. But it’s real, it’s happening, and you can be part of it.&lt;/p&gt;
&lt;p&gt;We’re building an operating system for code. An operating system that runs anywhere a browser runs. An operating system that makes programming accessible to everyone.&lt;/p&gt;
&lt;p&gt;Come help us build it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/c111c36b-0eb9-4328-af52-9496f3a7756f.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Create your own wasm plugin</title>
		<link href="https://blog.anirudha.dev/create-your-own-wasm-plugin/"/>
		<updated>2025-09-10T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/create-your-own-wasm-plugin/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;In this &lt;a href=&quot;https://blog.anirudha.dev/rust-plugin-system&quot;&gt;first article&lt;/a&gt; in this series, we went through all different rust plugins, &lt;a href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture&quot;&gt;the previous one&lt;/a&gt;, we understood the wasmrun plugin architecture. Here’s we’ll learn how to create your own wasm plugin which you can run using &lt;a href=&quot;https://github.com/anistark/wasmrun&quot;&gt;wasmrun&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Creating wasm plugins, is not limited to wasmrun plugins alone, they can be quite useful in distributing as independent modules as well. What’s currently lacking today is an open ecosystem, which is surprising given all the developement is quite open. Limited is a better word for it rather. So, consider this more of a guide to building your next wasm project, and to get it to work in the larger wasm ecosystem. Making it open or close is upto you. Currently, I’ve only made it work with published crates, however was testing local plugins as well. So, in case you’re also interested in contrubuting, feel free to work on it.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Plugins were introduced in wasmrun &lt;a href=&quot;https://github.com/anistark/wasmrun/releases/tag/v0.8.2&quot;&gt;v0.8.2&lt;/a&gt; for first time. However, the structural final changes before making it stable only achieved by &lt;a href=&quot;https://github.com/anistark/wasmrun/releases/tag/v0.11.3&quot;&gt;v0.11.3&lt;/a&gt;. So, make sure you’ve the right &lt;a href=&quot;https://crates.io/crates/wasmrun&quot;&gt;crate&lt;/a&gt; version installed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;creating-your-own-plugin&quot; tabindex=&quot;-1&quot;&gt;Creating Your Own Plugin &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#creating-your-own-plugin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Creating a wasmrun plugin involves implementing the required traits and exposing them through FFI for external plugins.&lt;/p&gt;
&lt;h3 id=&quot;create-a-new-rust-project&quot; tabindex=&quot;-1&quot;&gt;Create a New Rust Project &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#create-a-new-rust-project&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;# Create a new library crate
cargo new --lib wasmcustomlang
cd wasmcustomlang

# Add wasmrun as a dependency
cargo add wasmrun&lt;/terminal-block&gt;&lt;h3 id=&quot;configure-cargo.toml&quot; tabindex=&quot;-1&quot;&gt;Configure Cargo.toml &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#configure-cargo.toml&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasmcustomlang&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.1.0&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;edition&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2021&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;description&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Custom language plugin for wasmrun&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;license&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MIT&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;keywords&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;webassembly&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;plugin&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasmrun&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;lib&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasmcustomlang&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;crate-type&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cdylib&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;rlib&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Both dynamic and static library&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;wasmrun&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.10&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;libc&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.2&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;bin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasmrun-wasmcustomlang&quot;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Fallback binary&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;src/main.rs&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;implement-the-plugin-traits&quot; tabindex=&quot;-1&quot;&gt;Implement the Plugin Traits &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#implement-the-plugin-traits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmrun&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmrun&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;supported_extensions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cl&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;br /&gt;        path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang.toml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            version&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.1.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            description&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Custom language WebAssembly compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            author&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Your Name &amp;lt;email@example.com&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            extensions&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cl&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            capabilities&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;watch&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;web&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            dependencies&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dependencies&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                tools&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                optional_tools&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-optimizer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    plugin_info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            plugin_info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; output_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Your custom compilation logic here&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; main_file &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; output_file &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;output.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Example: Call your custom compiler&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; output &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;--input&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;main_file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;--output&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;output_file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;--target&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasm32&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; output&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;wasmrun&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Custom lang compilation failed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build_for_web&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; output_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Web-specific build logic&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; output_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;clean&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Clean build artifacts&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; build_dir &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; build_dir&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;fs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;remove_dir_all&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;build_dir&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_wasm_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Return the main WASM file path&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; wasm_file &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;output.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;wasm_file&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;implement-ffi-interface&quot; tabindex=&quot;-1&quot;&gt;Implement FFI Interface &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#implement-ffi-interface&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;ffi&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; c_char&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; c_void&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;GLOBAL_PLUGIN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;GLOBAL_BUILDER&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// FFI exports for dynamic loading&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;create_wasm_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_void &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token constant&quot;&gt;GLOBAL_BUILDER&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token constant&quot;&gt;GLOBAL_BUILDER&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;as_mut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; _ &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_void&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;builder&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_void&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; c_char&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; builder&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_ptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path_str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; c_str&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path_str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    builder&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_void&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;    project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; c_char&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;    output_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; c_char&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; c_char &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; builder&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; output_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_project &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_ptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_output &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_ptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c_project&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; c_output&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; builder_ref &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;builder &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; builder_ref&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_str&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; output_str&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; c_result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token namespace&quot;&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_plugin_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; c_char &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; info &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;serde_json&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_string &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        c_string&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;into_raw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token namespace&quot;&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Cleanup function.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;cleanup_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_char&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; _ &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_raw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;(optional)-create-binary&quot; tabindex=&quot;-1&quot;&gt;(Optional) Create Binary &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#(optional)-create-binary&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another easier approach for plugin extensions was to create and distribute the binary. Binaries could have ran independently with no compatibility issues. I prefer binary is secondary, not primary. However, binary are great to test and develop with.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/main.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmcustomlang&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmrun&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;collect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;eprintln!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Usage: {} &amp;lt;command&gt; [args...]&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;match&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;as_str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;can-handle&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token macro property&quot;&gt;eprintln!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Usage: {} can-handle &amp;lt;project-path&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; can_handle &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; can_handle&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;build&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token macro property&quot;&gt;eprintln!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Usage: {} build &amp;lt;project-path&gt; &amp;lt;output-path&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; builder &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; builder&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token string&quot;&gt;&quot;info&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; info &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; json &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;serde_json&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_pretty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; json&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        _ &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token macro property&quot;&gt;eprintln!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Unknown command: {}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; args&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;build-and-test-locally&quot; tabindex=&quot;-1&quot;&gt;Build and Test Locally &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#build-and-test-locally&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;# Build the plugin
cargo build --release

# Test that it builds correctly
cargo test

# Create a test project
mkdir test-project
echo &#39;fn main() { println!(&amp;quot;Hello from CustomLang!&amp;quot;); }&#39; &amp;gt; test-project/main.custom

# Test the plugin locally
cargo run -- can-handle test-project
cargo run -- build test-project ./output
cargo run -- info&lt;/terminal-block&gt;&lt;h2 id=&quot;plugin-distribution&quot; tabindex=&quot;-1&quot;&gt;Plugin Distribution &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#plugin-distribution&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;publish-to-crates.io&quot; tabindex=&quot;-1&quot;&gt;Publish to &lt;a href=&quot;https://crates.io/&quot;&gt;crates&lt;/a&gt;&lt;a href=&quot;http://crates.io/&quot;&gt;.io&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#publish-to-crates.io&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;# Login to crates.io
cargo login

# Publish the plugin
cargo publish&lt;/terminal-block&gt;&lt;h3 id=&quot;plugin-metadata-in-cargo.toml&quot; tabindex=&quot;-1&quot;&gt;Plugin Metadata in Cargo.toml &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#plugin-metadata-in-cargo.toml&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For better wasmrun integration, you can add wasmrun-specific metadata to your Cargo.toml:&lt;/p&gt;
&lt;code-block lang=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package.metadata.wasm_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.1.0&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;description&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Custom language WebAssembly compiler&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;author&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Your Name &amp;lt;email@example.com&gt;&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;extensions&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cl&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;entry_files&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang.toml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package.metadata.wasm_plugin.capabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;compile_wasm&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;compile_webapp&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;live_reload&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;optimization&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;custom_targets&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasm32-unknown-unknown&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;supported_languages&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# Explicit language support declaration&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# For multi-language plugins: supported_languages = [&quot;rust&quot;, &quot;zig&quot;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# If there&#39;s variations in same language, better to add each as separate langugage.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package.metadata.wasm_plugin.dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;tools&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;optional_tools&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-optimizer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package.metadata.wasm_plugin.exports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;create_wasm_builder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;create_wasm_builder&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;can_handle_project&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang_can_handle_project&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;build&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang_build&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;clean&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang_clean&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;clone_box&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang_clone_box&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;drop&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang_drop&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;plugin_create&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;wasmrun_plugin_create&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;package.metadata.wasm_plugin.frameworks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;supported&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom-framework&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;auto_detect&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;plugin-management&quot; tabindex=&quot;-1&quot;&gt;Plugin Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#plugin-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;install-and-use-with-wasmrun&quot; tabindex=&quot;-1&quot;&gt;Install and Use with Wasmrun &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#install-and-use-with-wasmrun&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;# Install your plugin
wasmrun plugin install wasmcustomlang

# Use it with a project
wasmrun ./my-custom-project
wasmrun compile ./my-custom-project --language customlang&lt;/terminal-block&gt;&lt;h3 id=&quot;plugin-metadata-management&quot; tabindex=&quot;-1&quot;&gt;Plugin Metadata Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#plugin-metadata-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Plugin metadata is stored in several places:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;~/.wasmrun/plugins/{name}/.wasmrun_metadata&lt;/code&gt; - Plugin information&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;~/.wasmrun/config.toml&lt;/code&gt; - Global plugin registry&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Plugin’s &lt;code&gt;Cargo.toml&lt;/code&gt; - Source metadata&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Example metadata file:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;version&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.1.0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Custom language WebAssembly compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Your Name &amp;lt;email@example.com&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;extensions&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cl&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;entry_files&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang.toml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;capabilities&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;compile_wasm&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;compile_webapp&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;live_reload&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;optimization&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;custom_targets&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasm32-unknown-unknown&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;supported_languages&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;dependencies&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;tools&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;optional_tools&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-optimizer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;plugin-management-commands&quot; tabindex=&quot;-1&quot;&gt;Plugin Management Commands &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#plugin-management-commands&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;terminal-block&gt;# List installed plugins
wasmrun plugin list

# Install a plugin
wasmrun plugin install wasmrust

# Uninstall a plugin  
wasmrun plugin uninstall wasmrust

# Update a plugin
wasmrun plugin update wasmrust

# Show plugin info
wasmrun plugin info wasmrust&lt;/terminal-block&gt;&lt;h2 id=&quot;best-practices-for-plugin-development&quot; tabindex=&quot;-1&quot;&gt;Best Practices for Plugin Development &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#best-practices-for-plugin-development&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;error-handling&quot; tabindex=&quot;-1&quot;&gt;Error Handling &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#error-handling&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Always provide clear error messages and handle edge cases:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; output_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Validate inputs&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Project path does not exist&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Check for required tools&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;which&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;which&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler not found. Please install CustomLang toolchain.&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Your build logic...&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;project-detection&quot; tabindex=&quot;-1&quot;&gt;Project Detection &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#project-detection&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Make project detection robust and specific:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Check for specific files&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang.toml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Check for file patterns&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;entries&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;fs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;read_dir&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; entry &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; entries&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ext&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; ext &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;dependency-management&quot; tabindex=&quot;-1&quot;&gt;Dependency Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#dependency-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Check for dependencies and provide helpful error messages:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;check_dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; missing &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;which&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;which&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        missing&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;customlang-compiler&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    missing&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;testing&quot; tabindex=&quot;-1&quot;&gt;Testing &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#testing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Write comprehensive tests for your plugin. Try to increase coverage and also check all cases:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(test)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;mod&lt;/span&gt; &lt;span class=&quot;token module-declaration namespace&quot;&gt;tests&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;tempdir&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;TempDir&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token attribute attr-name&quot;&gt;#[test]&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;test_can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; tmp_dir &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TempDir&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; project_path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tmp_dir&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Create test file&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;fs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;test content&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;assert!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token attribute attr-name&quot;&gt;#[test]&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;test_plugin_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CustomLangPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; info &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;customlang&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;assert!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;extensions&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;custom&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;common-issues-and-solutions&quot; tabindex=&quot;-1&quot;&gt;Common Issues and Solutions &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#common-issues-and-solutions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;dynamic-library-loading-issues&quot; tabindex=&quot;-1&quot;&gt;Dynamic Library Loading Issues &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#dynamic-library-loading-issues&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you try to load the plugin, you might encounter an error message saying that the library cannot be found. This issue is quite common and can be frustrating, especially if you’re not sure where things are going wrong. The error typically occurs because the system is unable to locate the necessary library files that the plugin depends on. This can happen if the library paths are not set correctly or if the library files are not named properly. To resolve this issue, you should first double-check that the library search paths are correctly configured. This involves ensuring that the directories where the libraries are stored are included in the system’s library path environment variables. Additionally, make sure that the library files are named correctly according to the system’s conventions. Sometimes, simply renaming a library file to match the expected naming pattern can solve the problem. By taking these steps, you can help the system locate the necessary libraries and successfully load the plugin without any errors.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// In your plugin loading code&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; lib_paths &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token macro property&quot;&gt;format!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;lib{}.dylib&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// macOS&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token macro property&quot;&gt;format!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;lib{}.so&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;         &lt;span class=&quot;token comment&quot;&gt;// Linux  &lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token macro property&quot;&gt;format!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;{}.dll&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;           &lt;span class=&quot;token comment&quot;&gt;// Windows&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;abi-compatibility&quot; tabindex=&quot;-1&quot;&gt;ABI Compatibility &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#abi-compatibility&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When a plugin crashes due to an ABI mismatch, it can be quite a headache to deal with. ABI, or Application Binary Interface, refers to the way different program modules communicate at the binary level. If there’s a mismatch, it means that the plugin and the host application are not able to communicate properly, leading to crashes or unexpected behavior. This often happens when the plugin and the application are built with different compiler versions or settings, or when there have been changes in the data structures or function signatures that they use to interact. It’s important to use stable ABI-compatible interfaces. This means designing your plugin and application interfaces in a way that remains consistent across different versions and compiler settings. One effective strategy is to implement version checking. By including version information in your interfaces, you can ensure that the plugin only loads if it matches the expected version of the application. This helps prevent crashes by ensuring that both the plugin and the application are using compatible interfaces. Additionally, it’s a good practice to document any changes in the ABI and communicate these changes to developers who might be using your plugin, so they can make the necessary adjustments on their end.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;plugin_abi_version&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;u32&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Increment when ABI changes&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;memory-management&quot; tabindex=&quot;-1&quot;&gt;Memory Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/create-your-own-wasm-plugin/#memory-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When dealing with memory leaks or crashes at the FFI boundary, it can be quite challenging to pinpoint the exact cause. These issues often arise because of improper handling of memory allocation and deallocation, which can lead to resources not being freed correctly or being accessed after they have been freed. This can cause unexpected behavior or crashes, especially when different languages with different memory management models are involved. It’s crucial to ensure proper memory cleanup and ownership management. This means clearly defining who is responsible for allocating and freeing memory, and sticking to these rules consistently. For example, if your plugin allocates memory, it should also be responsible for freeing it, unless there is a clear agreement that the host application will take over this responsibility. Additionally, using smart pointers or reference counting can help manage ownership and prevent memory leaks. It’s also beneficial to implement thorough testing and debugging practices to catch any memory-related issues early in the development process. By doing so, you can maintain a stable and reliable interface between your plugin and the host application, minimizing the risk of memory leaks or crashes.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;cleanup_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; c_char&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; _ &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_raw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now, you know how to create your very own wasm plugin. Would love to have more community plugins. 🙌&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/6e8fe806-2f4f-4316-aba5-884d0390fe83.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Even if you’re not building one, if you’ve an idea that you’d like to use, feel free to open an &lt;a href=&quot;https://github.com/anistark/wasmrun/issues&quot;&gt;issue&lt;/a&gt; and let us know about it. 🚀&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Wasmrun Plugin Architecture</title>
		<link href="https://blog.anirudha.dev/wasmrun-plugin-architecture/"/>
		<updated>2025-09-05T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/wasmrun-plugin-architecture/</id>
		<content type="html">&lt;p&gt;In the &lt;a href=&quot;https://blog.anirudha.dev/rust-plugin-system&quot;&gt;last article&lt;/a&gt;, I covered all different types of rust plugin architecture and approaches we could have done. Now, lets dive into the plugin architecture used in &lt;a href=&quot;https://github.com/anistark/wasmrun&quot;&gt;wasmrun&lt;/a&gt;, an open-source WebAssembly runtime that supports multiple programming languages through a hybrid plugin system.&lt;/p&gt;
&lt;h2 id=&quot;why-plugins-in-wasmrun&quot; tabindex=&quot;-1&quot;&gt;Why Plugins in Wasmrun &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#why-plugins-in-wasmrun&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wasmrun intends to support multiple programming languages like Rust, Go, C/C++, AssemblyScript, Python and each language has its own:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Compilation toolchain&lt;/strong&gt; (rustc, tinygo, emcc, asc, py2wasm)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Project structure conventions&lt;/strong&gt; (Cargo.toml, go.mod, Makefile, package.json)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optimization strategies&lt;/strong&gt; and output formats&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Development workflow&lt;/strong&gt; requirements&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Initially, we had all language support built directly into the binary:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// This was getting unwieldy fast&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;match&lt;/span&gt; language &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;compile_c_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;cpp&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;compile_cpp_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;assemblyscript&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;compile_as_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;python&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;compile_python_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// External plugins would require subprocess calls&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;rust&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;subprocess_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasmrust&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;go&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;subprocess_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasmgo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// ... and growing&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;The issues became clear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Monolithic binary&lt;/strong&gt; - Every user had to download support for all languages&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tight coupling&lt;/strong&gt; - Adding new language support required core changes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Testing complexity&lt;/strong&gt; - Each language change could break others&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Community contributions&lt;/strong&gt; - External developers couldn’t easily add language support&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wasmrun-implementation%3A-hybrid-built-in-%2B-external&quot; tabindex=&quot;-1&quot;&gt;&lt;code&gt;wasmrun&lt;/code&gt; Implementation: Hybrid Built-in + External &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#wasmrun-implementation%3A-hybrid-built-in-%2B-external&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Initially I started with trying to extend usage with same Traits to external as built-in plugins which would have made creating external plugins easy and also the migration process. However, it soon became an ant hill of issues. A good approach in this would have been to create a common &lt;code&gt;wasmrun_core&lt;/code&gt; crate and import for both. However, I want to keep things at minimal changes and not introduce a new dependency so as to increase &lt;code&gt;wasmrun&lt;/code&gt; maintainability before testing the concept. Another easy option was to run the external plugins as binary directly. However, this would have reduced the customisations that you’d be able to do on the runtime itself. A version of me would argue that this should have been the safest first step, but who cares about playing safe.&lt;/p&gt;
&lt;p&gt;After evaluating different approaches, I settled on a hybrid system that combines the benefits of multiple strategies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Built-in plugins&lt;/strong&gt; using trait objects for core language support&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;External plugins&lt;/strong&gt; using FFI for extensibility&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fallback subprocess execution&lt;/strong&gt; when FFI loading fails. We’ll remove this in future as we move to more tested approach.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This gives us type safety and performance for core functionality, while still allowing runtime extensibility.&lt;/p&gt;
&lt;h2 id=&quot;the-trait-foundation&quot; tabindex=&quot;-1&quot;&gt;The Trait Foundation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#the-trait-foundation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The key insight was to design traits that work identically for both built-in and external plugins:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/plugin/mod.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Sync&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// src/compiler/builder.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Sync&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;language_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;entry_file_candidates&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;supported_extensions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;check_dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; config&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CompilationResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;validate_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CompilationResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;clean&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;clone_box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;plugin-information-structure&quot; tabindex=&quot;-1&quot;&gt;Plugin Information Structure &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-information-structure&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[derive(Debug, Clone, Serialize, Deserialize)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; version&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; description&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; author&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; extensions&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; entry_files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; plugin_type&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; source&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginSource&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; dependencies&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; capabilities&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginCapabilities&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[derive(Debug, Clone, Serialize, Deserialize)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginCapabilities&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; compile_wasm&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; compile_webapp&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; live_reload&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; optimization&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; custom_targets&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; supported_languages&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[derive(Debug, Clone, Serialize, Deserialize)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginSource&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;CratesIo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; version&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Git&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; branch&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Local&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PathBuf&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;built-in-plugins%3A-the-foundation&quot; tabindex=&quot;-1&quot;&gt;Built-in Plugins: The Foundation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#built-in-plugins%3A-the-foundation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Built-in plugins are straightforward. They’re just structs implementing the traits, compiled directly into the binary. The current built-in plugins are C/C++, AssemblyScript, and Python. Earlier rust and go were also built-in but have successfully migrated them external. Soon the plan is to move all language built-in plugins to external.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/plugin/languages/c_plugin.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[derive(Clone)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;CPlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CPlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; info &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            version&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;env!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;CARGO_PKG_VERSION&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            description&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C WebAssembly compiler using Emscripten&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            author&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Wasmrun Team&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            extensions&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;h&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            entry_files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Makefile&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            plugin_type&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Builtin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            source&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            dependencies&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            capabilities&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginCapabilities&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                compile_wasm&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                compile_webapp&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                live_reload&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                optimization&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                custom_targets&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;web&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                supported_languages&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cpp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; info &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CPlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;info&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Check for Makefile or main.c files&lt;/span&gt;&lt;br /&gt;        path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Makefile&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;main.c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CWasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;built-in-plugin-loading&quot; tabindex=&quot;-1&quot;&gt;Built-in Plugin Loading &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#built-in-plugin-loading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All built-in plugins are loaded through a centralized system:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/plugin/builtin.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;load_all_builtin_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugins&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// C plugin&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; c_plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuiltinPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c_plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// AssemblyScript plugin&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; asc_plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;AscPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuiltinPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;asc_plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Python plugin&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; python_plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PythonPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuiltinPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;python_plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;external-plugins%3A-the-interesting-part&quot; tabindex=&quot;-1&quot;&gt;External Plugins: The Interesting Part &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#external-plugins%3A-the-interesting-part&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;External plugins are where things get interesting. The challenge was making them feel identical to built-in plugins while being loaded dynamically.&lt;/p&gt;
&lt;h3 id=&quot;the-cargo-install-approach&quot; tabindex=&quot;-1&quot;&gt;The &lt;code&gt;cargo install&lt;/code&gt; approach &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#the-cargo-install-approach&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I wanted plugin installation to feel familiar to Rust developers:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt;: Uses &lt;code&gt;cargo install&lt;/code&gt; to build the plugin&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Storage&lt;/strong&gt;: Installs to &lt;code&gt;~/.wasmrun/plugins/{plugin_name}/&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Registration&lt;/strong&gt;: Updates wasmrun config with plugin capabilities as mentioned in the plugin &lt;code&gt;Cargo.toml&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ready&lt;/strong&gt;: Plugin automatically handles supported projects&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/plugin/installer.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;install_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;InstallationResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Validate plugin exists on crates.io&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginRegistry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;validate_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token macro property&quot;&gt;format!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Plugin &#39;{plugin_name}&#39; not found&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; wasmrun_root &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;dirs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;home_dir&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ok_or&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Could not determine home directory&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;.wasmrun&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Install using cargo to ~/.wasmrun/&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; output &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cargo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;install&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;            plugin_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;            &lt;span class=&quot;token string&quot;&gt;&quot;--root&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;br /&gt;            &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;wasmrun_root&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;output&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Plugin installation failed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Create plugin directory and metadata&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin_dir &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; wasmrun_root&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;plugins&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;fs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create_dir_all&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_dir&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Extract metadata from Cargo.toml&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; metadata &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;extract_plugin_metadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;save_plugin_metadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_dir&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Update wasmrun config&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;update_plugin_config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;InstallationResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Success&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;plugin-directory-structure&quot; tabindex=&quot;-1&quot;&gt;Plugin Directory Structure &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-directory-structure&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;~/.wasmrun/
├── bin/                    # Plugin binaries installed via cargo
│   ├── wasmrust           # Plugin executable
│   └── wasmgo             # Plugin executable
├── plugins/               # Plugin metadata and dynamic libraries
│   ├── wasmrust/
│   │   ├── .wasmrun_metadata
│   │   ├── libwasmrust.dylib  # Dynamic library (optional)
│   │   └── target/
│   │       └── release/
│   │           └── libwasmrust.dylib
│   └── wasmgo/
│       ├── .wasmrun_metadata
│       └── libwasmgo.dylib
└── config.toml           # Plugin registry and configuration&lt;/terminal-block&gt;&lt;h2 id=&quot;ffi-and-dynamic-loading&quot; tabindex=&quot;-1&quot;&gt;FFI and Dynamic Loading &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#ffi-and-dynamic-loading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;External plugins are loaded as dynamic libraries using Rust’s Foreign Function Interface (FFI). This approach provides several advantages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: Direct function calls instead of subprocess execution&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Integration&lt;/strong&gt;: Same trait interface as built-in plugins&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Efficiency&lt;/strong&gt;: Shared memory space and reduced overhead&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;ffi-interface&quot; tabindex=&quot;-1&quot;&gt;FFI Interface &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#ffi-interface&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// src/plugin/external.rs&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;libloading&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Library&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;/// Generic wrapper for all external plugins&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;ExternalPluginWrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    metadata&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginMetadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;    library&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Library&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalPluginWrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PathBuf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalPluginEntry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin_name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginUtils&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_plugin_available&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;WasmrunError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token macro property&quot;&gt;format!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token string&quot;&gt;&quot;Plugin &#39;{plugin_name}&#39; not available&quot;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Load metadata for ALL plugins&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; metadata &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginMetadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_installed_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;or_else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;_&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginMetadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_crates_io&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;validate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; library &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;try_load_library&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;info&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            plugin_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            metadata&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;            library&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalPluginWrapper&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;info&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Try FFI first if library is available&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;library&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;library &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;exports&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token comment&quot;&gt;// Use FFI to call plugin&#39;s can_handle_project function&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token comment&quot;&gt;// ... FFI implementation details ...&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Fallback to metadata-based checking&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;check_project_via_metadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ExternalWasmBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;library&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;external-builder-implementation&quot; tabindex=&quot;-1&quot;&gt;External Builder Implementation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#external-builder-implementation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The external builder uses a hybrid approach - FFI when available, command execution as fallback:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;ExternalWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    metadata&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginMetadata&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;    library&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Arc&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Library&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmBuilder&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalWasmBuilder&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; config&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CompilationResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Try FFI first if available&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token attribute attr-name&quot;&gt;#[cfg(not(target_os = &lt;span class=&quot;token string&quot;&gt;&quot;windows&quot;&lt;/span&gt;))]&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;library&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;library &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;exports&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;metadata&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token comment&quot;&gt;// Use FFI to call plugin&#39;s build function&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token comment&quot;&gt;// ... FFI implementation details ...&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token comment&quot;&gt;// Return structured BuildResult&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Fallback to command execution&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build_via_command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build_via_command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; config&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CompilationResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Find plugin binary in ~/.wasmrun/bin or system PATH&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; wasmrun_bin_path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;dirs&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;home_dir&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;home&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; home&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;.wasmrun&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;bin&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap_or_else&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PathBuf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin_binary &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; wasmrun_bin_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            wasmrun_bin_path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string_lossy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; output &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;plugin_binary&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;compile&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;-p&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;-o&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;output_dir&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Process result and return BuildResult struct&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// ... result processing ...&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;plugin-manager-integration&quot; tabindex=&quot;-1&quot;&gt;Plugin Manager Integration &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-manager-integration&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The plugin system is managed through a central &lt;code&gt;PluginManager&lt;/code&gt; that handles both built-in and external plugins:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginManager&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    builtin_plugins&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    external_plugins&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    config&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmrunConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    plugin_stats&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginStats&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginManager&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; config &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmrunConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap_or_default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; manager &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;Self&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            builtin_plugins&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            external_plugins&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            config&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            plugin_stats&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginStats&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        manager&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load_all_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        manager&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;update_stats&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;manager&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;load_all_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Load built-in plugins&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;load_all_builtin_plugins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;builtin_plugins&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Load enabled external plugins&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;external_plugins &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; entry&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;enabled &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalPluginLoader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;entry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;✅ Loaded external plugin: {name}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;external_plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                        &lt;span class=&quot;token macro property&quot;&gt;eprintln!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;⚠️  Failed to load external plugin &#39;{name}&#39;: {e}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;find_plugin_for_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// External plugins have priority&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; plugin &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;external_plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Fallback to built-in plugins&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; plugin &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;builtin_plugins &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;project_path&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;as_ref&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;None&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Plugin management methods&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;install_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;update_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;enable_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;disable_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This hybrid architecture gives us the best of both worlds: type-safe, performant built-in plugins for core languages, and the flexibility to extend the system with external plugins for specialized use cases.&lt;/p&gt;
&lt;h2 id=&quot;advanced-features&quot; tabindex=&quot;-1&quot;&gt;Advanced Features &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#advanced-features&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;plugin-health-monitoring&quot; tabindex=&quot;-1&quot;&gt;Plugin Health Monitoring &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-health-monitoring&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The plugin system includes comprehensive health checking. Don’t have much support for it, but playing around it, so should have full support for health check soon.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginHealthStatus&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Healthy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;MissingDependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;NotFound&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;LoadError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginManager&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;check_plugin_health&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_plugin_installed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;NotFound&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; missing_deps &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginRegistry&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;check_plugin_dependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;missing_deps&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;is_empty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;MissingDependencies&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;missing_deps&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Try to load the plugin to ensure it&#39;s functional&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;entry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;external_plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExternalPluginLoader&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;entry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Healthy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token class-name&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;LoadError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginHealthStatus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Healthy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;plugin-updates-and-version-management&quot; tabindex=&quot;-1&quot;&gt;Plugin Updates and Version Management &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-updates-and-version-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The system supports automatic plugin updates:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginManager&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;update_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; plugin_name&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; current_version &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_current_plugin_version&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; latest_version &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get_latest_plugin_version&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; current_version &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; latest_version &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;✅ Plugin &#39;{plugin_name}&#39; is already up to date&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;⬆️  Updating from v{current_version} to v{latest_version}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reinstall_external_plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;latest_version&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;✅ Plugin updated successfully&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;enhanced-build-configuration&quot; tabindex=&quot;-1&quot;&gt;Enhanced Build Configuration &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#enhanced-build-configuration&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Modern build configuration uses structured data instead of simple string parameters:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;BuildConfig&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; output_dir&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; optimization_level&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;OptimizationLevel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; target_format&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TargetFormat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; enable_debug&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; custom_args&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;BuildResult&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; wasm_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; js_path&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; additional_files&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; is_wasm_bindgen&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;plugin-capabilities-system&quot; tabindex=&quot;-1&quot;&gt;Plugin Capabilities System &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#plugin-capabilities-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Rich capability detection allows for better plugin selection:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[derive(Debug, Clone, Serialize, Deserialize)]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginCapabilities&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; compile_wasm&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; compile_webapp&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; live_reload&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; optimization&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; custom_targets&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; supported_languages&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginManager&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;get_plugins_by_capability&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; capability&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginCapabilityFilter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;PluginInfo&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Filter plugins based on specific capabilities&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;builtin_plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;external_plugins&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter_map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;p&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;matches_capability_filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;p&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;capability&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;p&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                    &lt;span class=&quot;token class-name&quot;&gt;None&lt;/span&gt;&lt;br /&gt;                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;collect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;current-built-in-languages&quot; tabindex=&quot;-1&quot;&gt;Current Built-in Languages &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#current-built-in-languages&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The system currently ships with these built-in plugins:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;C/C++&lt;/strong&gt;: Using Emscripten for compilation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript&lt;/strong&gt;: TypeScript-like syntax for WebAssembly&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt;: Using py2wasm or similar tools&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;external-plugin-ecosystem&quot; tabindex=&quot;-1&quot;&gt;External Plugin Ecosystem &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasmrun-plugin-architecture/#external-plugin-ecosystem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Popular external plugins available through &lt;code&gt;cargo install&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/anistark/wasmrust&quot;&gt;&lt;strong&gt;wasmrust&lt;/strong&gt;&lt;/a&gt;: Rust to WebAssembly compilation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/anistark/wasmgo&quot;&gt;&lt;strong&gt;wasmgo&lt;/strong&gt;&lt;/a&gt;: Go to WebAssembly compilation&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Installation is as simple as:&lt;/p&gt;
&lt;terminal-block&gt;wasmrun plugin install wasmrust
wasmrun plugin enable wasmrust # Optional&lt;/terminal-block&gt;&lt;p&gt;This architecture has proven robust and extensible, allowing the wasmrun ecosystem to grow organically while maintaining excellent performance and reliability.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/69dd0e7d-110c-4b58-9fe7-3b91d1b12eed.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So, if you want to make your version of rust plugin and use it with wasmrun, you can. For instance, there can be various tools for compiling rust project through wasm target, and you’ve a special plugin which fits your use-case.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Current stable version of wasmrun is &lt;a href=&quot;https://crates.io/crates/wasmrun&quot;&gt;v0.11.3&lt;/a&gt;. 🚀 Try out our plugin system. 🙌&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Building a Rust Plugin System</title>
		<link href="https://blog.anirudha.dev/rust-plugin-system/"/>
		<updated>2025-08-31T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/rust-plugin-system/</id>
		<content type="html">&lt;p&gt;Plugin systems are one of those architectural decisions that seem straightforward until you start implementing them. In the Rust ecosystem, plugin architectures present unique challenges compared to interpreted languages where you can dynamically load and execute code relatively easily.&lt;/p&gt;
&lt;h2 id=&quot;the-plugin-system-challenge-in-rust&quot; tabindex=&quot;-1&quot;&gt;The Plugin System Challenge in Rust &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#the-plugin-system-challenge-in-rust&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Compiled languages like Rust require more careful consideration around:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Binary compatibility&lt;/strong&gt; across different compiler versions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Memory safety&lt;/strong&gt; when loading external code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance overhead&lt;/strong&gt; of plugin boundaries&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Distribution and versioning&lt;/strong&gt; of plugin components&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Developer experience&lt;/strong&gt; for both plugin authors and users&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;architectural-approaches-in-rust&quot; tabindex=&quot;-1&quot;&gt;Architectural Approaches in Rust &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#architectural-approaches-in-rust&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s examine the main approaches to plugin systems in Rust and their trade-offs:&lt;/p&gt;
&lt;h3 id=&quot;subprocess-based-plugins&quot; tabindex=&quot;-1&quot;&gt;Subprocess-Based Plugins &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#subprocess-based-plugins&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The simplest approach - plugins as separate executables:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Execute plugin as subprocess&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; output &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;wasmrun-rust-plugin&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;build&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_path&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Language agnostic - plugins can be written in any language&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Strong isolation - plugins can’t crash the main process&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Simple distribution - just ship executables&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Performance overhead of process spawning&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Complex data exchange (serialization/pipes)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Harder to maintain shared state&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;webassembly-plugins&quot; tabindex=&quot;-1&quot;&gt;WebAssembly Plugins &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#webassembly-plugins&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Using WASM as the plugin format:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; engine &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmtime&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Engine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; module &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Module&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;engine&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;plugin.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; instance &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Instance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; store&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;module&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sandboxed execution&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cross-platform compatibility&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Same runtime environment&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Performance limitations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Limited system access&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Additional complexity for system-level operations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Highly experimental&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dynamic-library-loading-(ffi)&quot; tabindex=&quot;-1&quot;&gt;Dynamic Library Loading (FFI) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#dynamic-library-loading-(ffi)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Loading plugins as shared libraries:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; lib &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Library&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;plugin.so&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; func&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Symbol&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; lib&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;b&quot;plugin_init&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Native performance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rich API capabilities&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Shared memory space&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Platform-specific binaries&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Safety concerns with unsafe code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;ABI stability challenges&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;trait-objects-%2B-dynamic-dispatch&quot; tabindex=&quot;-1&quot;&gt;Trait Objects + Dynamic Dispatch &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#trait-objects-%2B-dynamic-dispatch&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Compile-time plugin registration:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Sync&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; input&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;PLUGINS&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;RustPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;GoPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Type safety at compile time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Zero runtime overhead&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Simple implementation&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;All plugins must be known at compile time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Monolithic binary&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No runtime extensibility&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;alternative-approaches-to-consider&quot; tabindex=&quot;-1&quot;&gt;Alternative Approaches to Consider &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#alternative-approaches-to-consider&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;wasi-based-plugin-system&quot; tabindex=&quot;-1&quot;&gt;WASI-Based Plugin System &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#wasi-based-plugin-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Using WebAssembly System Interface for plugins could provide better sandboxing:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Hypothetical WASI plugin loader&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; engine &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmtime&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Engine&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; linker &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;wasmtime&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Linker&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;engine&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token namespace&quot;&gt;wasmtime_wasi&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add_to_linker&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;mut&lt;/span&gt; linker&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;s&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; wasi &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasiCtxBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;inherit_stdio&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;inherit_args&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasiPlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;engine&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;linker&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;plugin.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Language agnostic (plugins could be written in any language that compiles to WASM)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Better security through WASI’s capability-based security model&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Consistent cross-platform behavior&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Performance overhead&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Limited access to system APIs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;More complex toolchain for plugin authors&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;grpc-based-plugin-architecture&quot; tabindex=&quot;-1&quot;&gt;gRPC-Based Plugin Architecture &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#grpc-based-plugin-architecture&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Taking inspiration from tools like Terraform:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Plugin communication via gRPC&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;tonic&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token namespace&quot;&gt;transport&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;token type-definition class-name&quot;&gt;PluginService&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;can_handle_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; request&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ProjectPath&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CanHandleResponse&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Status&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;build_project&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; request&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildRequest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BuildResponse&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Status&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Language agnostic&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Network transparency (plugins could run remotely)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Structured communication protocol&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Easy to version and extend&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Network serialization overhead&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;More complex deployment (need to manage plugin processes)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Requires protobuf toolchain&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;lua%2Fjavascript-embedded-scripting&quot; tabindex=&quot;-1&quot;&gt;Lua/JavaScript Embedded Scripting &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#lua%2Fjavascript-embedded-scripting&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Embed a scripting language for simple plugins:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;mlua&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Lua&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; lua &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Lua&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;lua&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;r#&quot;&lt;br /&gt;    function can_handle_project(path)&lt;br /&gt;        return string.match(path, &quot;%.mylang$&quot;) ~= nil&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    function build_project(project_path, output_path)&lt;br /&gt;        os.execute(&quot;mylang-compiler &quot; .. project_path .. &quot; -o &quot; .. output_path)&lt;br /&gt;        return output_path .. &quot;/output.wasm&quot;&lt;br /&gt;    end&lt;br /&gt;&quot;#&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Very low barrier to entry for plugin authors&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No compilation step required&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Dynamic reconfiguration possible&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Limited to what the scripting language can do&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Performance implications&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another language for developers to learn&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;ebpf-style-jit-compilation&quot; tabindex=&quot;-1&quot;&gt;eBPF-Style JIT Compilation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#ebpf-style-jit-compilation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For ultimate performance with safety:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Hypothetical plugin JIT system&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; plugin_bytecode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;load_plugin_bytecode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;rust-plugin.bc&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; jit_compiler &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PluginJIT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; compiled_plugin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; jit_compiler&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin_bytecode&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Near-native performance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Safety through bytecode verification&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Platform optimization opportunities&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Extremely complex to implement&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Limited ecosystem and tooling&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;High development cost&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are most of the ways, but even so gives us a glimpse into what’s possible and borderline best practice. However, it still doesn’t answer all the questions we’ve. Your decision to which plugin system works for you can be very personal at the same time very divided. Perhaps a combination of these work for you.&lt;/p&gt;
&lt;h2 id=&quot;open-questions-and-considerations&quot; tabindex=&quot;-1&quot;&gt;Open Questions and Considerations &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#open-questions-and-considerations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Building plugin systems in Rust raises several interesting questions:&lt;/p&gt;
&lt;h3 id=&quot;performance-vs.-safety-trade-offs&quot; tabindex=&quot;-1&quot;&gt;Performance vs. Safety Trade-offs &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#performance-vs.-safety-trade-offs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;FFI approaches prioritize performance over safety. We’re essentially trusting plugin authors not to cause memory safety issues. Alternative approaches like WASI or subprocess isolation provide better safety guarantees but at a performance cost.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: In systems like build tools where performance matters, how much safety are you willing to trade for speed?&lt;/p&gt;
&lt;h3 id=&quot;api-evolution-and-compatibility&quot; tabindex=&quot;-1&quot;&gt;API Evolution and Compatibility &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#api-evolution-and-compatibility&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Plugin APIs need to evolve, but external plugins create compatibility challenges.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: How do you handle API breaking changes when external plugins may not update immediately? Should there be a plugin API versioning system?&lt;/p&gt;
&lt;h3 id=&quot;distribution-and-discovery&quot; tabindex=&quot;-1&quot;&gt;Distribution and Discovery &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#distribution-and-discovery&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Using existing package systems like &lt;a href=&quot;http://crates.io/&quot;&gt;crates.io&lt;/a&gt; has limitations - no way to mark crates as tool-specific plugins, no plugin-specific metadata, etc.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Should specialized tools have their own plugin registries, or is it better to piggyback on existing package systems?&lt;/p&gt;
&lt;h3 id=&quot;testing-and-quality-assurance&quot; tabindex=&quot;-1&quot;&gt;Testing and Quality Assurance &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#testing-and-quality-assurance&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;External plugins can break in ways that are hard to test. A plugin might work fine until it encounters a specific project structure or environment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: What’s the right balance between trusting plugin authors and providing safety rails? Should there be automated testing requirements for plugins?&lt;/p&gt;
&lt;h3 id=&quot;plugin-composition-and-dependencies&quot; tabindex=&quot;-1&quot;&gt;Plugin Composition and Dependencies &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rust-plugin-system/#plugin-composition-and-dependencies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Currently, most plugin systems have isolated plugins. But what if plugins could build on each other?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: How complex should plugin systems be? Is composition worth the added complexity?&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://nullderef.com/img/CoM36VEtZL-600.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Here’s also a nice &lt;a href=&quot;https://nullderef.com/series/rust-plugins/&quot;&gt;series&lt;/a&gt; you can follow.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There’s no “right” answer for plugin systems in Rust - only trade-offs that align with your specific needs. Different use cases call for different approaches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A text editor might prioritize safety and choose WASI plugins&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A data processing pipeline might choose gRPC for language flexibility&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A performance-critical system might go with JIT compilation despite the complexity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A build tool might accept FFI trade-offs for performance and simplicity&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The key is understanding your constraints and making conscious trade-offs rather than accidentally falling into them.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Why I&#39;m Switching SOT to uv</title>
		<link href="https://blog.anirudha.dev/sot-on-uv/"/>
		<updated>2025-08-24T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/sot-on-uv/</id>
		<content type="html">&lt;p&gt;I’ve migrated the &lt;a href=&quot;https://github.com/anistark/sot/&quot;&gt;SOT&lt;/a&gt; (System Observation Tool) project from traditional pip/venv workflows to &lt;a href=&quot;https://github.com/astral-sh/uv&quot;&gt;uv&lt;/a&gt;, Astral’s blazing-fast Python package manager. This is gonna be a game-changer for both contributors and users.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Maybe I was just finding an excuse to use something from F1 movie fever. But speed is about performance as much as it’s about being quick.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;10-100x faster dependency resolution and installation&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;pip install&lt;/code&gt; for our dev dependencies: &lt;strong&gt;~45&lt;/strong&gt; seconds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv sync&lt;/code&gt; --dev: &lt;strong&gt;~3&lt;/strong&gt; seconds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cold cache package installation improved by 15x on average&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lockfile generation performance:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;pip-tools pip-compile&lt;/code&gt;: ~12 seconds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv lock&lt;/code&gt;: ~800ms&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/83b37323-c78a-4cf7-b2cf-b2c7b74f04f0.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This isn’t just benchmark flaunting, these improvements compound during development, CI/CD, and Docker builds. In addition to an actually reliable dependency resolution.&lt;/p&gt;
&lt;p&gt;Which then brings us to an universal resolution across platforms. &lt;code&gt;uv&lt;/code&gt; resolves dependencies for all target platforms simultaneously. No more &lt;em&gt;“works on my Linux but breaks on macOS”&lt;/em&gt; surprises Single &lt;code&gt;uv.lock&lt;/code&gt; replaces platform-specific requirements files. Most importantly, better conflict detection. Someone told me once fail loudly always. I kinda took it to heart, and so did &lt;code&gt;uv&lt;/code&gt;. All for improving developer experience. A single command covers most of them,which we handled via justfile earlier.&lt;/p&gt;
&lt;terminal-block&gt;uv sync --dev&lt;/terminal-block&gt;&lt;p&gt;Workspace management without the pain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;No more source venv/bin/activate dance&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv run python script.py&lt;/code&gt; works from any directory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Built-in tool isolation: &lt;code&gt;uv tool install sot&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;technical-architecture-benefits&quot; tabindex=&quot;-1&quot;&gt;Technical Architecture Benefits &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/sot-on-uv/#technical-architecture-benefits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This tool is &lt;strong&gt;Rust-native&lt;/strong&gt;.&lt;br /&gt;
It’s written in Rust, not Python, which means there’s no Python bootstrap overhead. Installs and downloads run in parallel, and dependency resolution is memory-efficient.&lt;/p&gt;
&lt;p&gt;It’s also &lt;strong&gt;pip/PyPI compatible&lt;/strong&gt;.&lt;br /&gt;
So it’s a drop-in replacement for pip workflows. It uses the existing PyPI infrastructure and supports all pip-compatible packages. No ecosystem fragmentation.&lt;/p&gt;
&lt;p&gt;Finally, it has &lt;strong&gt;advanced caching&lt;/strong&gt;.&lt;br /&gt;
There’s a global package cache with deduplication, network-aware caching strategies, incremental lockfile updates, and cross-project dependency sharing.&lt;/p&gt;
&lt;h3 id=&quot;project-specific-improvements&quot; tabindex=&quot;-1&quot;&gt;Project-Specific Improvements &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/sot-on-uv/#project-specific-improvements&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;CI/CD is simpler.&lt;/strong&gt;&lt;br /&gt;
Before: multiple cache keys, complex setup with &lt;code&gt;actions/setup-python&lt;/code&gt; and &lt;code&gt;actions/cache&lt;/code&gt;.&lt;br /&gt;
After: one command &lt;code&gt;uv sync --dev&lt;/code&gt; handles caching and installs automatically.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Development is smoother.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv add package&lt;/code&gt; for instant dependency addition&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv tree&lt;/code&gt; for dependency visualization&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;uv lock --upgrade&lt;/code&gt; for controlled updates&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Hot-swappable dev dependencies&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;for-contributors&quot; tabindex=&quot;-1&quot;&gt;For Contributors &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/sot-on-uv/#for-contributors&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Faster feedback loops&lt;/strong&gt;: quicker setup, faster CI, smoother PR iterations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fewer environment issues&lt;/strong&gt;: deterministic builds, no dependency hell, consistent tool versions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Better dependency management&lt;/strong&gt;: clear upgrades, easy dev testing, safe removals&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;getting-started&quot; tabindex=&quot;-1&quot;&gt;Getting Started &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/sot-on-uv/#getting-started&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For end users:&lt;/p&gt;
&lt;terminal-block&gt;uv tool install sot&lt;/terminal-block&gt;&lt;p&gt;For contributors:&lt;/p&gt;
&lt;terminal-block&gt;git clone https://github.com/anistark/sot.git
cd sot
uv sync --dev
# You&#39;re ready to code&lt;/terminal-block&gt;&lt;p&gt;The migration maintains full backward compatibility. Existing &lt;code&gt;pip&lt;/code&gt; workflows still work, but &lt;code&gt;uv&lt;/code&gt; offers a superior developer experience with tangible performance benefits.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;uv&lt;/code&gt; isn’t just faster. It’s fundamentally more reliable, making our development process more predictable and our contributors more productive.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Migration completed in &lt;a href=&quot;https://github.com/anistark/sot/pull/18&quot;&gt;[PR #18]&lt;/a&gt; and available on &lt;a href=&quot;https://pypi.org/project/sot/4.4.0/&quot;&gt;sot v4.4.0&lt;/a&gt; onwards. Questions or issues? Open an &lt;a href=&quot;https://github.com/anistark/sot/issues&quot;&gt;issue&lt;/a&gt; or &lt;a href=&quot;https://github.com/anistark/sot/discussions&quot;&gt;discussion&lt;/a&gt;.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>At the mercy of AI</title>
		<link href="https://blog.anirudha.dev/at-the-mercy-of-ai/"/>
		<updated>2025-08-18T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/at-the-mercy-of-ai/</id>
		<content type="html">&lt;p&gt;It’s the 2020s, and we’re all living in a world where the phrase &lt;em&gt;“just ask the AI”&lt;/em&gt; has replaced &lt;em&gt;“let me Google that”.&lt;/em&gt; From product design to poetry, from diagnosing diseases to picking your next Netflix binge, AI is no longer a tool we occasionally refer to. It’s the invisible co-pilot running the plane, the ship, and sometimes the planet.&lt;/p&gt;
&lt;p&gt;We are, in many ways, at the mercy of it. And mercy is a funny thing. It can be a blessing… or a warning!&lt;/p&gt;
&lt;h2 id=&quot;the-age-of-the-prompt&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Age of the Prompt&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/at-the-mercy-of-ai/#the-age-of-the-prompt&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Do you remember a time, when software was built by writing long lines of code, painstakingly tested by humans, and released with the slow, deliberate pride of a craftsman? Now? Much of the next generation of software isn’t “written” so much as &lt;em&gt;requested&lt;/em&gt; from an AI model. The magic phrase isn’t an algorithm, it’s a prompt.&lt;/p&gt;
&lt;p&gt;Want a new marketing campaign? Tell the AI: “Make it sound like Steve Jobs meets Shakespeare on a coffee bender.” Need a new app? “Write a Python script that tracks my cat’s mood and syncs it to Spotify.”&lt;/p&gt;
&lt;p&gt;It’s fast, powerful, and let’s admit it, super addictive. But there’s a quiet shift happening: the people who know &lt;em&gt;what&lt;/em&gt; to ask and &lt;em&gt;how&lt;/em&gt; to ask it hold the real power. This is the age of &lt;em&gt;prompt engineering&lt;/em&gt;, and it’s shaping the products, culture, and even the politics of tomorrow. Once what was fun and games, has now turned into a harsh reality. I tried vibe coding too last year using some popular tools like lovable and v0. Incredible results! It generated entire websites with sections that I had not even mentioned or thought of up until that point. It was too good to be true at first glance. I tried a few more options and all were crazy smooth. I heard a gear shift in my head and went full blown into it. The results are great sometimes. Most times, it does small errors. At one point, I was only fixing bugs that my AI generated and onto next prompt. It would have actually been faster if I wrote it myself though. But I was already hooked. And then it hit me.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/9b149691-014c-4954-a6be-87df1ae06e4e.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This quote is true on so many levels as well and we’re hooked. In a world hooked already on AI tools, all other tools have lost it’s charm. We rarely open Google now, we go to chatgpt or perplexity. We don’t open any normal IDE now, it has to be Claude powered. And why won’t you? Everyone else is doing it. If you don’t, you’re just falling behind. We’re so blindly going at it, that we’ve stopped questioning things. Soon, we might not know what a cat actually looks like and rely on whatever our AI tells us. It’s not all bad of course. A lot of task handling stuff have gotten really good too. Vibe coding has a good side as well, makes you faster and better documented. &lt;em&gt;Nobody like docs like AI does!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let’s consider a fork in the path ahead. AI, like fire, can cook your dinner or burn down your house. Let’s take a peek at both possible timelines.&lt;/p&gt;
&lt;h3 id=&quot;the-dystopian-dumpster-fire&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Dystopian Dumpster Fire&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/at-the-mercy-of-ai/#the-dystopian-dumpster-fire&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It starts slowly. First, your favorite news site replaces most of its journalists with AI writers. Cheaper, faster, 24/7 content. At first, you barely notice. The headlines are punchy, the stories flow smoothly. But after a while, you realize you’re reading the same turns of phrase everywhere, as if the entire internet has developed one eerily consistent voice. The AI voice! It doesn’t even matter if it’s actually true, fact checked. You believe what you’re reading, seeing, hearing. That’s what our past 10,000 years or so of existence have trained us for.&lt;/p&gt;
&lt;p&gt;Your morning routine changes too. You no longer choose what to wear, your AI assistant, synced to your wardrobe, calendar and the weather, lays it out for you. You don’t pick your own meals, your health-optimization AI decides the “ideal” menu. You don’t even write birthday messages, your AI drafts them in your “tone” and sends them out. People thank you for your heartfelt words, but you don’t remember saying them. All your shit posts are now done by AI too. All your selfies, friends hanging out, vacation pictures are now all generated by AI, indistinguishable from reality as you’re unaware and chilling at some secluded location.&lt;/p&gt;
&lt;p&gt;At work, creativity doesn’t mean brainstorming, it means telling the AI what you want and waiting for it to generate something “good enough”. Marketing campaigns? Done in 3 minutes. Product designs? One prompt away. Eventually, “good enough” becomes the gold standard, because why spend extra time when the AI’s version passes the tests? You get to go home early, maybe catch that happy hour finally, spend more time with your friends and family. “Good enough” made all of it possible afterall.&lt;/p&gt;
&lt;p&gt;Schools shift too. Kids submit AI-polished essays indistinguishable from one another. Teachers use AI to grade them. Learning becomes a loop of machines producing work for machines to evaluate. Students still “learn”, technically, but their ability to think independently, to wrestle with ambiguity, starts to drain out into nothingness.&lt;/p&gt;
&lt;p&gt;And slowly, almost imperceptibly, the edges of human originality blur away. Every movie feels like a mash-up of the last 50 hits. Every song seems to have the same mathematically perfect chord progression. Every opinion you read feels like it was optimized for engagement, not truth.&lt;/p&gt;
&lt;p&gt;The worst part? We stop noticing. We stop &lt;em&gt;wanting&lt;/em&gt; to notice. Because the AI makes life frictionless and friction is exhausting. The mental muscles that make us question, imagine, and create quietly wither away. We’re comfortable. We’re entertained. We’re efficient. And we become empty.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/bb15defa-1fae-48e0-bb32-d3619e11d74b.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-renaissance-2.0&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Renaissance 2.0&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/at-the-mercy-of-ai/#the-renaissance-2.0&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It starts with one moment of magic. Someone, somewhere, uses AI to bring an impossible idea to life. A teenager in rural India, with no formal art training, creates a breathtaking animated film that wins awards at international festivals. A small-town baker in Italy uses AI to design recipes that blend centuries-old techniques with new flavor combinations, putting her village on the map. A disabled musician composes an entire symphony with the help of AI-powered instruments that adapt to his movement patterns.&lt;/p&gt;
&lt;p&gt;The tools are everywhere, and they’re cheap enough that anyone can use them. The barrier between “I wish I could” and “I made this” collapses. Want to build a video game? AI helps you code and design in weeks, not years. Have a story idea but no writing experience? The AI helps you draft, edit, and publish while still letting your unique voice shine through.&lt;/p&gt;
&lt;p&gt;Workplaces hum with possibility. Instead of drowning in repetitive tasks, people spend their days solving problems, experimenting, collaborating across continents in real time. AI translates languages instantly, making cross-cultural projects effortless. The office “productivity suite” isn’t just a set of tools it’s an intelligent creative partner that suggests connections you hadn’t imagined. Write docs? Create pipelines? Review PRs? Done in seconds. You can back to iterating, working on feedbacks and building your product.&lt;/p&gt;
&lt;p&gt;Education transforms. Students use AI as a tutor that adapts to their learning style, explains concepts in ten different ways, and never loses patience. Language barriors disappear and any subject just is a click away. Classrooms become workshops of invention, where kids design robots, write plays, and create documentaries before they turn 15. AI isn’t the shortcut, it’s the scaffolding that helps them climb higher. Experience gaining becomes second nature as compared to doing the boring tasks.&lt;/p&gt;
&lt;p&gt;Culture explodes into diversity. Films, music, books, and games are no longer bottlenecked by big studios or record labels. The market isn’t dominated by a handful of companies. It’s alive, breathing with creators from every corner of the globe, each using AI to amplify their own distinct style.&lt;/p&gt;
&lt;p&gt;And the thing that makes this future special isn’t the technology, it’s the fact that humanity learns to keep hold of the steering wheel. We remember that AI is a brush, not the painter. An instrument, not the musician. We let it extend our reach without dulling our fingerprints. We learn to weild this new sword in a way to charge forward, not settle down with.&lt;/p&gt;
&lt;p&gt;This is a world that feels alive, unpredictable, and brimming with wonder. A place where AI hasn’t replaced the human spark, but fanned it into a wildfire.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/7725c2c5-0a1b-46d3-9bf1-2dca4fb52f79.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The road to the better future isn’t just paved with fancy algorithms, it’s built through choices, habits, and the willingness to stay awake at the wheel while AI drives alongside us. The easiest trap is to assume, “Well, the machines are smarter now, so we can relax.” That’s the same logic sailors used when GPS became a thing, until ships started running aground because nobody remembered how to read a map.&lt;/p&gt;
&lt;p&gt;The first step is simple but essential, &lt;strong&gt;keep humans in the loop.&lt;/strong&gt; Autopilot can guide a plane, but no one in their right mind would trust it alone in a thunderstorm without a pilot ready to take over. In the same way, AI can help us design, diagnose, or decide, but the final call has to rest with a thinking, feeling human who can weigh context, nuance, and ethics in ways an algorithm can’t.&lt;/p&gt;
&lt;p&gt;Then there’s &lt;strong&gt;building with ethics baked in&lt;/strong&gt;, not sprinkled on as an afterthought. Think of it like constructing a bridge, you wouldn’t pour the foundation and then, halfway through, decide “Oh right, safety railings.” We’ve already seen what happens when technology races ahead without ethical guardrails. Social media algorithms optimized for engagement gave us a decade of outrage cycles, misinformation, and culture wars. We cannot repeat that mistake at AI speed.&lt;/p&gt;
&lt;p&gt;Just as important is &lt;strong&gt;teaching prompt literacy&lt;/strong&gt;, the new universal skill. Just like reading and writing became survival skills in the industrial age, knowing how to communicate with AI will become as essential as knowing how to search the web today. If you can’t speak the language of prompts, you’re locked out of the most powerful tools of our time. Schools, universities, and even workplaces need to treat prompt fluency as part of digital literacy, not as some niche skill for techies. LEARN TO DRIVE!&lt;/p&gt;
&lt;p&gt;And finally, &lt;strong&gt;we must celebrate human originality&lt;/strong&gt;. Fiercely! The temptation will always be to let AI do “most” of the work, smoothing edges and optimizing ideas until they’re safe, predictable, and ironically forgettable. But the greatest cultural moments in history weren’t optimized. They were bold, messy, and personal. People still read Shakespeare not because he was flawless, but because he was human. The future we want is one where AI makes us more &lt;em&gt;ourselves&lt;/em&gt;, not less. Losing that acute unique perspective is when we start spelling out doom. We stop at the edge of utopia and wonder if it’s dystopia.&lt;/p&gt;
&lt;p&gt;If we can hold onto these principles, we’re not just “using” AI, we’re shaping the world it will help create.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.worldhistory.org/img/c/p/1600x900/13067.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It’s easy to think what’s happening now is unprecedented, but humanity has been here before, staring at a new invention with equal parts awe and terror. Perhaps the closest parallel to AI’s disruption is the invention of the &lt;strong&gt;printing press&lt;/strong&gt; in the mid-1400s.&lt;/p&gt;
&lt;p&gt;Before Gutenberg, books were hand-copied by scribes, often monks, working in silence for months, sometimes years, on a single manuscript. Knowledge was literally locked in the hands of a few, and access to it was as much about privilege as it was about curiosity. Most people could not read. Most people had never owned a book. And most ideas never spread beyond the walls where they were written. Hard to imagine you having to wait for a new chapter on your ipad or kindle when your friend already had it months before, isn’t it?&lt;/p&gt;
&lt;p&gt;Then, in 1450, Johannes Gutenberg introduced a machine that could print multiple pages at once, using movable metal type. Suddenly, a book that might have taken a year to copy could be reproduced in days. The &lt;strong&gt;Bible&lt;/strong&gt; was one of the first major works to be printed, and that alone caused a cultural earthquake. For the first time, ordinary people could own a copy of a sacred text. For the first time, they could read and interpret it themselves, without the mediation of the Church.&lt;/p&gt;
&lt;p&gt;That shift was revolutionary and dangerous to the powers of the time. Within decades, the printing press became the engine of the &lt;strong&gt;Reformation&lt;/strong&gt;, as Martin Luther’s 95 Theses were printed and distributed across Europe, fueling religious upheaval. It became the megaphone of the &lt;strong&gt;scientific revolution&lt;/strong&gt;, spreading the works of Copernicus and Galileo. It even fueled wars and political unrest, as pamphlets became the social media of the 16th and 17th centuries, spreading radical and sometimes dangerous ideas at unprecedented speed.&lt;/p&gt;
&lt;p&gt;But it also democratized learning. Literacy rates soared. New ideas crossed borders faster than armies could march. The Renaissance, which had been a slow simmer, began to boil over. By the 18th century, the Enlightenment thinkers, Voltaire, Rousseau, Locke were all children of print culture, using the press to spread philosophies that would reshape governments and revolutions.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The printing press didn’t just change the tools, it changed the &lt;em&gt;mental furniture&lt;/em&gt; of civilization. We went from a world where knowledge was scarce and guarded, to one where ideas could be multiplied, challenged, and improved.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And here’s the twist: the printing press didn’t guarantee a utopia. It gave us the &lt;strong&gt;Scientific Method&lt;/strong&gt; and the &lt;strong&gt;French Revolution&lt;/strong&gt;. But it also gave us the rapid spread of propaganda, pseudoscience, and conspiracy theories (sound familiar?). It was not inherently good or bad. It was a mirror that reflected the best and worst of human nature, only faster.&lt;/p&gt;
&lt;p&gt;AI is our modern printing press, capable of multiplying not just words, but &lt;em&gt;thoughts&lt;/em&gt;, &lt;em&gt;images&lt;/em&gt;, &lt;em&gt;ideas&lt;/em&gt;, and &lt;em&gt;decisions&lt;/em&gt;. The question is not whether it will change us, it already has. The real question is whether we can steer that change toward a Renaissance, or whether we’ll repeat the mistakes of history at a speed that makes them irreversible.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://images-prod.dazeddigital.com/355/azure/dazed-prod/1240/9/1249323.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We &lt;em&gt;are&lt;/em&gt; at the mercy of AI, in the same way humanity has always been at the mercy of its greatest inventions. But mercy isn’t submission, it’s stewardship. If we remain passive, we drift toward the dumpster fire. If we stay engaged, curious, and critical, we could be steering toward the most creative and connected era in history.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The question isn’t whether AI will change our world. It already has.&lt;br /&gt;
The real question is: &lt;strong&gt;Will we still recognize ourselves in the world it creates?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/f6588827-8004-499d-baa3-54ef5b2ab307.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A silent revolution is upon us! Are you ready?&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Making Chakra Modular</title>
		<link href="https://blog.anirudha.dev/making-chakra-modular/"/>
		<updated>2025-06-22T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/making-chakra-modular/</id>
		<content type="html">&lt;p&gt;For the past few weeks since the first public release of &lt;a href=&quot;https://github.com/anistark/chakra&quot;&gt;Chakra&lt;/a&gt;, I’ve been really thinking about what the next right step for it is. I felt like driving myself into an overthinking well of right and wrong directions, I eneded up doing random stuff and going back and forth on updates. Also, not coding as consistently.&lt;/p&gt;
&lt;p&gt;The wasm ecosystem has really taken into the browser side of stuff while the server side is ignored. The client side wasm vm is an ideal playground, but it lacks heavy firepower. I can only hope a server side runtime can bring in that firepower. From a developer’s standpoint, I’d see Chakra as a runtime that we can use to build, test, debug and iterate fast. While compiled languages are great and perfect for wasm, it’s a nightmare for developments. I think some of it has been already done with some amazing projects. I personally love wasmtime, wasmer, wazero and trunk. All of them are great runtimes and perform best in their own arena. Wasmer I feel is more aligned to my thought process, while I can’t relate to how the architecture of wasmer has been like. That was a major reason to build Chakra.&lt;/p&gt;
&lt;p&gt;This article isn’t to cover the shortcomings of other tools or frameworks but figure out a direction for Chakra. so, bear with me…&lt;/p&gt;
&lt;p&gt;The compiler part of it, can be better done by other languages, and shouldn’t be a part of chakra at all. It anyway wasn’t meant to stay inside Chakra at all. So, I’m making plugins and moving all compiler languages to built-in plugins to begin with. Slowly, each of them would be made into external plugins. &lt;em&gt;Use what you want, not what’s shipped!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Next, I want to push for more modular architecture. WASI is great and needs to be integrated. But I tried to run a server side web app and serve it wasm vm. The approach needs further work in a way, that the i/o for dev tool and production build are separated out. We definetly don’t need the same stuff as long as the compiled wasm runs for both. At the moment, we need to load the entire wasi implementation, which is quite a huge file. Pyodide, py2wasm and all other tools that currently support WASI work in similar way. This is extrememly inefficient cause of the huge number of exports we’ve to deal with. For now, Chakra avoids it by loading a custom wasi implementation, so the exports can be avoided. But the entire wasi implementation still needs to be put up. So, we need to take another look at packaging before we come back to client side building. Something perhaps that while AOT is running, adds implementation alongside of it, like a true rust plugin. Perhaps we can build a dynamic implementation system. Might need more than a pipe dream.&lt;/p&gt;
&lt;p&gt;Finally, serving web apps. Trunk does an amazing job with serving web apps for yew, leptos, dioxus, etc rust frameworks. But it’s still far behind node, webpack or even air in go from a dev experience perspective. Of course the web app frameworks also need to get updated. Chakra web apps are currently served in a similar way. We do server side rendering (SSR) and open up a port for the browser to load the webapp on. Of course, there was a few issues in the initial version of it with not loading css. But in the new version, it’s not working at all. Will need to rethink the SSR approach more. But for the time being, I believe, it can be done by simply creating a trunk wrapper plugin for chakra.&lt;/p&gt;
&lt;p&gt;So, these are my thoughts at the moment for future of WASM and Chakra. There’s more to come. Keep an eye out on the github repo. Will keep it open under MIT license and will be more discussions in the future.&lt;/p&gt;
&lt;p&gt;Our next upcoming release &lt;a href=&quot;https://github.com/anistark/chakra/releases/tag/v0.9.6&quot;&gt;v0.9.6&lt;/a&gt; will showcase the first modular plug-in architecture for Chakra. ✨&lt;/p&gt;
&lt;p&gt;Also, should we’ve a chat forum or mailing list for wasm and chakra updates? IRC is dead I guess.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Chakra: A Wasm Runtime</title>
		<link href="https://blog.anirudha.dev/chakra/"/>
		<updated>2025-05-25T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/chakra/</id>
		<content type="html">&lt;p&gt;The modern software landscape is shifting rapidly towards &lt;strong&gt;portability&lt;/strong&gt;, &lt;strong&gt;performance&lt;/strong&gt;, and &lt;strong&gt;sandboxed execution&lt;/strong&gt;. At the heart of this transformation is &lt;strong&gt;WebAssembly (Wasm)&lt;/strong&gt;. &lt;em&gt;A low-level binary instruction format that allows code written in multiple languages to run safely and efficiently across environments.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Initially built for the browser, Wasm is now powering:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🔌 Plugin systems&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🧠 AI agents and edge runtimes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🖥️ Serverless functions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🎮 Cross-platform games&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📱 Portable desktop/mobile apps&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As covered in &lt;a href=&quot;https://blog.anirudha.dev/wasm-landscape&quot;&gt;The WebAssembly Odyssey&lt;/a&gt;, Wasm is becoming the standard for execution in the age of decentralization, polyglot development, and composable software.&lt;/p&gt;
&lt;h2 id=&quot;wasm-today&quot; tabindex=&quot;-1&quot;&gt;Wasm Today &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#wasm-today&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wasm’s language-agnostic nature makes it accessible from many ecosystems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rust&lt;/strong&gt;: Via &lt;code&gt;wasm-bindgen&lt;/code&gt;, &lt;code&gt;wasmer&lt;/code&gt;, &lt;code&gt;wasmtime&lt;/code&gt;, and &lt;code&gt;cargo build --target wasm32-unknown-unknown&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Go&lt;/strong&gt;: Via &lt;code&gt;tinygo&lt;/code&gt; and official support for &lt;code&gt;wasip1&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;C/C++&lt;/strong&gt;: Via &lt;code&gt;Emscripten&lt;/code&gt; and Clang toolchains&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript&lt;/strong&gt;: A TypeScript-like language targeting Wasm directly&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But developing, testing, and running Wasm modules still involves a mix of fragmented tools, runtimes, and platforms.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%A6%80-rust&quot; tabindex=&quot;-1&quot;&gt;🦀 Rust &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%A6%80-rust&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Rust is hands-down one of the most mature and performance-friendly options for compiling to Wasm. The tooling specially &lt;code&gt;wasm-bindgen&lt;/code&gt;, &lt;code&gt;wasm-pack&lt;/code&gt;, and &lt;code&gt;cargo&lt;/code&gt; integration makes it relatively easy to write code that compiles cleanly to &lt;code&gt;.wasm&lt;/code&gt; binaries. It’s the go-to choice for developers building serious performance-critical apps in the browser or on the edge. Plus, the safety guarantees of Rust carry over nicely into the Wasm sandbox. That said, dealing with bindings specially JavaScript interop can still be fiddly, and debugging Wasm modules from Rust isn’t always seamless. Afterall who wants to deal with a whole suite of outputs when all you need is a simple &lt;code&gt;.wasm&lt;/code&gt; file.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%90%B9-go-(and-tinygo)&quot; tabindex=&quot;-1&quot;&gt;🐹 Go (and TinyGo) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%90%B9-go-(and-tinygo)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Go has official Wasm support through &lt;code&gt;GOARCH=wasm&lt;/code&gt;, but the real star for WebAssembly is &lt;a href=&quot;https://tinygo.org/&quot;&gt;&lt;strong&gt;TinyGo&lt;/strong&gt;&lt;/a&gt;. It’s a stripped-down Go compiler built specifically for embedded systems and Wasm, and it produces much smaller binaries than the standard Go toolchain. TinyGo shines in lightweight environments specially when building Wasm for microcontrollers or edge runtimes with tight constraints. The downside? You lose some language features like full reflection, and TinyGo’s support for newer Go features tends to lag behind the mainline compiler. Also, working with system-level capabilities in Wasm through Go is still evolving, specially in WASI contexts.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%A7%B1-assemblyscript&quot; tabindex=&quot;-1&quot;&gt;🧱 AssemblyScript &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%A7%B1-assemblyscript&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you’re coming from a TypeScript background, AssemblyScript feels like a friendly on-ramp to Wasm. It’s essentially a subset of TypeScript that compiles to WebAssembly with minimal fuss. You can write near-Wasm-level code without jumping into Rust or C++. This makes AssemblyScript great for writing plugins or extensions in JavaScript-heavy ecosystems. But the tooling is less mature, debugging support is basic, and because it’s not the full TypeScript spec, you might hit limitations or surprises if you’re expecting all JS/TS behavior to carry over. Of course not all dynamic functionalities of js/ts are still supported and you’d need to use external js/ts still for those features. Still, for rapid prototyping and smaller modules, AssemblyScript hits a nice sweet spot.&lt;/p&gt;
&lt;h3 id=&quot;%E2%9A%99%EF%B8%8F-c-and-c%2B%2B&quot; tabindex=&quot;-1&quot;&gt;⚙️ C and C++ &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%E2%9A%99%EF%B8%8F-c-and-c%2B%2B&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The OGs of systems programming have been compiling to Wasm for a while now, mostly via &lt;a href=&quot;https://emscripten.org/&quot;&gt;&lt;strong&gt;Emscripten&lt;/strong&gt;&lt;/a&gt;, a powerful but somewhat heavyweight toolchain that turns C/C++ code into &lt;code&gt;.wasm&lt;/code&gt; along with glue code. You’ll see this in action in big efforts like porting game engines (think Doom or Unreal) or emulators to run in the browser. C/C++ to Wasm is fast, but the learning curve around toolchains, memory management, and glue code can be steep. And without careful tuning, you might end up with massive Wasm binaries full of unused system libraries. Emscripten is great when you &lt;em&gt;need&lt;/em&gt; that level of control, but it’s not exactly plug-and-play, specially if you’re not on a linux machine. I had to install 4 different packages to just get it to run.&lt;/p&gt;
&lt;h3 id=&quot;wasm-runtimes-and-where-they-fit&quot; tabindex=&quot;-1&quot;&gt;Wasm Runtimes and Where They Fit &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#wasm-runtimes-and-where-they-fit&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Compiling to Wasm is just the first half of the journey. The other half is figuring out &lt;strong&gt;how to run it&lt;/strong&gt;. That’s where runtimes come in.&lt;/p&gt;
&lt;p&gt;Today, we have a handful of mature and battle-tested runtimes like &lt;a href=&quot;https://github.com/bytecodealliance/wasmtime&quot;&gt;&lt;strong&gt;Wasmtime&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://wasmer.io/&quot;&gt;&lt;strong&gt;Wasmer&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/tetratelabs/wazero&quot;&gt;&lt;strong&gt;Wazero&lt;/strong&gt;&lt;/a&gt;, and &lt;a href=&quot;https://v8.dev/&quot;&gt;&lt;strong&gt;V8&lt;/strong&gt;&lt;/a&gt;. Each of them targets different goals. Some are optimized for embedding, some for server-side, and others for full sandboxed environments. But none of them are perfect, and each comes with trade-offs that show up fast when you’re trying to build real-world systems.&lt;/p&gt;
&lt;h4 id=&quot;wasmtime&quot; tabindex=&quot;-1&quot;&gt;Wasmtime &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#wasmtime&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Wasmtime is one of the most respected Wasm runtimes out there, maintained by the Bytecode Alliance (the same people behind &lt;a href=&quot;https://wasi.dev/&quot;&gt;WASI&lt;/a&gt;). It’s written in Rust, super fast, and very WASI-compliant. It excels in scenarios where performance and standards compliance matter, like cloud-native environments or sandboxed serverless functions. It also has solid support for features like component model and interface types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Where it falls short&lt;/strong&gt; is accessibility and extensibility. If you’re building something experimental or need to integrate Wasm into a non-standard context (like a desktop sandbox or local-first P2P system), Wasmtime can feel overengineered. The API is powerful but dense. The project is heavily geared toward large-scale production deployments and tends to move slowly on more community-driven, experimental ideas. It’s not the friendliest tool if you’re just trying to embed a runtime into a minimal app or CLI tool.&lt;/p&gt;
&lt;h4 id=&quot;wasmer&quot; tabindex=&quot;-1&quot;&gt;Wasmer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#wasmer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Wasmer also comes from the Rust world, but it has a different vibe. Wasmer is built with embedding in mind and comes with bindings for a bunch of languages like Python, Ruby, PHP, JavaScript, etc. It aims to be the “Docker of Wasm”. You can distribute and run Wasm modules using &lt;code&gt;wasmer run&lt;/code&gt; just like Docker containers. This is great for plugin architectures, lightweight apps, and scripting environments.&lt;/p&gt;
&lt;p&gt;But Wasmer has &lt;strong&gt;its own complexity tax&lt;/strong&gt;. The tooling is inconsistent, the documentation has gaps, and its performance can vary depending on which backend you choose (Cranelift, LLVM, Singlepass). Features like WASIX (Wasmer’s extended WASI for more POSIX-like behavior) are powerful but fragmented and not part of the core Wasm spec. You would also need a separate docker for &lt;a href=&quot;https://nuitka.net/&quot;&gt;nuitka&lt;/a&gt; to compile python to wasm using py2wasm. Personal experience with &lt;a href=&quot;https://github.com/wasmerio/py2wasm&quot;&gt;py2wasm&lt;/a&gt; wasn’t so great but the team is dedicately working towards it and it’s currently the best tool out there hands-down. Debugging issues inside Wasmer can feel opaque, and versioning across plugins and toolchains isn’t always smooth. For all its ambition, Wasmer sometimes bites off more than it can chew.&lt;/p&gt;
&lt;h4 id=&quot;wazero&quot; tabindex=&quot;-1&quot;&gt;Wazero &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#wazero&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Wazero is a standout because it’s the only major Wasm runtime &lt;strong&gt;written entirely in Go&lt;/strong&gt;. That makes it ideal for Go-native applications that want to run Wasm without introducing foreign dependencies or FFI boundaries. It’s small, easy to embed, and has a clean API that fits nicely into idiomatic Go programs. It’s one of the best written runtimes I’ve seen.&lt;/p&gt;
&lt;p&gt;However, being Go-native is a double-edged sword. Wazero’s performance is good &lt;em&gt;for what it is&lt;/em&gt;, but it can’t compete with native runtimes like Wasmtime or Wasmer in terms of raw speed or compilation efficiency. And because it’s written in Go, it’s not always the right fit for systems built in Rust, C++, or other environments where bringing in a Go runtime would be awkward. WASI support is solid but not complete, and because it’s a relatively young project, some edge cases or advanced features (like multi-module linking or advanced debugging) may be limited.&lt;/p&gt;
&lt;h4 id=&quot;v8-(via-node.js-or-chrome)&quot; tabindex=&quot;-1&quot;&gt;V8 (via Node.js or Chrome) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#v8-(via-node.js-or-chrome)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;V8 is the JavaScript engine that powers Chrome and Node.js which also includes a mature WebAssembly engine. If you’re already in a JavaScript/TypeScript environment, running &lt;code&gt;.wasm&lt;/code&gt; inside V8 is the path of least resistance. The performance is excellent, and you get seamless interop with JavaScript, which is ideal for browser-based games, UI frameworks, or web-native compute modules.&lt;/p&gt;
&lt;p&gt;But V8 is &lt;strong&gt;not a general-purpose Wasm runtime&lt;/strong&gt;. It’s deeply tied to the JS ecosystem. You can’t use it easily outside of browser or Node contexts, and you don’t get any of the benefits of WASI. No filesystem, no networking, no standalone system features. You’re locked into the JS execution environment, which limits its usefulness for non-browser, non-serverless use cases. Embedding V8 is also no joke. It’s massive, memory-hungry, and incredibly hard to integrate into minimal or embedded applications.&lt;/p&gt;
&lt;p&gt;So where does that leave developers building Wasm-native applications, CLI tools, or experimental systems?&lt;/p&gt;
&lt;p&gt;Most existing runtimes are either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Too heavyweight and complex (Wasmtime, V8)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fragmented or unstable (Wasmer)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Tied to one language ecosystem (Wazero)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What’s missing is a &lt;strong&gt;lightweight, understandable, and extensible&lt;/strong&gt; runtime that developers can pick up, hack on, and make their own.&lt;/p&gt;
&lt;p&gt;That’s where Chakra enters the story.&lt;/p&gt;
&lt;h2 id=&quot;meet-chakra-%F0%9F%94%A5-one-runtime-to-run-%E2%80%98em-all&quot; tabindex=&quot;-1&quot;&gt;Meet Chakra 🔥 One Runtime to Run ‘em all &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#meet-chakra-%F0%9F%94%A5-one-runtime-to-run-%E2%80%98em-all&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://wazero.io/&quot;&gt;&lt;strong&gt;Chakra&lt;/strong&gt;&lt;/a&gt; is an open-source &lt;strong&gt;WebAssembly runtime&lt;/strong&gt; designed to unify and simplify the Wasm development and execution experience.&lt;/p&gt;
&lt;p&gt;Whether you’re a systems developer, an app builder, or just exploring Wasm for the first time, Chakra offers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🧩 &lt;strong&gt;Lightweight &amp;amp; modular&lt;/strong&gt; runtime for embedding and experimentation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🦀 &lt;strong&gt;Built in Rust&lt;/strong&gt; with performance and safety at its core&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🔐 &lt;strong&gt;Secure sandboxing&lt;/strong&gt; to isolate execution&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🖥️ &lt;strong&gt;CLI-first&lt;/strong&gt; for quick Wasm testing and automation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📦 &lt;strong&gt;WASI support (in progress)&lt;/strong&gt; for file, network, and system access&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🔄 &lt;strong&gt;Multi-language support&lt;/strong&gt;: One tool to run modules compiled from &lt;strong&gt;Rust, Go, AssemblyScript, and C/C++&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chakra isn’t just about running Wasm, it’s about making Wasm &lt;strong&gt;developer-friendly and extensible&lt;/strong&gt;. Basically, your go-to tool to get started with wasm, build something and finally deploy it. Chakra aims to cover the entire WASM Dev Tooling ecosystem. Quite ambitious, and of course will need lot of support from the community, as I want to build it with everyone.&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%A6%80-chakra-can-already-run-rust-web-projects&quot; tabindex=&quot;-1&quot;&gt;🦀 Chakra Can Already Run Rust Web Projects &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%A6%80-chakra-can-already-run-rust-web-projects&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Rust has emerged as one of the leading languages for building high-performance Wasm modules specially for web UIs using tools like &lt;code&gt;yew&lt;/code&gt;, &lt;code&gt;leptos&lt;/code&gt;, and &lt;code&gt;dioxus&lt;/code&gt;. Arguably can work as a potential replacement to JavaScript/TypeScript ecosystem entirely in the near future, and that’s saying something.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;With Chakra, you can already compile and run Rust-based Wasm projects with ease.&lt;/strong&gt; If your project is a rust web project, chakra will identify it and run it as a web app. This means Chakra can be integrated into your development workflow to &lt;strong&gt;test, debug, or embed&lt;/strong&gt; Rust logic, without setting up complex runtimes or containers.&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%8C%8D-one-runtime%2C-many-languages&quot; tabindex=&quot;-1&quot;&gt;🌍 One Runtime, Many Languages &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%8C%8D-one-runtime%2C-many-languages&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Unlike runtimes tied to a specific language or platform, Chakra is designed to be &lt;strong&gt;language-agnostic&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If you can compile it to Wasm, Chakra can run it. Currently supports four languages and python is in next step.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🦀 Rust&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🐹 Go (via TinyGo)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🧱 AssemblyScript&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🛠️ C/C++&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It aims to be the &lt;strong&gt;“one tool to run them all”&lt;/strong&gt;, streamlining execution across your entire stack, whether you’re building microservices, CLI tools, or local-first apps.&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%9A%80-what%E2%80%99s-next-for-chakra%3F&quot; tabindex=&quot;-1&quot;&gt;🚀 What’s Next for Chakra? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%9A%80-what%E2%80%99s-next-for-chakra%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chakra is just getting started. The future includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🧱 Full WASI support&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📡 Dynamic loading and linking&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🖥️ Web playground + desktop runner&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🔁 Live reload for rapid dev workflows&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📊 Better diagnostics and logging&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And most importantly…&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Chakra aims to become the &lt;strong&gt;go-to name for Wasm runtime and development&lt;/strong&gt;. The project is community-driven and open to &lt;strong&gt;any feature request or feedback&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/anistark/chakra/main/assets/loader.svg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%A4%9D-join-the-movement&quot; tabindex=&quot;-1&quot;&gt;🤝 Join the Movement &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chakra/#%F0%9F%A4%9D-join-the-movement&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’re passionate about WebAssembly, runtime design, developer tools, or just want to contribute to the open-source future of portable software:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;⭐ &lt;a href=&quot;https://github.com/anistark/chakra&quot;&gt;Star Chakra on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🧑‍💻 Try it out locally and run your first &lt;code&gt;.wasm&lt;/code&gt; file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🗣️ Open an issue with suggestions or bugs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📢 Spread the word and help grow the ecosystem&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;WebAssembly is the execution format of the modular web.&lt;br /&gt;
&lt;strong&gt;Chakra&lt;/strong&gt; is your runtime for that future.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let’s build it together. 💙&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Typed, Transpiled, Compiled</title>
		<link href="https://blog.anirudha.dev/js-ts-asc/"/>
		<updated>2025-05-14T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/js-ts-asc/</id>
		<content type="html">&lt;p&gt;If you’ve ever coded for the web, chances are you’ve touched &lt;strong&gt;JavaScript&lt;/strong&gt;. But as apps get more complex, you might run into its quirks. That’s where &lt;strong&gt;TypeScript&lt;/strong&gt; and &lt;strong&gt;AssemblyScript&lt;/strong&gt; come into play.&lt;/p&gt;
&lt;p&gt;It all began in the wild early days of the internet, back in &lt;strong&gt;1995&lt;/strong&gt;, when web pages were mostly just static documents. Plain text, maybe some images, and a lot of reloading. Netscape, one of the first web browsers, wanted to make the web more dynamic, so they asked a guy named &lt;strong&gt;Brendan Eich&lt;/strong&gt; to come up with a scripting language for browsers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/cccb751a-e5c6-4d96-adb5-b1d041e3c8c6.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Brendan, in what now sounds like a myth, wrote the first version of &lt;strong&gt;JavaScript&lt;/strong&gt; in just &lt;strong&gt;10 days&lt;/strong&gt;. It was a scrappy little language, originally called &lt;em&gt;Mocha&lt;/em&gt;, then &lt;em&gt;LiveScript&lt;/em&gt;, and finally &lt;em&gt;JavaScript&lt;/em&gt;. Not because it had much to do with Java, but because marketing thought the name sounded cool and can probably piggy back the popularity of Java. Brendan later founded &lt;strong&gt;Mozilla&lt;/strong&gt; and now &lt;strong&gt;Brave&lt;/strong&gt; browser.&lt;/p&gt;
&lt;p&gt;Despite its rushed beginnings and quirks, JavaScript exploded in popularity. It let developers add interactivity to websites. Things like pop-ups, form validation, dropdown menus, and animations. Over time, it evolved. In &lt;strong&gt;1996&lt;/strong&gt;, it got standardized as &lt;strong&gt;ECMAScript&lt;/strong&gt;. In &lt;strong&gt;2009&lt;/strong&gt;, it broke free from the browser thanks to &lt;strong&gt;Node.js&lt;/strong&gt;, which let JavaScript to run on servers too.&lt;/p&gt;
&lt;p&gt;By the early 2010s, JavaScript was everywhere. But as applications got bigger, teams started to struggle. It was just too easy to make mistakes. Misspell a variable, call a method on &lt;code&gt;undefined&lt;/code&gt;, or forget what type something was supposed to be. That’s where &lt;strong&gt;TypeScript&lt;/strong&gt; enters the picture.&lt;/p&gt;
&lt;p&gt;In &lt;strong&gt;2012&lt;/strong&gt;, &lt;strong&gt;Microsoft&lt;/strong&gt; added types to JavaScript. That’s how &lt;strong&gt;TypeScript&lt;/strong&gt; was born. A superset of JavaScript that brought optional static typing, interfaces, and better tooling. It was spearheaded by &lt;strong&gt;Anders Hejlsberg&lt;/strong&gt;, the same guy who created &lt;strong&gt;C#&lt;/strong&gt;, so it had some serious engineering power behind it.&lt;/p&gt;
&lt;p&gt;At first, the JS community was skeptical. Why add types to a language that prides itself on being dynamic? But as apps and teams grew, so did the headaches, and TypeScript’s value became clear. Big frameworks like &lt;strong&gt;Angular&lt;/strong&gt; adopted it, and eventually even the JavaScript purists warmed up to it. Today, TypeScript is used in everything from small web apps to massive enterprise systems.&lt;/p&gt;
&lt;p&gt;But the story doesn’t stop there.&lt;/p&gt;
&lt;p&gt;By &lt;strong&gt;2018&lt;/strong&gt;, a new frontier was opening up: &lt;strong&gt;WebAssembly (WASM)&lt;/strong&gt;. WASM let developers run near-native code in the browser. Fast, efficient, and portable. Languages like C, C++, and Rust were already compiling to WASM, but they weren’t easy for JavaScript devs to pick up.&lt;/p&gt;
&lt;p&gt;That’s when &lt;strong&gt;AssemblyScript&lt;/strong&gt; came into the picture. It was a community-driven project started by &lt;strong&gt;Daniel Wirtz&lt;/strong&gt;, with one goal: make it easy for JavaScript and TypeScript developers to write code that could compile to WASM. AssemblyScript used TypeScript-like syntax but was stripped down to only the features that could compile safely and efficiently to WebAssembly.&lt;/p&gt;
&lt;p&gt;Suddenly, JS devs could write &lt;strong&gt;high-performance math functions&lt;/strong&gt;, &lt;strong&gt;image processors&lt;/strong&gt;, or even &lt;strong&gt;game engines&lt;/strong&gt; in a language they already knew, without touching C or Rust.&lt;/p&gt;
&lt;p&gt;Of course, AssemblyScript isn’t a full replacement for JS or TS. It can’t talk to the DOM or fetch data directly. But it fits beautifully into apps that need a speed boost in specific parts.&lt;/p&gt;
&lt;p&gt;So now, in 2025, we live in a world where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt; is the old reliable: still easy, still everywhere.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; is the modern favorite: safer, smarter, and beloved by teams.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript&lt;/strong&gt; is the performance geek’s sidekick: fast, focused, and built for the WebAssembly era.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://www.tutorialrepublic.com/lib/images/javascript-illustration.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;JavaScript (JS)&lt;/strong&gt; is a &lt;strong&gt;dynamic&lt;/strong&gt;, &lt;strong&gt;loosely-typed&lt;/strong&gt; scripting language. It’s the backbone of most front-end (and even some back-end) apps. It runs everywhere (browsers, Node.js, Bun, Deno, etc. It’s super easy to learn. Has a huge ecosystem. It’s flexible and forgiving. However, it lacks type safety, has more runtime bugs than any other project. Large projects can get messy and extremely hard to debug due to lack of structure.&lt;/p&gt;
&lt;code-block lang=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; n &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; n&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 25&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;JavaScript has the richest tooling because it’s been around forever.&lt;/p&gt;
&lt;h3 id=&quot;frameworks-%26-libraries&quot; tabindex=&quot;-1&quot;&gt;Frameworks &amp;amp; Libraries &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#frameworks-%26-libraries&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Vue&lt;/strong&gt;, &lt;strong&gt;Svelte&lt;/strong&gt;, &lt;strong&gt;AngularJS&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Express.js&lt;/strong&gt; – server-side apps&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;jQuery&lt;/strong&gt; – (still around, but fading)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Three.js&lt;/strong&gt; – 3D graphics&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;build-tools&quot; tabindex=&quot;-1&quot;&gt;Build Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#build-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Webpack&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Parcel&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rollup&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;testing-tools&quot; tabindex=&quot;-1&quot;&gt;Testing Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#testing-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jest&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mocha&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cypress&lt;/strong&gt; (E2E)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dev-tools&quot; tabindex=&quot;-1&quot;&gt;Dev Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#dev-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Chrome DevTools&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ESLint&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Prettier&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Babel&lt;/strong&gt; – transpile newer JS for older browsers&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;use-javascript-when%3A&quot; tabindex=&quot;-1&quot;&gt;Use JavaScript when: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#use-javascript-when%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You want &lt;strong&gt;zero setup&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You’re working on &lt;strong&gt;legacy apps&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You need &lt;strong&gt;runtime scripting&lt;/strong&gt;, e.g., eval or REPL&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You want &lt;strong&gt;maximum browser compatibility&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://www.orientsoftware.com/Themes/Content/Images/blog/2023-11-13/typescript-introduction.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TypeScript (TS)&lt;/strong&gt; is a &lt;strong&gt;typed superset&lt;/strong&gt; of JavaScript. It adds &lt;strong&gt;static typing&lt;/strong&gt;, interfaces, enums, and more. All compiled down to JavaScript.&lt;/p&gt;
&lt;p&gt;It catches errors at &lt;strong&gt;compile time.&lt;/strong&gt; Helps with &lt;strong&gt;auto-complete&lt;/strong&gt;, &lt;strong&gt;refactoring&lt;/strong&gt;, and &lt;strong&gt;documentation.&lt;/strong&gt; Works with existing JS code and it’s great for large projects. There’s a slight learning curve if you’re new to typing. It requires a build step (using &lt;code&gt;tsc&lt;/code&gt;) and is slower iteration for quick scripts.&lt;/p&gt;
&lt;code-block lang=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;n&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; n &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; n&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 25&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// console.log(square(&quot;5&quot;)); // ❌ Compile-time error&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;TypeScript is super popular in modern frontend and backend development.&lt;/p&gt;
&lt;h3 id=&quot;frameworks-(ts-first-or-ts-friendly)&quot; tabindex=&quot;-1&quot;&gt;Frameworks (TS-first or TS-friendly) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#frameworks-(ts-first-or-ts-friendly)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Next.js&lt;/strong&gt; – full-stack React&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remix&lt;/strong&gt; – modern web app framework&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NestJS&lt;/strong&gt; – backend framework (like Angular for backend)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;tRPC&lt;/strong&gt; – type-safe APIs&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TypeORM&lt;/strong&gt; / &lt;strong&gt;Prisma&lt;/strong&gt; – typed database ORM&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;build-tools-1&quot; tabindex=&quot;-1&quot;&gt;Build Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#build-tools-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;tsc&lt;/strong&gt; – official TypeScript compiler&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt; – works great with TS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;esbuild&lt;/strong&gt; – super fast bundler&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;SWC&lt;/strong&gt; – Rust-based compiler used in Next.js&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;testing-tools-1&quot; tabindex=&quot;-1&quot;&gt;Testing Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#testing-tools-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Same as JS, but with type support:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jest&lt;/strong&gt; (with TS config)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vitest&lt;/strong&gt; (Vite-native testing)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ts-node&lt;/strong&gt; (run TypeScript directly)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dev-tools-1&quot; tabindex=&quot;-1&quot;&gt;Dev Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#dev-tools-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TypeScript Language Server (TSLS)&lt;/strong&gt; – for autocomplete&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;tsconfig.json&lt;/strong&gt; – config your compiler&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Typedoc&lt;/strong&gt; – generate docs from types&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;use-typescript-when%3A&quot; tabindex=&quot;-1&quot;&gt;Use TypeScript when: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#use-typescript-when%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You’re building &lt;strong&gt;large projects&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You want &lt;strong&gt;safe refactoring&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You work in a &lt;strong&gt;team&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You love &lt;strong&gt;autocomplete and IDE help&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://gitlab.com/uploads/-/system/project/avatar/37766828/assemblyscript-logo.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript (AS)&lt;/strong&gt; looks like TypeScript but compiles to &lt;strong&gt;WebAssembly (WASM)&lt;/strong&gt;, which runs at near-native speed in the browser or other WASM environments. It’s &lt;strong&gt;super fast&lt;/strong&gt; performance for CPU-heavy tasks. Easy to learn for JS/TS devs. Compiles to &lt;code&gt;.wasm&lt;/code&gt; easily. However, it’s not a full TS/JS replacement (limited standard lib). No DOM access (must be called from JS) and has some tooling quirks.&lt;/p&gt;
&lt;code-block lang=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// assembly/index.ts&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;n&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; i32&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; i32 &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; n &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; n&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;code-block lang=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; wasm &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; WebAssembly&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;instantiateStreaming&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;build/optimized.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;wasm&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 25&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;AssemblyScript is younger and more niche, but growing for performance-focused devs.&lt;/p&gt;
&lt;h3 id=&quot;core-tools&quot; tabindex=&quot;-1&quot;&gt;Core Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#core-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript Compiler (&lt;/strong&gt;&lt;code&gt;asc&lt;/code&gt;) – compile &lt;code&gt;.ts&lt;/code&gt; to &lt;code&gt;.wasm&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;asbuild&lt;/strong&gt; – build script tool&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;loader&lt;/strong&gt; – JS loader for WASM output&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;wasm-bindgen / as-bind&lt;/strong&gt; – simplify JS ↔ WASM communication&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;use-with%3A&quot; tabindex=&quot;-1&quot;&gt;Use with: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#use-with%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Web projects&lt;/strong&gt; that require native speed&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Game engines&lt;/strong&gt; (e.g., integrate into Unity, Bevy, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Blockchain smart contracts&lt;/strong&gt; (e.g., NEAR Protocol uses AssemblyScript)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scientific simulations&lt;/strong&gt; or &lt;strong&gt;image/video/audio processing&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;testing&quot; tabindex=&quot;-1&quot;&gt;Testing &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#testing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;as-pect&lt;/strong&gt; – testing framework for AssemblyScript&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dev-tools-2&quot; tabindex=&quot;-1&quot;&gt;Dev Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#dev-tools-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WABT (WebAssembly Binary Toolkit)&lt;/strong&gt; – inspect &lt;code&gt;.wasm&lt;/code&gt; files&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WasmExplorer&lt;/strong&gt;, &lt;strong&gt;WasmFiddle&lt;/strong&gt; – online WASM playgrounds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;VSCode AssemblyScript Extension&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;use-assemblyscript-when%3A&quot; tabindex=&quot;-1&quot;&gt;Use AssemblyScript when: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#use-assemblyscript-when%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You need &lt;strong&gt;WASM performance&lt;/strong&gt; with &lt;strong&gt;JavaScript-like syntax&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You’re optimizing a &lt;strong&gt;hot loop or math-heavy function&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You’re building to &lt;strong&gt;target WebAssembly&lt;/strong&gt; for portability&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While, it seems like a natural progression with AssemblyScript being the natural step. But, we’re not quite there yet. Let’s look into a few use-cases:&lt;/p&gt;
&lt;p&gt;Suppose we want to &lt;strong&gt;fetch user data from an API&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;%E2%9C%85-typescript-version-(works-fine)&quot; tabindex=&quot;-1&quot;&gt;✅ TypeScript Version (works fine) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#%E2%9C%85-typescript-version-(works-fine)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://jsonplaceholder.typicode.com/users/1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;%E2%9D%8C-assemblyscript-version-(won%E2%80%99t-work)&quot; tabindex=&quot;-1&quot;&gt;❌ AssemblyScript Version (won’t work) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#%E2%9D%8C-assemblyscript-version-(won%E2%80%99t-work)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// assembly/index.ts&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// ❌ No &#39;fetch&#39; API available&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// This will not compile or work&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;blockquote&gt;
&lt;p&gt;🛠 Workaround: You’d have to call &lt;code&gt;fetch&lt;/code&gt; from JS, then pass the result to WASM. That’s extra work and complexity.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, you might think that typescript is all powerful then? It’s close. But javascript still has it’s value. Say, you’re building a &lt;strong&gt;plugin system&lt;/strong&gt; or a browser-based REPL where users write code at runtime.&lt;/p&gt;
&lt;h3 id=&quot;%E2%9C%85-javascript-version-(works-fine)&quot; tabindex=&quot;-1&quot;&gt;✅ JavaScript Version (works fine) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#%E2%9C%85-javascript-version-(works-fine)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; userCode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;console.log(&#39;Hello from user!&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;userCode&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// ✅ Works out of the box&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;%E2%9D%8C-typescript-version-(won%E2%80%99t-work-directly)&quot; tabindex=&quot;-1&quot;&gt;❌ TypeScript Version (won’t work directly) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#%E2%9D%8C-typescript-version-(won%E2%80%99t-work-directly)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; userCode&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;console.log(&#39;Hello from user!&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// eval(userCode); ❌ This only works at runtime after TS has compiled the code to JS&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;blockquote&gt;
&lt;p&gt;🛠 You’d need to compile the user’s TypeScript code to JavaScript &lt;strong&gt;on the fly&lt;/strong&gt; (using Babel or TypeScript compiler API), which is overkill for simple tasks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, a combination is still required to get the optimal performance and scale.&lt;/p&gt;
&lt;p&gt;Imagine you’re building a browser-based photo editor:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;UI: &lt;strong&gt;React + TypeScript&lt;/strong&gt; (Next.js)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Filters and image processing: &lt;strong&gt;AssemblyScript → WASM&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Tiny plugins or runtime scripts: &lt;strong&gt;Plain JavaScript&lt;/strong&gt; with &lt;code&gt;eval&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You’re mixing all three to get:&lt;br /&gt;
✅ Scalability + ✅ Performance + ✅ Flexibility&lt;/p&gt;
&lt;h3 id=&quot;a-quick-comparison%3A&quot; tabindex=&quot;-1&quot;&gt;A quick comparison: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#a-quick-comparison%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;JavaScript&lt;/th&gt;
&lt;th&gt;TypeScript&lt;/th&gt;
&lt;th&gt;AssemblyScript&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Type safety&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (limited)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Browser support&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅ (compiled)&lt;/td&gt;
&lt;td&gt;✅ (compiled to WASM)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;⚠️ (interpreter)&lt;/td&gt;
&lt;td&gt;⚠️ (same as JS)&lt;/td&gt;
&lt;td&gt;✅✅✅ (near native)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use case&lt;/td&gt;
&lt;td&gt;Web, backend&lt;/td&gt;
&lt;td&gt;Large apps&lt;/td&gt;
&lt;td&gt;Performance-critical code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Learning curve&lt;/td&gt;
&lt;td&gt;Easy&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Medium (WASM specifics)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access to DOM&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So, there’s a time to type, transpile and compile afterall.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use JavaScript&lt;/strong&gt; if you’re building a quick prototype, small scripts, or prefer minimal setup.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use TypeScript&lt;/strong&gt; for any medium to large project where code quality and developer experience matter.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use AssemblyScript&lt;/strong&gt; if you need performance (e.g. image/video processing, simulations) and want to stay in JS-like syntax land.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As we look into the future of web development, one thing is becoming crystal clear: &lt;strong&gt;WebAssembly isn’t just a cool experiment anymore, it’s a movement.&lt;/strong&gt; And it’s reshaping how we think about building applications for the browser, desktop, and beyond.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://uno-website-assets.s3.amazonaws.com/wp-content/uploads/2019/10/01091008/webassembly-pic.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;webassembly%3A-the-portable-runtime-of-the-future&quot; tabindex=&quot;-1&quot;&gt;WebAssembly: The Portable Runtime of the Future &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/js-ts-asc/#webassembly%3A-the-portable-runtime-of-the-future&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Originally designed to make &lt;strong&gt;browser-based games and apps faster&lt;/strong&gt;, WebAssembly is now evolving into something much bigger, something &lt;strong&gt;universal&lt;/strong&gt;. It’s not just about the web anymore. WASM is showing up in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Edge computing&lt;/strong&gt; (like Cloudflare Workers)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Serverless runtimes&lt;/strong&gt; (like Wasmtime and Wasmer)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Smart contracts&lt;/strong&gt; (in chains like NEAR, Polkadot, and Internet Computer)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Plugins systems&lt;/strong&gt; for IDEs, databases, and even game engines&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The dream? &lt;strong&gt;Code that runs &lt;em&gt;anywhere&lt;/em&gt;, securely and fast, no matter the host system.&lt;/strong&gt; And AssemblyScript is well-positioned to be the “JavaScript dev’s entry point” into that world.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://sapphireventures.com/wp-content/uploads/2022/10/Final5_WebAssemblyMarketMap.Oct_.2022.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;WebAssembly is becoming:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;universal runtime&lt;/strong&gt; for sandboxed, fast code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;next VM target&lt;/strong&gt; for many languages (Python, Go, Ruby are all working on WASM support)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A way to &lt;strong&gt;escape the browser&lt;/strong&gt; while still using browser-native tech&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And as WASM matures (with support for garbage collection, threads, and better debugging), &lt;strong&gt;AssemblyScript will mature alongside it&lt;/strong&gt;. Maybe we can have a better runtime for typescript which helps push WASM beyond AssemblyScript too.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Understanding the CPython Compiler</title>
		<link href="https://blog.anirudha.dev/cpython-compiler/"/>
		<updated>2025-04-28T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/cpython-compiler/</id>
		<content type="html">&lt;p&gt;CPython is the reference implementation of Python written in C. When you run a &lt;code&gt;.py&lt;/code&gt; file, it goes through several internal steps before your code is actually executed.&lt;/p&gt;
&lt;h2 id=&quot;overview-of-the-compilation-process&quot; tabindex=&quot;-1&quot;&gt;Overview of the Compilation Process &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#overview-of-the-compilation-process&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here’s a simplified overview of what happens when you run a Python script:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lexical Analysis (Tokenizer)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Parsing (AST generation)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Abstract Syntax Tree to Bytecode Compilation&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Execution by Python Virtual Machine&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;lexical-analysis-(tokenizer)&quot; tabindex=&quot;-1&quot;&gt;Lexical Analysis (Tokenizer) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#lexical-analysis-(tokenizer)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The tokenizer splits the raw source code into &lt;em&gt;tokens&lt;/em&gt;. This is like identifying words and punctuation in a sentence.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;source_code &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;x = 42&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;CPython uses a &lt;a href=&quot;https://docs.python.org/3/library/tokenize.html&quot;&gt;tokenizer&lt;/a&gt; from the &lt;code&gt;tokenize&lt;/code&gt; module. You can inspect how Python breaks it down:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; tokenize&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; io &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; BytesIO&lt;br /&gt;&lt;br /&gt;code &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;b&quot;x = 42&quot;&lt;/span&gt;&lt;br /&gt;tokens &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenize&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tokenize&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;BytesIO&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;readline&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; token &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; tokens&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;token&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;TokenInfo&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;NAME&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; string&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;x&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; start&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; end&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; line&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;x = 42&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;TokenInfo&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;54&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;OP&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; string&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;=&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;TokenInfo&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;NUMBER&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; string&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;42&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;parsing-(ast-generation)&quot; tabindex=&quot;-1&quot;&gt;Parsing (AST Generation) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#parsing-(ast-generation)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Next, Python turns those tokens into an &lt;strong&gt;Abstract Syntax Tree (AST)&lt;/strong&gt;. This is a tree structure representing the grammar of your code.&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; ast&lt;br /&gt;&lt;br /&gt;tree &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ast&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;parse&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;x = 42&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ast&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dump&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tree&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; indent&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;Module&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    body&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;        Assign&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;            targets&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Name&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;x&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ctx&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;Store&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            value&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;Constant&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This tree shows an assignment of the constant &lt;code&gt;42&lt;/code&gt; to variable &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Here’s a visual of another tree for a simple function of &lt;code&gt;x = y + 3&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/63b3d188-ae93-480a-ac9a-e7bb03259a4c.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;ast-to-bytecode-compilation&quot; tabindex=&quot;-1&quot;&gt;AST to Bytecode Compilation &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#ast-to-bytecode-compilation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now, the AST is compiled into &lt;strong&gt;bytecode&lt;/strong&gt;, the low-level instructions that Python’s virtual machine can understand.&lt;/p&gt;
&lt;p&gt;You can do this using &lt;code&gt;compile()&lt;/code&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;code &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;x = 42&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&amp;lt;string&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;exec&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;co_code&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;# raw bytecode&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;To disassemble it into human-readable instructions:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; dis&lt;br /&gt;&lt;br /&gt;dis&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dis&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;  &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;           &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; LOAD_CONST               &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; STORE_NAME               &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt; LOAD_CONST               &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt; RETURN_VALUE&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Each instruction here corresponds to an operation in the &lt;strong&gt;Python Virtual Machine&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Of course, do try these commands in your terminal. I’ve made a small web tool for you to checkout AST and bytecode for any python program. &lt;a href=&quot;https://anistark.github.io/python-bytecode-inspector/&quot;&gt;https://anistark.github.io/python-bytecode-inspector/&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;python-virtual-machine&quot; tabindex=&quot;-1&quot;&gt;Python Virtual Machine &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#python-virtual-machine&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Finally, the bytecode is interpreted by the &lt;strong&gt;PVM&lt;/strong&gt;, a stack-based virtual machine that executes instructions like &lt;code&gt;LOAD_CONST&lt;/code&gt;, &lt;code&gt;STORE_NAME&lt;/code&gt;, etc.&lt;/p&gt;
&lt;p&gt;You can think of the interpreter as a loop that fetches, decodes, and executes each instruction in the bytecode. A simplified C-style pseudo code for it might look like:&lt;/p&gt;
&lt;code-block lang=&quot;c&quot;&gt;&lt;pre class=&quot;language-c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    opcode &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ip&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// instruction pointer&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;opcode&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; LOAD_CONST&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;consts&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; STORE_NAME&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;            names&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;arg&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;compiling-and-running-custom-code&quot; tabindex=&quot;-1&quot;&gt;Compiling and Running Custom Code &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cpython-compiler/#compiling-and-running-custom-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here’s how you can compile and execute custom Python code dynamically:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;code &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;for i in range(3): print(i)&quot;&lt;/span&gt;&lt;br /&gt;compiled &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;compile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&amp;lt;string&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;exec&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;compiled&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;You can inspect and understand how Python internally handles this by analyzing the AST and bytecode.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://mathspp.com/blog/building-a-python-compiler-and-interpreter/_structure.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The CPython compiler is elegant and modular, allowing dynamic features like &lt;code&gt;exec()&lt;/code&gt; and &lt;code&gt;eval()&lt;/code&gt; because Python code is always just one &lt;code&gt;compile()&lt;/code&gt; away from being bytecode. Understanding this pipeline gives you deeper insight into debugging, performance optimization, and even writing your own language features.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The WebAssembly Odyssey</title>
		<link href="https://blog.anirudha.dev/wasm-landscape/"/>
		<updated>2025-04-23T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/wasm-landscape/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;From browser booster to universal runtime, the journey of WebAssembly in 2025.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;a-bytecode-born-for-browsers&quot; tabindex=&quot;-1&quot;&gt;A Bytecode Born for Browsers &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#a-bytecode-born-for-browsers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In 2017, WebAssembly (WASM) arrived as a new low-level bytecode format. Safe, compact, and fast. It was meant to make games, 3D apps, and video editors perform better inside browsers.&lt;/p&gt;
&lt;p&gt;But developers had a bigger question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“What if this thing could run &lt;em&gt;anywhere&lt;/em&gt;?”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;wasi---giving-wasm-a-real-world&quot; tabindex=&quot;-1&quot;&gt;WASI - Giving WASM a Real World &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#wasi---giving-wasm-a-real-world&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;WASI&lt;/strong&gt; (WebAssembly System Interface) changed the game by giving WASM access to filesystems, networking, and other OS-level capabilities in a secure way.&lt;/p&gt;
&lt;p&gt;🧪 &lt;em&gt;WASI Hello World (Rust)&lt;/em&gt;&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello from WASI!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;To compile for WASI:&lt;/p&gt;
&lt;terminal-block&gt;rustup target add wasm32-wasi
cargo build --target wasm32-wasi&lt;/terminal-block&gt;&lt;p&gt;You can now run this &lt;code&gt;.wasm&lt;/code&gt; file in a WASI runtime like Wasmtime.&lt;/p&gt;
&lt;h2 id=&quot;tooling-%26-runtimes-evolve&quot; tabindex=&quot;-1&quot;&gt;Tooling &amp;amp; Runtimes Evolve &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#tooling-%26-runtimes-evolve&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;WASM’s power lies in its growing ecosystem.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%9B%A0%EF%B8%8F-popular-toolchains%3A&quot; tabindex=&quot;-1&quot;&gt;🛠️ Popular Toolchains: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#%F0%9F%9B%A0%EF%B8%8F-popular-toolchains%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rust&lt;/strong&gt; with &lt;code&gt;wasm-bindgen&lt;/code&gt; and &lt;code&gt;wasm-pack&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;C/C++&lt;/strong&gt; with Emscripten&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TinyGo&lt;/strong&gt; for small footprint WASM builds&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AssemblyScript&lt;/strong&gt; for JS-style development&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;%E2%9A%A1-key-runtimes%3A&quot; tabindex=&quot;-1&quot;&gt;⚡ Key Runtimes: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#%E2%9A%A1-key-runtimes%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;wasmtime&lt;/code&gt; – fast and WASI-compliant&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;wasmer&lt;/code&gt; – embeddable with multi-language support&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;wasmedge&lt;/code&gt; – optimized for edge workloads&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🧪 &lt;em&gt;Hello from Wasmtime&lt;/em&gt;&lt;/p&gt;
&lt;terminal-block&gt;wasmtime hello.wasm&lt;/terminal-block&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;Hello &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; WASI!&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;wasm-escapes-the-browser&quot; tabindex=&quot;-1&quot;&gt;WASM Escapes the Browser &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#wasm-escapes-the-browser&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;WASM’s breakout moment didn’t come from the server — it came from everywhere else.&lt;/p&gt;
&lt;h3 id=&quot;browsers%3F-still-relevant.&quot; tabindex=&quot;-1&quot;&gt;Browsers? Still relevant. &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#browsers%3F-still-relevant.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Pyodide runs Python notebooks entirely in-browser.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;AutoCAD, Figma, and even parts of Photoshop now use WASM for performance-critical code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Replit and StackBlitz built full IDEs that boot instantly in the browser.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-edge%3F-wasm%E2%80%99s-new-playground.&quot; tabindex=&quot;-1&quot;&gt;The Edge? WASM’s new playground. &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#the-edge%3F-wasm%E2%80%99s-new-playground.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Fast cold starts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Small binaries.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Secure sandboxing. Perfect for &lt;strong&gt;IoT nodes&lt;/strong&gt;, &lt;strong&gt;AI inference&lt;/strong&gt;, and &lt;strong&gt;low-latency data processing&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;smart-contracts%3F-wasm-native-chains-like-cosmos%2C-polkadot%2C-near%2C-solana-and-internet-computer-are-rewriting-the-rulebook.-no-more-custom-vms%2C-just-webassembly-all-the-way-down.&quot; tabindex=&quot;-1&quot;&gt;Smart Contracts? WASM-native chains like Cosmos, &lt;strong&gt;Polkadot&lt;/strong&gt;, &lt;strong&gt;NEAR&lt;/strong&gt;, Solana and &lt;strong&gt;Internet Computer&lt;/strong&gt; are rewriting the rulebook. No more custom VMs, just WebAssembly all the way down. &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#smart-contracts%3F-wasm-native-chains-like-cosmos%2C-polkadot%2C-near%2C-solana-and-internet-computer-are-rewriting-the-rulebook.-no-more-custom-vms%2C-just-webassembly-all-the-way-down.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;🧪 &lt;em&gt;Using WASM in the Browser (JS + WASM Binary)&lt;/em&gt;&lt;/p&gt;
&lt;code-block lang=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;span class=&quot;token language-javascript&quot;&gt;&lt;br /&gt;  WebAssembly&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;instantiateStreaming&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;simple.wasm&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;obj&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;instance&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;say_hello&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;With a Rust-compiled function like:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[no_mangle]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;C&quot;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;say_hello&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello from the browser-side WASM!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;wasm-goes-everywhere&quot; tabindex=&quot;-1&quot;&gt;WASM Goes Everywhere &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#wasm-goes-everywhere&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;%F0%9F%9A%80-serverless-%26-edge&quot; tabindex=&quot;-1&quot;&gt;🚀 Serverless &amp;amp; Edge &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#%F0%9F%9A%80-serverless-%26-edge&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Platforms like &lt;strong&gt;Cloudflare Workers&lt;/strong&gt;, &lt;strong&gt;Fermyon Spin&lt;/strong&gt;, and &lt;strong&gt;Fastly Compute Edge&lt;/strong&gt; run WASM-based microservices with blazing cold-starts and secure isolation.&lt;/p&gt;
&lt;p&gt;🧪 &lt;em&gt;Fermyon Spin App (TOML + Rust)&lt;/em&gt;&lt;/p&gt;
&lt;code-block lang=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token key property&quot;&gt;spin_manifest_version&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hello-spin&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0.1.0&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;component&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;target/wasm32-wasi/release/hello_spin.wasm&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token key property&quot;&gt;route&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/hello&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;spin_sdk&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;http&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[http_component]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_req&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;status&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello from Spin!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;active-development-in-wasm&quot; tabindex=&quot;-1&quot;&gt;Active development in WASM &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#active-development-in-wasm&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;WASM hasn’t stopped evolving.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;🧩 &lt;strong&gt;Component Model&lt;/strong&gt;: Mix and match WASM modules written in different languages.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🧠 &lt;strong&gt;WASM GC&lt;/strong&gt;: Brings modern memory-managed languages like Swift and Kotlin into the WASM family.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;📡 &lt;strong&gt;WASI Sockets&lt;/strong&gt;: Full networking support in progress.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🔁 &lt;strong&gt;Persistent Storage&lt;/strong&gt;: SQLite in WASM with real file persistence.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🧪 &lt;em&gt;SQLite in WASM (using sql.js)&lt;/em&gt;&lt;/p&gt;
&lt;code-block lang=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;SQL&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;initSqlJs&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;locateFile&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;https://sql.js.org/dist/&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;f&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; db &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SQL&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Database&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;CREATE TABLE hello (message TEXT);&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;INSERT INTO hello VALUES (&#39;Hello from SQLite in WASM!&#39;);&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;SELECT * FROM hello&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;WebAssembly is at the cusp of becoming the &lt;strong&gt;universal bytecode for the web and beyond&lt;/strong&gt;. With a strong standard foundation, rising adoption in cloud and edge platforms, and growing support from language ecosystems, WASM is transforming from a niche browser tech into the &lt;strong&gt;next big compute platform&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Whether you’re building browser tools, serverless apps, or decentralized networks, WASM is likely to be in your stack sooner than you think.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.cncf.io/wp-content/uploads/2023/09/image-21-6.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.ttgtmedia.com/rms/onlineimages/webassembly_landscape-f.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;what%E2%80%99s-next%3F&quot; tabindex=&quot;-1&quot;&gt;What’s Next? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-landscape/#what%E2%80%99s-next%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WAPM + jco&lt;/strong&gt;: Standardized package management for WASM.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Electron Replacement&lt;/strong&gt;: WASM + WASIX running full apps in-browser with no install.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;More languages&lt;/strong&gt;: Kotlin, Swift, Zig, Dart, even Java.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Native-feeling sandboxed desktops&lt;/strong&gt;: Think &lt;em&gt;VS Code&lt;/em&gt; running entirely in WASM, no local install.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;It’s sandboxed, portable, fast and it’s &lt;em&gt;just getting started&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	<entry>
		<title>Compiling Python</title>
		<link href="https://blog.anirudha.dev/compiling-python/"/>
		<updated>2025-04-04T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/compiling-python/</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://www.python.org/&quot;&gt;Python&lt;/a&gt; is one of the most widely used programming languages, but have you ever wondered how it works under the hood? CPython is the official implementation of Python written in C, and modifying it allows you to change Python’s behavior.&lt;/p&gt;
&lt;p&gt;CPython is the &lt;strong&gt;official and most widely used implementation of Python&lt;/strong&gt;, written in &lt;strong&gt;C&lt;/strong&gt;. When people talk about “Python,” they are usually referring to CPython. It is the reference implementation maintained by the Python Software Foundation (PSF) and serves as the &lt;strong&gt;gold standard&lt;/strong&gt; for how Python should behave.&lt;/p&gt;
&lt;p&gt;The name &lt;strong&gt;CPython&lt;/strong&gt; came about because it is implemented in the &lt;strong&gt;C programming language&lt;/strong&gt;. It is different from other implementations of Python, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;PyPy&lt;/strong&gt; → A Python implementation written in Python, optimized with Just-In-Time (JIT) compilation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jython&lt;/strong&gt; → A Python implementation for the Java Virtual Machine (JVM).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IronPython&lt;/strong&gt; → A Python implementation for the .NET framework.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;CPython is the &lt;strong&gt;most widely used&lt;/strong&gt; and the &lt;strong&gt;official&lt;/strong&gt; Python interpreter.&lt;/p&gt;
&lt;p&gt;When you run a Python script using CPython, the execution happens in several steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Parsing &amp;amp; Compilation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CPython first &lt;strong&gt;parses&lt;/strong&gt; the Python code into an Abstract Syntax Tree (AST).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It then &lt;strong&gt;compiles&lt;/strong&gt; the AST into &lt;strong&gt;bytecode&lt;/strong&gt; (&lt;code&gt;.pyc&lt;/code&gt; files in &lt;code&gt;__pycache__&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interpreting Bytecode:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;CPython Virtual Machine (VM)&lt;/strong&gt; executes the bytecode line by line.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This is why Python is often called an &lt;strong&gt;interpreted language&lt;/strong&gt;, even though it has a compilation step.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Memory Management &amp;amp; C Extensions:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CPython manages memory using &lt;strong&gt;reference counting&lt;/strong&gt; and &lt;strong&gt;garbage collection&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It supports C extensions, allowing Python to call C libraries (e.g., &lt;code&gt;numpy&lt;/code&gt;, &lt;code&gt;pandas&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you want to truly &lt;strong&gt;understand Python internals&lt;/strong&gt;, modifying CPython is one of the best ways to do it! 🚀&lt;/p&gt;
&lt;h2 id=&quot;cloning-the-cpython-source-code&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cloning the CPython Source Code&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#cloning-the-cpython-source-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First, clone the official CPython repository:&lt;/p&gt;
&lt;terminal-block&gt;git clone https://github.com/python/cpython.git
cd cpython&lt;/terminal-block&gt;&lt;p&gt;You can check out a specific version of Python by using:&lt;/p&gt;
&lt;terminal-block&gt;git checkout tags/v3.12.0 -b my-python&lt;/terminal-block&gt;&lt;p&gt;This creates a new branch (&lt;code&gt;my-python&lt;/code&gt;) based on Python 3.12.&lt;/p&gt;
&lt;p&gt;Stable versions of Python are maintained in &lt;code&gt;3.x&lt;/code&gt; branches, where &lt;code&gt;x&lt;/code&gt; represents the minor version. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;3.13&lt;/code&gt; (Latest stable release branch)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;3.12&lt;/code&gt; (Older stable release)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;3.11&lt;/code&gt; (Older LTS release)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To check out a specific stable branch:&lt;/p&gt;
&lt;terminal-block&gt;git checkout 3.13&lt;/terminal-block&gt;&lt;p&gt;&lt;a href=&quot;https://devguide.python.org/versions/#versions&quot;&gt;Checkout all the versions and latest updates&lt;/a&gt;. If you want to experiment with &lt;strong&gt;upcoming features&lt;/strong&gt;, use &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;setting-up-dependencies&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Setting Up Dependencies&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#setting-up-dependencies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before compiling, install the required dependencies:&lt;/p&gt;
&lt;h3 id=&quot;on-ubuntu%2Fdebian&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;On Ubuntu/Debian&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#on-ubuntu%2Fdebian&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;sudo apt update
sudo apt install -y build-essential libffi-dev libssl-dev zlib1g-dev &#92;
    libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev &#92;
    libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev&lt;/terminal-block&gt;&lt;h3 id=&quot;on-macos&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;On macOS&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#on-macos&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;brew install pkg-config openssl readline sqlite3 xz zlib tcl-tk autoconf automake libtool autoconf-archive&lt;/terminal-block&gt;&lt;blockquote&gt;
&lt;p&gt;Not all these packages might be relevant for you. Or maybe your system needs more so.&lt;/p&gt;
&lt;p&gt;Make sure to have openssl 1.1.1 or above.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For Windows, it’s recommended to use &lt;strong&gt;Windows Subsystem for Linux (WSL)&lt;/strong&gt; or &lt;strong&gt;MSYS2&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;compiling-cpython&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Compiling CPython&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#compiling-cpython&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now, configure the build:&lt;/p&gt;
&lt;terminal-block&gt;./configure --prefix=$HOME/python-build&lt;/terminal-block&gt;&lt;blockquote&gt;
&lt;p&gt;Most Linux/macOS distributions come with a pre-installed version of Python. Installing your custom build in &lt;code&gt;/usr/local&lt;/code&gt; or &lt;code&gt;/usr/bin&lt;/code&gt; could break system utilities that depend on the default Python version.&lt;/p&gt;
&lt;p&gt;By using &lt;code&gt;--prefix=$HOME/python-build&lt;/code&gt;, you install Python in your home directory, ensuring that it doesn’t interfere with the system Python.&lt;/p&gt;
&lt;p&gt;Keeping your custom Python in &lt;code&gt;~/python-build&lt;/code&gt; allows you to easily test your modifications without affecting anything else. If something goes wrong, you can just delete the directory:&lt;/p&gt;
&lt;terminal-block&gt;rm -rf ~/python-build&lt;/terminal-block&gt;&lt;p&gt;and start fresh.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Then, compile CPython:&lt;/p&gt;
&lt;terminal-block&gt;make -j$(nproc)&lt;/terminal-block&gt;&lt;p&gt;Finally, install it:&lt;/p&gt;
&lt;terminal-block&gt;make install&lt;/terminal-block&gt;&lt;p&gt;This installs your custom Python build in &lt;code&gt;~/python-build/bin/python3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Check the Python version:&lt;/p&gt;
&lt;terminal-block&gt;~/python-build/bin/python3 --version&lt;/terminal-block&gt;&lt;h2 id=&quot;modifying-cpython%3A-a-simple-example&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Modifying CPython: A Simple Example&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#modifying-cpython%3A-a-simple-example&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let’s modify CPython to change the default Python prompt (&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;).&lt;/p&gt;
&lt;h3 id=&quot;step-1%3A-locate-the-prompt-code&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Step 1: Locate the Prompt Code&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#step-1%3A-locate-the-prompt-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Open the &lt;code&gt;Python/prompt.c&lt;/code&gt; file in the CPython source directory.&lt;/p&gt;
&lt;p&gt;Find this section (in &lt;code&gt;prompt.c&lt;/code&gt;):&lt;/p&gt;
&lt;terminal-block&gt;const char *Py_GetPrompt(void) {
    return &amp;quot;&amp;gt;&amp;gt;&amp;gt; &amp;quot;;
}&lt;/terminal-block&gt;&lt;p&gt;Change it to:&lt;/p&gt;
&lt;terminal-block&gt;const char *Py_GetPrompt(void) {
    return &amp;quot;python-vibe&amp;gt; &amp;quot;;
}&lt;/terminal-block&gt;&lt;h3 id=&quot;step-2%3A-recompile-cpython&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Step 2: Recompile CPython&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/compiling-python/#step-2%3A-recompile-cpython&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Rebuild the source:&lt;/p&gt;
&lt;terminal-block&gt;make -j$(nproc)
make install&lt;/terminal-block&gt;&lt;p&gt;Now, when you run your custom Python:&lt;/p&gt;
&lt;terminal-block&gt;~/python-build/bin/python3&lt;/terminal-block&gt;&lt;p&gt;You’ll see:&lt;/p&gt;
&lt;terminal-block&gt;python-vibe&amp;gt;&lt;/terminal-block&gt;&lt;p&gt;instead of:&lt;/p&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;blockquote&gt;
&lt;p&gt;Imagination is your limit!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you make further changes, you can run Python’s built-in test suite:&lt;/p&gt;
&lt;terminal-block&gt;make test&lt;/terminal-block&gt;&lt;p&gt;For debugging, use &lt;code&gt;gdb&lt;/code&gt;:&lt;/p&gt;
&lt;terminal-block&gt;gdb --args ~/python-build/bin/python3&lt;/terminal-block&gt;&lt;p&gt;Or enable debug symbols:&lt;/p&gt;
&lt;terminal-block&gt;./configure --with-pydebug
make -j$(nproc)&lt;/terminal-block&gt;&lt;p&gt;It’s exciting, isn’t it? So, what all can we do with this? Maybe build a custom Python runtime? Optimize Python for a specific use case? Experiment with new language features before they’re even proposed?&lt;/p&gt;
&lt;p&gt;The source code is open, and the only limit is our imagination. What will you modify next? 🤔🔥&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Real World Assets</title>
		<link href="https://blog.anirudha.dev/rwa/"/>
		<updated>2025-03-25T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/rwa/</id>
		<content type="html">&lt;p&gt;​Real-World Assets (RWAs) refer to tangible or intangible items from the traditional economy such as real estate, commodities, bonds, and intellectual property, that are represented digitally on blockchain platforms. Integrating RWAs into the Web3 ecosystem aims to democratize access to these assets, enhance liquidity, and introduce innovative financial products.​&lt;/p&gt;
&lt;p&gt;Digital assets and real-world assets (RWAs) are increasingly converging, unlocking new possibilities for ownership, liquidity, and financial inclusion. While digital assets traditionally include cryptocurrencies, stablecoins, and NFTs, RWAs bring physical and financial assets into the blockchain ecosystem through tokenization.&lt;/p&gt;
&lt;p&gt;Digital assets exist purely in electronic form and are stored on decentralized ledgers like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cryptocurrencies&lt;/strong&gt; (e.g., Bitcoin, Ethereum) as decentralized money.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stablecoins&lt;/strong&gt; (e.g., USDT, USDC) providing low-volatility digital cash.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NFTs&lt;/strong&gt; (Non-Fungible Tokens) representing unique digital ownership, such as art, collectibles, and intellectual property.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;RWAs expand the scope of digital assets by bringing real-world value on-chain which further enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fractional Ownership&lt;/strong&gt;: Investors can own small shares of high-value assets like real estate, gold, and fine art.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enhanced Liquidity&lt;/strong&gt;: Traditionally illiquid assets, such as private equity and real estate, become tradeable on blockchain-based marketplaces.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Programmability&lt;/strong&gt;: Smart contracts automate transactions, compliance, and profit distribution, reducing reliance on intermediaries.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Traditional finance (TradFi) and Web3 are merging through tokenization. &lt;strong&gt;Tokenized Real Estate&lt;/strong&gt; allows investors to buy property shares without requiring full ownership. &lt;strong&gt;Tokenized Bonds and Equities&lt;/strong&gt; introduce institutional-grade financial instruments to DeFi. &lt;strong&gt;Real-World Collateral in DeFi&lt;/strong&gt; enables users to borrow against RWAs, such as tokenized invoices, supply chain assets, and luxury goods. By integrating RWAs into the digital asset space, Web3 is paving the way for a more inclusive, efficient, and transparent financial ecosystem.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/81e75b3e-2008-4b16-ba40-22ddd5a036bc.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Types of RWAs in Web3&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized Real Estate&lt;/strong&gt;: Platforms like Lofty and RealT enable fractional ownership of properties, allowing investors to participate in the real estate market with reduced capital requirements.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized Bonds and Securities&lt;/strong&gt;: Asset managers, including Janus Henderson, are exploring tokenization to enhance efficiency and reduce costs in bond and equity markets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized Commodities&lt;/strong&gt;: Projects are emerging that represent commodities like gold, diamond and oil as digital tokens, offering investors a more accessible and liquid means to trade these assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized Carbon Credits&lt;/strong&gt;: By converting carbon credits into digital tokens, companies can engage in a more streamlined trading process, facilitating their sustainability initiatives.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The integration of RWAs into Web3 has led to the development of specific token standards to ensure compliance, interoperability, and functionality:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ERC-1400&lt;/strong&gt;: This standard focuses on security tokens, emphasizing regulatory compliance and flexibility in representing asset ownership on the blockchain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ERC-3525&lt;/strong&gt;: Designed for semi-fungible tokens, ERC-3525 allows each token to maintain its distinct identity while being fragmentable and tradable, offering a nuanced approach to asset representation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ERC-3475&lt;/strong&gt;: This standard facilitates the issuance and trading of decentralized bonds with multiple redemption data, simplifying the management of liquidity pools and reducing transaction costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ERC-6065&lt;/strong&gt;: Still in review stage, this proposal introduces an open structure for physical real estate and property to exist on the blockchain. This standard builds off of ERC-721, adding important functionality necessary for representing real world assets such as real estate. The three objectives this standard aims to meet are: universal transferability of the NFT, private property rights attached to the NFT, and atomic transfer of property rights with the transfer of the NFT. The token contains a hash of the operating agreement detailing the NFT holder’s legal right to the property, unique identifiers for the property, a debt value and foreclosure status, and a manager address.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ERC-7765&lt;/strong&gt;: This standard defines an interface to carry a real world asset with some privileges that can be exercised by the holder of the corresponding NFT.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://tokeny.com/wp-content/uploads/2023/10/beincrypto-image-4-1024x321.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Since RWAs involve tangible assets and legal frameworks, security is critical to prevent fraud, hacking, and regulatory non-compliance.&lt;/p&gt;
&lt;h3 id=&quot;smart-contract-security&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Smart Contract Security&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#smart-contract-security&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Audited Code&lt;/strong&gt;: RWAs often rely on complex smart contracts. Regular security audits (by firms like CertiK or Quantstamp) help prevent vulnerabilities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Access Control&lt;/strong&gt;: Role-based access ensures that only authorized parties can modify or transfer assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi-Sig Wallets&lt;/strong&gt;: Using multi-signature wallets adds an extra layer of security for high-value asset management.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;regulatory-compliance-%26-identity-verification&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Regulatory Compliance &amp;amp; Identity Verification&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#regulatory-compliance-%26-identity-verification&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;KYC/AML Protocols&lt;/strong&gt;: Tokenized RWAs must comply with Know Your Customer (KYC) and Anti-Money Laundering (AML) regulations to prevent illicit transactions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;On-Chain Identity&lt;/strong&gt;: Decentralized identity solutions, such as Soulbound Tokens (SBTs) or Verifiable Credentials (VCs), help validate asset ownership securely.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;data-privacy-%26-encryption&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Data Privacy &amp;amp; Encryption&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#data-privacy-%26-encryption&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Zero-Knowledge Proofs (ZKPs)&lt;/strong&gt;: RWAs can use ZKPs to verify transactions without exposing sensitive details.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Off-Chain Data Storage&lt;/strong&gt;: Sensitive asset data can be stored off-chain while using blockchain for verification, reducing on-chain risks.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;insurance-%26-risk-mitigation&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Insurance &amp;amp; Risk Mitigation&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#insurance-%26-risk-mitigation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Decentralized Insurance&lt;/strong&gt;: Platforms like Nexus Mutual or Chainproof offer insurance against smart contract failures.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Oracles &amp;amp; Valuation Checks&lt;/strong&gt;: Secure oracles (e.g., Chainlink) provide real-time price feeds and asset valuation to prevent price manipulation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/2ca8f232-42c0-4e32-ad06-8c77dd4967fb.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The tokenization of real-world assets (RWAs) is transforming financial markets, but it also brings regulatory challenges. Governments and financial authorities worldwide are working to establish frameworks that ensure compliance, security, and consumer protection while fostering innovation.&lt;/p&gt;
&lt;h3 id=&quot;securities-regulations&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Securities Regulations&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#securities-regulations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Many tokenized RWAs, such as real estate, equities, and debt instruments, fall under &lt;strong&gt;securities laws&lt;/strong&gt; in different jurisdictions. Regulations like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;U.S. SEC (Securities and Exchange Commission)&lt;/strong&gt;: Treats tokenized assets as securities if they meet the &lt;strong&gt;Howey Test&lt;/strong&gt;, requiring them to follow registration and disclosure requirements.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;EU Markets in Crypto-Assets (MiCA) Regulation&lt;/strong&gt;: Provides a framework for tokenized securities and stablecoins, ensuring transparency and investor protection.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Singapore (MAS - Monetary Authority of Singapore)&lt;/strong&gt;: Has a &lt;strong&gt;Sandbox Framework&lt;/strong&gt; allowing regulated experimentation with asset tokenization.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;kyc%2Faml-%26-compliance-standards&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;KYC/AML &amp;amp; Compliance Standards&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#kyc%2Faml-%26-compliance-standards&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To prevent money laundering and fraud, most jurisdictions require &lt;strong&gt;Know Your Customer (KYC)&lt;/strong&gt; and &lt;strong&gt;Anti-Money Laundering (AML)&lt;/strong&gt; checks for RWA platforms.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;FATF (Financial Action Task Force) Guidelines&lt;/strong&gt;: Recommend &lt;strong&gt;Travel Rule&lt;/strong&gt; compliance, ensuring identity verification for transactions above a threshold.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Privacy vs. Compliance&lt;/strong&gt;: Zero-Knowledge Proofs (ZKPs) and decentralized identity solutions help balance on-chain privacy with regulatory needs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;taxation-%26-reporting&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Taxation &amp;amp; Reporting&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#taxation-%26-reporting&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Tokenized RWAs create tax implications based on jurisdiction:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Capital Gains Tax&lt;/strong&gt;: Profits from selling tokenized assets may be subject to capital gains tax.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Asset Valuation &amp;amp; Reporting&lt;/strong&gt;: Regular valuation and reporting of tokenized assets to authorities are required for transparency.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stablecoin &amp;amp; Tokenized Cash Flow Taxation&lt;/strong&gt;: Income from tokenized debt, real estate, or commodities might be taxed as traditional financial instruments.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;ownership-%26-legal-recognition&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Ownership &amp;amp; Legal Recognition&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/rwa/#ownership-%26-legal-recognition&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Governments are working on defining &lt;strong&gt;legal ownership&lt;/strong&gt; of RWAs on-chain.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Smart Contracts &amp;amp; Property Rights&lt;/strong&gt;: Can on-chain ownership be legally recognized in courts?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jurisdictional Conflicts&lt;/strong&gt;: A tokenized asset might exist globally, but legal disputes arise under national laws.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custody &amp;amp; Recovery&lt;/strong&gt;: Who is responsible if an RWA platform fails or assets are lost?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Watch out for &lt;strong&gt;Evolving Policies&lt;/strong&gt;, &lt;strong&gt;Hybrid Compliance Models&lt;/strong&gt; and &lt;strong&gt;CBDCs&lt;/strong&gt; &amp;amp; Tokenized Banking Assets in particular.&lt;/p&gt;
&lt;p&gt;The security of buying and trading &lt;strong&gt;real-world assets (RWAs)&lt;/strong&gt; depends on factors like &lt;strong&gt;platform credibility, smart contract security, regulatory compliance, and asset verification&lt;/strong&gt;. While tokenized assets offer transparency and efficiency, they also introduce risks that buyers and investors need to be aware of.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Smart Contract Vulnerabilities&lt;/strong&gt; – Poorly written or unaudited smart contracts can be exploited, leading to asset loss.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Counterfeit or Fake Assets&lt;/strong&gt; – Fraudulent RWAs may be minted without proper legal backing, leading to fake ownership claims.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Regulatory Uncertainty&lt;/strong&gt; – Some jurisdictions do not yet recognize tokenized RWAs, leading to potential legal risks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Liquidity Risks&lt;/strong&gt; – Unlike cryptocurrencies, RWAs may have lower liquidity, making it harder to sell them quickly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Centralized Points of Failure&lt;/strong&gt; – If an RWA marketplace is centralized or lacks proper decentralization measures, assets could be frozen or mismanaged.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/091672db-03a2-41ce-9b4f-2963eb236784.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Current RWA market is valued at &lt;strong&gt;about $50 Billion. $16 Trillion Market by 2030&lt;/strong&gt; is what experts predict RWAs as a &lt;strong&gt;huge part of the financial system&lt;/strong&gt; soon. Real estate, stocks, and commodities will likely move &lt;strong&gt;on-chain&lt;/strong&gt; in the next decade. RWAs are set to change the game in finance, real estate, supply chains, and even digital ownership. As web3 tech gets better, RWAs will make buying, selling, and investing in real-world stuff easier, faster, and more accessible to everyone.&lt;/p&gt;
&lt;p&gt;🚀 &lt;strong&gt;Big Banks &amp;amp; Companies Are Jumping In&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Major players like &lt;strong&gt;BlackRock and JPMorgan&lt;/strong&gt; are already testing tokenized assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Soon, &lt;strong&gt;stocks, bonds, and even real estate&lt;/strong&gt; could be traded on blockchain just like crypto.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🌍 &lt;strong&gt;Buying &amp;amp; Selling Globally, No Middlemen&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Imagine owning &lt;strong&gt;a piece of a building in New York&lt;/strong&gt; while sitting in India, all through blockchain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No need for banks or brokers—just &lt;strong&gt;fast, direct transactions&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;📊 &lt;strong&gt;AI + Blockchain = Smarter Investments&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;AI-powered smart contracts will handle &lt;strong&gt;loans, risk assessments, and payments&lt;/strong&gt; automatically.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;People with &lt;strong&gt;no credit history&lt;/strong&gt; might finally get &lt;strong&gt;fair financial access&lt;/strong&gt; through blockchain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;🔗 &lt;strong&gt;RWAs Across Different Blockchains &amp;amp; TradFi&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;RWAs will work across multiple blockchains like &lt;strong&gt;Ethereum and Solana&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You could use &lt;strong&gt;tokenized gold or real estate as collateral&lt;/strong&gt; in both traditional finance and DeFi.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Businesses can tokenize &lt;strong&gt;future earnings, property, or contracts&lt;/strong&gt; and sell shares to investors. Own &lt;strong&gt;a virtual house&lt;/strong&gt; that’s linked to a &lt;strong&gt;real apartment&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;RWAs are more than just a trend. They’re the &lt;strong&gt;future of finance and ownership.&lt;/strong&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Feluda</title>
		<link href="https://blog.anirudha.dev/feluda/"/>
		<updated>2025-02-26T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/feluda/</id>
		<content type="html">&lt;p&gt;Imagine you’re deep into building something exciting. A groundbreaking app, a sleek dev tool, or even just a weekend side project that scratches a creative itch. You’re focused, in the zone, writing code and adding dependencies to move faster. After all, why reinvent the wheel when you can leverage existing libraries?&lt;/p&gt;
&lt;p&gt;But, here’s where things get tricky. Every package you install comes with a license, and those licenses aren’t always as straightforward as you’d hope. Some are as chill as a summer breeze, letting you do whatever you want. Others, however, sneak in clauses like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;“No commercial use!”&lt;/strong&gt; – meaning you can’t monetize your project without legal consequences.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;“Your whole project must be open-source!”&lt;/strong&gt; – suddenly, your proprietary work isn’t so proprietary anymore.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;“You need to give attribution in a specific way!”&lt;/strong&gt; – and failing to do so could cause legal trouble down the line.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most of us don’t read licenses in detail. Who has the time? But ignoring them can lead to a nasty surprise, like a cease-and-desist letter, a forced code rewrite, or even legal trouble.&lt;/p&gt;
&lt;p&gt;That’s why we created &lt;a href=&quot;https://github.com/anistark/feluda&quot;&gt;&lt;strong&gt;Feluda&lt;/strong&gt;&lt;/a&gt;, your personal detective for project dependencies.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/f0c146aa-e85f-4486-a596-23c6a5003646.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Feluda is a command-line tool that scans your project’s dependencies, analyzes their licenses, and flags any restrictive or risky ones before they become a problem. Instead of spending hours manually digging through legal jargon, Feluda does the detective work for you.&lt;/p&gt;
&lt;p&gt;Here’s how it helps:&lt;/p&gt;
&lt;p&gt;✅ &lt;strong&gt;Instant License Check&lt;/strong&gt; – Get a clear breakdown of what each dependency allows and restricts.&lt;br /&gt;
✅ &lt;strong&gt;Early Warnings&lt;/strong&gt; – Catch licensing issues &lt;em&gt;before&lt;/em&gt; they turn into serious problems.&lt;br /&gt;
✅ &lt;strong&gt;Automated Reports&lt;/strong&gt; – Get an easy-to-read summary without manually searching license terms.&lt;br /&gt;
✅ &lt;strong&gt;Dependency Transparency&lt;/strong&gt; – Understand what you’re using and where it’s coming from.&lt;/p&gt;
&lt;p&gt;All of this happens with a simple CLI command. Run Feluda, and it will analyze your &lt;code&gt;cargo.toml&lt;/code&gt;, &lt;code&gt;package.json&lt;/code&gt;, &lt;code&gt;go.mod&lt;/code&gt;, or other dependency files. Within seconds, you get a comprehensive report on whether your dependencies are safe to use commercially or if you need to make adjustments. In the lastest release, Feluda even supports python, weather its via &lt;code&gt;pyproject.toml&lt;/code&gt; or &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In modern development, package managers make it easier than ever to install third-party libraries. But with great convenience comes great complexity. A single package might depend on ten others, which in turn depend on fifty more. Before you realize it, your project has &lt;strong&gt;hundreds of hidden dependencies&lt;/strong&gt;, each with its own license terms. A small oversight could mean that your app is suddenly violating multiple agreements. Large companies have legal teams to handle this, but indie developers, startups, and open-source maintainers often don’t have that luxury. That’s where Feluda steps in, making sure that whether you’re an individual dev or part of a team, you stay informed and legally safe.&lt;/p&gt;
&lt;h2 id=&quot;features&quot; tabindex=&quot;-1&quot;&gt;Features &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#features&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Feluda is designed to make license compliance easy and transparent for developers. We’re constantly evolving and taking in requests to go to the next level, making it easier and smoother and more accurate to provide licensing guidelines for your convenience.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%94%8E-multi-language-support&quot; tabindex=&quot;-1&quot;&gt;🔎 &lt;strong&gt;Multi-Language Support&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%94%8E-multi-language-support&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Feluda can analyze dependencies across multiple programming languages, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rust&lt;/strong&gt; (&lt;code&gt;Cargo.toml&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt; (&lt;code&gt;package.json&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Go&lt;/strong&gt; (&lt;code&gt;go.mod&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; (&lt;code&gt;requirements.txt&lt;/code&gt;, &lt;code&gt;pyproject.toml&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also filter the analysis to a specific language using the &lt;code&gt;--language&lt;/code&gt; flag.&lt;/p&gt;
&lt;terminal-block&gt;feluda --language rust&lt;/terminal-block&gt;&lt;h3 id=&quot;%F0%9F%9A%A6-license-classification-%26-restriction-flagging&quot; tabindex=&quot;-1&quot;&gt;🚦 &lt;strong&gt;License Classification &amp;amp; Restriction Flagging&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%9A%A6-license-classification-%26-restriction-flagging&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Feluda automatically identifies and classifies licenses into:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Permissive&lt;/strong&gt; – Free to use with minimal restrictions (e.g., MIT, Apache-2.0, BSD).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Restrictive&lt;/strong&gt; – Might impose conditions like open-sourcing your code (e.g., GPL-3.0, AGPL-3.0).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unknown&lt;/strong&gt; – Not recognized or missing a standard license identifier.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It flags dependencies that &lt;strong&gt;might restrict personal or commercial use&lt;/strong&gt;, so you can address them early. Some of it is still open as an issue, and we’re working on it. Hopefully, by the time you’re reading this article, we might have tackled them already! :)&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%93%8A-multiple-output-formats&quot; tabindex=&quot;-1&quot;&gt;📊 &lt;strong&gt;Multiple Output Formats&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%93%8A-multiple-output-formats&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Feluda provides output in different formats to suit various needs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Plain text&lt;/strong&gt; (default) – Readable report summary in the terminal.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JSON&lt;/strong&gt; (&lt;code&gt;--json&lt;/code&gt;) – For programmatic use or automation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TUI (Graphical Mode)&lt;/strong&gt; (&lt;code&gt;--gui&lt;/code&gt;) – Browse dependencies in a visual, interactive interface.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Strict Mode&lt;/strong&gt; (&lt;code&gt;--strict&lt;/code&gt;) – Outputs only dependencies with restrictive licenses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gist Format&lt;/strong&gt; – Available in strict mode to output a single-line summary.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;%F0%9F%93%8D-customizable-license-policies&quot; tabindex=&quot;-1&quot;&gt;📍 &lt;strong&gt;Customizable License Policies&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%93%8D-customizable-license-policies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Define your own restrictive licenses through:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;.feluda.toml&lt;/code&gt; configuration file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Environment variables &lt;code&gt;export FELUDA_LICENSES_RESTRICTIVE=&#39;[&amp;quot;GPL-3.0&amp;quot;,&amp;quot;AGPL-3.0&amp;quot;,&amp;quot;Custom-1.0&amp;quot;]&#39;&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Default restrictive licenses list&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This ensures flexibility, allowing you to tailor Feluda to your project’s compliance needs.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%9A%80-fast-%26-lightweight&quot; tabindex=&quot;-1&quot;&gt;🚀 &lt;strong&gt;Fast &amp;amp; Lightweight&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%9A%80-fast-%26-lightweight&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Feluda is built in Rust, ensuring a &lt;strong&gt;blazing-fast&lt;/strong&gt; execution with minimal resource usage. It can scan and classify hundreds of dependencies in seconds. We are working on improving performance to make everything run more smoothly and quickly while using fewer resources.&lt;/p&gt;
&lt;h3 id=&quot;%F0%9F%94%84-ci%2Fcd-integration-(planned)&quot; tabindex=&quot;-1&quot;&gt;🔄 &lt;strong&gt;CI/CD Integration&lt;/strong&gt; (Planned) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/feluda/#%F0%9F%94%84-ci%2Fcd-integration-(planned)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Future versions will support integration into CI/CD pipelines, helping teams automate license checks before deployment.&lt;/p&gt;
&lt;p&gt;With these features, Feluda simplifies dependency management and lets you build with confidence. 🚀 As an open-source tool, Feluda is a community-driven project. We welcome contributions, feedback, and ideas to make it even better.&lt;/p&gt;
&lt;p&gt;If you’re a developer, and interested in contributing, checkout the repository, open issues and discussions. We’d be more than happy to work together in building a better tool for licensing while keeping it performant compliant. Currently, Farhaan and myself are the only maintainers, but seeing the rise in contribution from the open source community, I can only hope for more amazing folks to get involved. 🙌&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/anistark/feluda&quot;&gt;View Feluda on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Latest version at the time of writing this article is &lt;a href=&quot;https://crates.io/crates/feluda&quot;&gt;v1.5.0&lt;/a&gt;. 🥂&lt;/p&gt;
&lt;p&gt;At the end of the day, Feluda isn’t just about compliance, it’s about peace of mind. When you use Feluda, you can focus on what really matters: &lt;strong&gt;building something awesome&lt;/strong&gt; without worrying about hidden legal traps.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;So go ahead, write code, ship products, and let Feluda handle the detective work.&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The Future of Digital Profiles and Avatars</title>
		<link href="https://blog.anirudha.dev/decentralised-profile-standard/"/>
		<updated>2025-02-18T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/decentralised-profile-standard/</id>
		<content type="html">&lt;p&gt;The way we represent ourselves online is undergoing a fundamental transformation. Traditional user profiles, tied to centralised platforms, restrict true ownership, portability, and privacy. But what if identities could be &lt;strong&gt;self-sovereign, interoperable, and decentralised&lt;/strong&gt;, seamlessly working across all apps, chains, and ecosystems?&lt;/p&gt;
&lt;p&gt;We have to maintain &lt;strong&gt;separate profiles&lt;/strong&gt; for each platform we use. Social media, professional networks, gaming accounts, and various decentralised applications (dApps). This means a person might have an X handle, a LinkedIn profile, a gaming avatar, and a separate Web3 identity, each with different usernames, profile pictures, and reputations. And rightly so. Your gamer friends would make fun of your linkedin avatar and nobody would take you seriously if you put your gaming avatar on linkedin. Prejudice is common and we’re not here to argue that. The problem we’re discussing is both deeply personal and about presentability without sacrificing originality.&lt;/p&gt;
&lt;p&gt;There is &lt;strong&gt;no single source of truth&lt;/strong&gt; for your identity today. Someone might recognise you on X or instagram but have no idea it’s the same person on Discord or LinkedIn. You have to &lt;strong&gt;manually update&lt;/strong&gt; every profile when you change details like bio, profile picture, or contact info. No wonder a lot of us only update our profile pictures once in 5 years, more or less at a time, when the image itself stops looking like us. Moreover, &lt;strong&gt;reputation and social ranking are siloed&lt;/strong&gt;. A person’s credibility on one platform does not carry over to another. A &lt;strong&gt;decentralised identity system&lt;/strong&gt; would eliminate these silos, providing a &lt;strong&gt;unified, portable profile&lt;/strong&gt; that users can take across the internet, whether in Web2 or Web3. With centralised identity systems, it’s also easy to create &lt;strong&gt;fake accounts, impersonate others, and conduct fraudulent activities&lt;/strong&gt;. There is no universal way to verify someone’s authenticity across platforms. A &lt;strong&gt;decentralised, verifiable identity system&lt;/strong&gt; using &lt;strong&gt;Soulbound Tokens (SBTs) and on-chain attestations&lt;/strong&gt; would help ensure &lt;strong&gt;authenticity&lt;/strong&gt;, making it easy to verify real users while maintaining &lt;strong&gt;privacy and anonymity where needed&lt;/strong&gt;. &lt;a href=&quot;https://blog.anirudha.dev/did&quot;&gt;Read about Decentralised Identities in this article if you’ve not yet.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The centralised identity systems of today are broken, fragmented, insecure, and controlled by corporations with misaligned incentives. What you need is more than a linktree. A decentralised, blockchain-based identity would give users true ownership, privacy, and control, allowing them to manage their digital presence across the internet without relying on third parties. With self-sovereign profiles and interoperable avatars, users can seamlessly interact across dApps, metaverses, and Web2 platforms while ensuring security, censorship resistance, and portability. The future of digital identity is decentralised, user-owned, and truly interoperable, putting individuals back in control of their online presence. So, a general flow towards decentralised identity would look something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://img.etimg.com/photo/msid-103886888,imgsize-100901/Moody&#39;s.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But we’re here to propose a new form of profile management.&lt;/p&gt;
&lt;p&gt;Imagine a &lt;strong&gt;single profile&lt;/strong&gt; that works across all dApps, protocols, and metaverses. An identity truly owned by the user, secured on-chain, and &lt;strong&gt;resistant to censorship&lt;/strong&gt;. This decentralised identity framework introduces:&lt;/p&gt;
&lt;p&gt;✅ &lt;strong&gt;Unique, Portable Profiles&lt;/strong&gt; – A universal identifier like &lt;code&gt;username@network.soul&lt;/code&gt; that functions across any application.&lt;br /&gt;
✅ &lt;strong&gt;On-Chain Digital Identity (DID)&lt;/strong&gt; – A standardised format (&lt;code&gt;did:chain:address&lt;/code&gt;) ensuring cryptographic ownership.&lt;br /&gt;
✅ &lt;strong&gt;Decentralised Storage&lt;/strong&gt; – Metadata and avatars stored securely on IPFS/Filecoin rather than centralised servers.&lt;br /&gt;
✅ &lt;strong&gt;Privacy Controls&lt;/strong&gt; – Users decide which parts of their profile are public or private, including app-specific avatars.&lt;/p&gt;
&lt;p&gt;In Web2, &lt;strong&gt;Gravatar&lt;/strong&gt; provided a simple yet powerful solution for managing profile pictures across multiple websites. It allowed users to upload an avatar once and have it automatically appear on any site that integrated Gravatar, such as WordPress, GitHub, and Stack Overflow.&lt;/p&gt;
&lt;h3 id=&quot;how-gravatar-works-in-web2&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;How Gravatar Works in Web2&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#how-gravatar-works-in-web2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User creates an account on&lt;/strong&gt; &lt;a href=&quot;http://gravatar.com/&quot;&gt;&lt;strong&gt;Gravatar.com&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Uploads an avatar and links it to their email&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;When logging into a supported website, the site queries Gravatar with the user’s email&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;If an avatar is found, it’s displayed automatically. If not, a default avatar is shown&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This model enabled &lt;strong&gt;seamless profile picture portability&lt;/strong&gt; across multiple platforms &lt;strong&gt;without requiring repeated uploads&lt;/strong&gt;. However, Gravatar still has &lt;strong&gt;centralised limitations&lt;/strong&gt;, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Controlled by a single entity (Automattic, the company behind WordPress)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Subject to data privacy concerns and potential censorship&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Limited to Web2 applications, making it unusable in decentralised environments&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.gravatar.com/wp-content/uploads/2024/12/image-4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, imagine a &lt;strong&gt;decentralised profile system, that&lt;/strong&gt; allows users to maintain a &lt;strong&gt;single identity&lt;/strong&gt; that works &lt;strong&gt;across all platforms, chains, and applications&lt;/strong&gt;, ensuring &lt;strong&gt;ownership, security, and interoperability&lt;/strong&gt;. Instead of being tied to a single company, these profiles live on the blockchain, controlled by the user’s private key.&lt;/p&gt;
&lt;p&gt;The proposed &lt;strong&gt;ERC-7866: Decentralised Profile Standard&lt;/strong&gt; (&lt;a href=&quot;https://ethereum-magicians.org/t/erc-7866-decentralised-profile-standard/22610&quot;&gt;Ethereum Magicians Discussion&lt;/a&gt;) aims to create an &lt;strong&gt;interoperable identity layer&lt;/strong&gt; that enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;A unique identifier as Decentralised Profile&lt;/strong&gt; tied to a user’s &lt;strong&gt;wallet address&lt;/strong&gt; and formatted as &lt;code&gt;username@networkslug.soul&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Metadata storage&lt;/strong&gt; on &lt;strong&gt;IPFS, Arweave, or other decentralised storage solutions&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom avatars per dApp&lt;/strong&gt;, allowing users to set specific profile pictures for different applications while maintaining a &lt;strong&gt;default avatar&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Access control&lt;/strong&gt;, letting users &lt;strong&gt;choose what information is public or private&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-chain interoperability&lt;/strong&gt; using &lt;strong&gt;Axelar, LayerZero, or similar messaging protocols&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;technical-implementation-of-a-decentralised-profile&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Technical Implementation of a Decentralised Profile&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#technical-implementation-of-a-decentralised-profile&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id=&quot;1.-unique-identifier%3A-decentralised-profile&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;1. Unique Identifier: Decentralised Profile&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#1.-unique-identifier%3A-decentralised-profile&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Each user is assigned a &lt;strong&gt;decentralised identifier (DID)&lt;/strong&gt; in the format:&lt;/p&gt;
&lt;code-block lang=&quot;plaintext&quot;&gt;&lt;pre class=&quot;language-plaintext&quot;&gt;&lt;code class=&quot;language-plaintext&quot;&gt;did:chain:address&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;did:ethereum:0x1731B43cc0B6F14777FBE14bfd44847C3a0e47dE&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;did:xion:xion1gxasu43e4wt89gjpfp4vhm977yf356x786w9c7&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This DID is mapped to a &lt;strong&gt;human-readable username&lt;/strong&gt; in the form of a &lt;strong&gt;Decentralised Profile (CSP)&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;plaintext&quot;&gt;&lt;pre class=&quot;language-plaintext&quot;&gt;&lt;code class=&quot;language-plaintext&quot;&gt;username@networkslug.soul&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;alice@eth.soul&lt;/code&gt; (for Ethereum)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;bob@bnb.soul&lt;/code&gt; (for Binance Smart Chain)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;strong&gt;CSP acts as the user’s universal profile handle&lt;/strong&gt;, allowing seamless recognition across multiple platforms.&lt;/p&gt;
&lt;h4 id=&quot;profile-metadata-storage&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Profile Metadata Storage&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#profile-metadata-storage&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;A user’s profile information (bio, links, avatars, etc.) is stored &lt;strong&gt;off-chain&lt;/strong&gt; on &lt;strong&gt;IPFS, Arweave, or decentralised storage networks&lt;/strong&gt; to ensure scalability and cost-efficiency.&lt;/p&gt;
&lt;p&gt;Each profile contains a structured metadata schema, defining:&lt;/p&gt;
&lt;code-block lang=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;bio&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Web3 builder &amp;amp; NFT enthusiast&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;avatar&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ipfs://Qm123...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;dapp_avatars&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;0xDapp1...&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ipfs://QmAvatar1...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;0xDapp2...&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ipfs://QmAvatar2...&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;socials&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;twitter&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@alice_eth&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;github&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;alice-dev&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;&quot;visibility&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;avatar&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;public&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;&quot;profile&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;private&quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This enables &lt;strong&gt;custom avatars per dApp&lt;/strong&gt; and &lt;strong&gt;user-controlled privacy settings&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;bringing-gravatar%E2%80%99s-convenience-to-web3-with-cybersoul-profiles&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Bringing Gravatar’s Convenience to Web3 with CyberSoul Profiles&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#bringing-gravatar%E2%80%99s-convenience-to-web3-with-cybersoul-profiles&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;ERC-7866 Decentralised Profile Standard&lt;/strong&gt; takes the &lt;strong&gt;best aspects of Gravatar&lt;/strong&gt; while &lt;strong&gt;eliminating its centralisation flaws&lt;/strong&gt;. Instead of relying on an &lt;strong&gt;email-linked database&lt;/strong&gt; controlled by a company, CyberSoul Profiles are:&lt;/p&gt;
&lt;p&gt;✅ &lt;strong&gt;Tied to a decentralised identifier (DID), not an email&lt;/strong&gt;&lt;br /&gt;
✅ &lt;strong&gt;Stored on IPFS/Arweave instead of a centralised server&lt;/strong&gt;&lt;br /&gt;
✅ &lt;strong&gt;Interoperable across all dApps, metaverses, and chains&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;how-it-works-in-web3&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;How It Works in Web3&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralised-profile-standard/#how-it-works-in-web3&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User registers their decentralised profile (CSP) and sets a default avatar&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;They can assign different avatars for specific dApps or keep one universal avatar&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Any dApp can query the CyberSoulProfile contract to fetch the avatar using CSP&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;If a custom avatar for that dApp exists, it’s displayed, otherwise, the default avatar is used&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This ensures that, just like Gravatar in Web2, users only &lt;strong&gt;set up their avatar once&lt;/strong&gt; and it &lt;strong&gt;works everywhere&lt;/strong&gt;, but in a &lt;strong&gt;fully decentralised, censorship-resistant, and cross-chain manner&lt;/strong&gt;. 🚀&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;decentralised profile system&lt;/strong&gt; isn’t just about convenience. It’s about &lt;strong&gt;user autonomy, security, and ownership&lt;/strong&gt; in an increasingly digital world. By moving away from &lt;strong&gt;platform-dependent identities&lt;/strong&gt; to a self-sovereign system, users gain &lt;strong&gt;true control over their digital selves&lt;/strong&gt;, one profile, usable everywhere.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cybersoul.netlify.app/images/landing/avatars.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;With the right architecture, &lt;strong&gt;Web3 can finally have a standard, chain-agnostic identity layer&lt;/strong&gt;, paving the way for an open, decentralised, and user-first internet. 🌐 Come support this new standard and let’s step forward into decentralised profiles. 🙌&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Building a Cross-Chain Bridge to Cosmos</title>
		<link href="https://blog.anirudha.dev/building-a-cross-chain-bridge-to-cosmos/"/>
		<updated>2025-02-13T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/building-a-cross-chain-bridge-to-cosmos/</id>
		<content type="html">&lt;p&gt;In &lt;a href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge&quot;&gt;&lt;strong&gt;Part 1&lt;/strong&gt;&lt;/a&gt;, we built a &lt;strong&gt;LayerZero-powered bridge&lt;/strong&gt; for moving NFTs between &lt;strong&gt;two EVM chains&lt;/strong&gt;. But what if we want to &lt;strong&gt;bridge an NFT from Ethereum to Cosmos&lt;/strong&gt; (e.g., &lt;a href=&quot;https://osmosis.zone/&quot;&gt;Osmosis&lt;/a&gt;, &lt;a href=&quot;https://junonetwork.io/&quot;&gt;Juno&lt;/a&gt;, or &lt;a href=&quot;https://www.stargaze.zone/&quot;&gt;Stargaze&lt;/a&gt;)?&lt;/p&gt;
&lt;p&gt;For this, let’s go with the setup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;LayerZero on the EVM side&lt;/strong&gt; (Ethereum, Base, Polygon, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IBC (Inter-Blockchain Communication)&lt;/strong&gt; on the Cosmos side&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;so%2C-what-are-we-doing%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;So, what are we doing?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge-to-cosmos/#so%2C-what-are-we-doing%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;EVM Side (Solidity)&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Locks the NFT in a Solidity contract&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Sends a message to the Cosmos chain using LayerZero&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cosmos Side (Rust-CosmWasm)&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Receives the message via an IBC contract&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mints a wrapped NFT on the Cosmos chain&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Similarly, when transferring back:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Burn wrapped NFT on Cosmos&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Send an IBC message to Ethereum&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unlock the original NFT on Ethereum&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We’ll extend our previous &lt;code&gt;BridgeA.sol&lt;/code&gt; to support &lt;strong&gt;sending messages to Cosmos&lt;/strong&gt; via &lt;strong&gt;LayerZero&lt;/strong&gt;.&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.19&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@layerzerolabs/solidity-examples/contracts/lzApp/NonblockingLzApp.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;EVMCosmosBridge&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; NonblockingLzApp &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    ERC721 &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nft&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; admin&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _nft&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NonblockingLzApp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        admin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        nft &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ERC721&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_nft&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;lockNFT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt; destChainId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; receiver&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Not NFT owner&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Transfer NFT to the contract&lt;/span&gt;&lt;br /&gt;        nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Encode user + token ID to send to Cosmos&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Send message to Cosmos via LayerZero&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_lzSend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;destChainId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_nonblockingLzReceive&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint64&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;internal&lt;/span&gt; override &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Unlock NFT on EVM when receiving from Cosmos&lt;/span&gt;&lt;br /&gt;        nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;So, what’s happening here?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The user initiates the process by calling the &lt;code&gt;lockNFT(tokenId, destChainId, receiver)&lt;/code&gt; function. This function requires the user to specify the token ID of the NFT they want to lock, the destination chain ID where the NFT will be sent, and the receiver’s address on the destination chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once the function is called, the specified NFT is &lt;strong&gt;transferred to the smart contract&lt;/strong&gt; and effectively &lt;strong&gt;locked&lt;/strong&gt; within it. This means the user no longer has direct control over the NFT, as it is held securely by the contract.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After locking the NFT, a &lt;strong&gt;LayerZero message&lt;/strong&gt; is created and sent to the Cosmos contract. This message contains encoded information about the user and the token ID, allowing the Cosmos network to understand which NFT is being transferred and who it belongs to.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Upon receiving the message, the Cosmos contract processes it and &lt;strong&gt;mints a wrapped NFT&lt;/strong&gt; for the user. This wrapped NFT represents the original NFT on the Cosmos network, allowing the user to interact with it as if it were the original NFT, while the real NFT remains locked in the EVM contract.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now, lets move to cosmos side. We need to receive IBC messages from Ethereum, mints a &lt;strong&gt;wrapped NFT, and finally&lt;/strong&gt; burn the wrapped NFT when sending back to Ethereum.&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;cosmwasm_std&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    entry_point&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; to_binary&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Binary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Deps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DepsMut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;StdResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SubMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;cw721&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Cw721ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MintMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;crate&lt;/span&gt;&lt;span class=&quot;token module-declaration namespace&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;InstantiateMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// NFT Bridge Contract&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[entry_point]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;instantiate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    deps&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DepsMut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    _env&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    _info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    msg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;InstantiateMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;StdResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Store NFT contract address in state&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;State&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; nft_contract&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nft_contract &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;CONFIG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;storage&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token attribute attr-name&quot;&gt;#[entry_point]&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    deps&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DepsMut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    env&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    msg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;StdResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;match&lt;/span&gt; msg &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ReceiveNFT&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;receive_nft&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; env&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token class-name&quot;&gt;ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;BurnAndSend&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dest_chain_id &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;burn_and_send&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; env&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; info&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dest_chain_id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Receive NFT from Ethereum&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;receive_nft&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DepsMut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; env&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;StdResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;CONFIG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;storage&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; mint_msg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Execute&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        contract_addr&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nft_contract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        msg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;to_binary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Cw721ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Mint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;MintMsg&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            token_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            owner&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;            token_uri&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://metadata-url&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        funds&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;mint_msg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// Burn and Send Back to Ethereum&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;burn_and_send&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DepsMut&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; env&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; info&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageInfo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dest_chain_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;u16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;-&gt;&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;StdResult&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;CONFIG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;deps&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;storage&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; burn_msg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WasmMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Execute&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        contract_addr&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nft_contract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        msg&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;to_binary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Cw721ExecuteMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Burn&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; token_id&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        funds&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token macro property&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Send IBC message back to Ethereum&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; ibc_msg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;IbcMsg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;SendPacket&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        channel_id&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;channel-0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;to_binary&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CrossChainPayload&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; info&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; token_id &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        timeout&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;IbcTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;with_timestamp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;time&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;plus_seconds&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token class-name&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;burn_msg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;add_message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ibc_msg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;So, what’s happening here?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Receive Message&lt;/strong&gt; from Ethereum → This step involves receiving a message from the Ethereum blockchain, which triggers the process of creating a new wrapped NFT on the current blockchain. This NFT represents the original asset from Ethereum.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mint Wrapped NFT&lt;/strong&gt; → After receiving the message, the system mints a new wrapped NFT. This involves executing a minting function that creates a token with a unique ID and assigns it to the specified owner, linking it to metadata that describes the asset.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Burn Wrapped NFT&lt;/strong&gt; when sending back → When the wrapped NFT needs to be returned to Ethereum, it is first burned. This means the token is destroyed on the current blockchain to ensure it cannot be used again, maintaining the integrity of the asset’s representation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Send IBC Message&lt;/strong&gt; back to Ethereum → Finally, an Inter-Blockchain Communication (IBC) message is sent back to Ethereum. This message includes details about the burned token and the intended recipient on Ethereum, ensuring the asset can be accurately reconstructed on its original chain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A bigger problem in cosmos ecosystem is that each project uses their custom developed cw-standard. It’s not a problem per-say but it poses higher risks towards interoperability, vulnerability risks and so on.&lt;/p&gt;
&lt;h2 id=&quot;%F0%9F%94%91-best-practices-%26-optimisations&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;🔑 Best Practices &amp;amp; Optimisations&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge-to-cosmos/#%F0%9F%94%91-best-practices-%26-optimisations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;✅ &lt;strong&gt;Security First:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Add &lt;strong&gt;role-based access&lt;/strong&gt; for admins.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ensure &lt;strong&gt;proper NFT ownership checks&lt;/strong&gt; before burning/minting.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;✅ &lt;strong&gt;Gas Optimisation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;strong&gt;batch transactions&lt;/strong&gt; for handling multiple NFTs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compress payload data before sending cross-chain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;✅ &lt;strong&gt;Scalability:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Support multiple &lt;strong&gt;Cosmos chains&lt;/strong&gt; by using &lt;strong&gt;ICS-721 (NFT standard for Cosmos IBC)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/26f8ca87-06af-47d8-8cbc-a6d68fd02a6f.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;There’s a few token bridges that operate today. Haven’t tested them all myself but they seem reliable.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.axelar.network/blog/cosmos-bridge-explained&quot;&gt;Axelar&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.cosmos.network/gravity-is-an-essential-force-of-the-cosmos-aligning-all-planets-in-orbits-in-the-composable-b1ca17de18cc&quot;&gt;Gravity bridge&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.squidrouter.com/squid-school/Cosmos-to-EVM-swap-guide#section-1&quot;&gt;Squid router&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.evmos.org/protocol&quot;&gt;Evmos&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There might be more.&lt;/p&gt;
&lt;p&gt;The future of Cosmos–EVM bridges is shaping up to be a game-changer, not just for developers but for the entire blockchain space. Right now, we see fragmented ecosystems, Ethereum, with its massive DeFi and NFT markets, and Cosmos, with its modular, interoperable chains. Bridging these two worlds is more than just about moving assets, it’s about unlocking new possibilities for seamless cross-chain interactions. Imagine a future where an NFT minted on Ethereum can be used in a Cosmos-based game, or where DeFi users on Cosmos can access Ethereum’s liquidity pools without even realising they’re using two different chains. That’s the kind of frictionless experience these bridges are working toward.&lt;/p&gt;
&lt;p&gt;One of the biggest shifts we’re likely to see is the rise of generalised cross-chain smart contracts. Right now, most bridges focus on asset transfers. Locking tokens on one side and minting wrapped versions on the other. But what if dApps could execute Solidity contracts from Cosmos-based chains or trigger CosmWasm contracts from Ethereum? That would mean truly decentralised applications that function across multiple chains, rather than being siloed into one ecosystem. We’re already seeing early versions of this with Axelar’s General Message Passing and Cosmos Interchain Accounts, but the technology is still in its early days. Once these solutions become more mature, developers will no longer have to build separate versions of their dApps for different chains. Just build once and let the bridge handle the communication.&lt;/p&gt;
&lt;p&gt;Security is another major aspect that’s bound to improve. Traditional bridges have been some of the biggest targets for hacks, often due to their reliance on trusted relayers or multi-sig setups. The future will likely bring more trustless designs, possibly using zk-SNARKs or other cryptographic proofs to validate transactions across chains without needing intermediaries. This will not only make bridges safer but also reduce centralisation risks. Additionally, optimised gas fee mechanisms could make cross-chain transactions more affordable, encouraging wider adoption.&lt;/p&gt;
&lt;p&gt;Ultimately, the future of Cosmos–EVM bridges is about making blockchain technology feel invisible. Users shouldn’t have to think about which chain they’re on, they should just be able to interact with applications, own assets, and move seamlessly across networks. The end goal isn’t just interoperability, it’s a fully decentralised, interconnected metaverse where blockchains function as one unified system rather than competing silos.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Building a Cross-Chain Bridge</title>
		<link href="https://blog.anirudha.dev/building-a-cross-chain-bridge/"/>
		<updated>2025-02-09T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/building-a-cross-chain-bridge/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;cross-chain bridge&lt;/strong&gt; is a protocol that allows assets, data, or smart contract states to be transferred between two or more decentralised networks. It enables interoperability between different blockchains, ensuring seamless movement of tokens, NFTs, and other digital assets across ecosystems.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, how about we learn how to build a &lt;strong&gt;cross-chain bridge&lt;/strong&gt; that allows NFTs to move between two &lt;strong&gt;EVM-compatible chains&lt;/strong&gt; (e.g., Ethereum &amp;amp; Base, Arbitrum, Optimism &amp;amp; Polygon). Unlike traditional bridges, which use an &lt;strong&gt;off-chain relayer&lt;/strong&gt;, we will implement an &lt;strong&gt;on-chain gateway&lt;/strong&gt; using &lt;a href=&quot;https://layerzero.network/&quot;&gt;LayerZero&lt;/a&gt;, making the process &lt;strong&gt;fully decentralised and trustless&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.anirudha.dev/decentralising-bridges&quot;&gt;&lt;em&gt;If you want to read more about decentralised bridges, check out my previously posted article.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;NFTs and assets are often confined to their originating blockchain, limiting their interoperability and liquidity. A &lt;strong&gt;cross-chain bridge&lt;/strong&gt; enables users to transfer NFTs between different chains, enhancing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Liquidity&lt;/strong&gt; – NFTs can be traded across multiple ecosystems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt; – Users can access different dApps on multiple chains.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt; – Avoid congestion on expensive chains like Ethereum.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The base chain, where an NFT collection originates, plays a crucial role in determining the overall value and functionality of the NFTs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security and Trust&lt;/strong&gt;: The base chain provides the foundational security for the NFT collection. A well-established chain like Ethereum offers robust security features, which can enhance the trustworthiness of the NFTs. While an L2 like Base can offer lower gas fee. There’s several factors that you can think of while deciding the base chain for your NFT collection.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Network Effects&lt;/strong&gt;: The popularity and user base of the base chain can significantly impact the visibility and adoption of the NFT collection. A chain with a large community can drive more engagement and transactions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ecosystem and Tools&lt;/strong&gt;: The base chain often dictates the available development tools and ecosystem support. A rich ecosystem with various dApps and services can add more utility to the NFTs, allowing them to be used in diverse applications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transaction Costs&lt;/strong&gt;: The cost of transactions on the base chain can affect the affordability and frequency of NFT trades. Chains with lower fees can encourage more trading activity, while high fees might deter users.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interoperability&lt;/strong&gt;: The base chain’s compatibility with other chains can determine how easily NFTs can be transferred across different networks. A chain that supports cross-chain protocols can enhance the liquidity and utility of the NFTs. It’s very important that you do not choose a chain which doesn’t allow access to outside network at all.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Innovation and Upgrades&lt;/strong&gt;: The pace of innovation and the ability to implement upgrades on the base chain can influence the long-term viability and features of the NFT collection. Chains that are actively developed and improved can offer more advanced capabilities over time. Never go for a chain, which has stangant development or takes too long to iterate.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;However, we can not expect all the users to remain on any single network. So, we need to prepare for the seemless moving around of assets cross-chain, thereby improving interoperability.&lt;/p&gt;
&lt;p&gt;And of course, there are several approaches to achieve bridging, depending on how you structure your product. Let’s go ahead with a classic approach this time.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.prod.website-files.com/5f75fe1dce99248be5a892db/65675d979a0831972f6df33a_65525236ec04b0422258c81d_6537cb2e61b41e734eb82148_What-Are-Cross-Chain-NFTs__2-V1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; tabindex=&quot;-1&quot;&gt;How It Works &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#how-it-works&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lock the NFT&lt;/strong&gt; on &lt;strong&gt;Chain A&lt;/strong&gt; (BridgeA contract).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Send a cross-chain message&lt;/strong&gt; using LayerZero to &lt;strong&gt;Chain B&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;BridgeB contract receives the message&lt;/strong&gt; and &lt;strong&gt;mints a wrapped NFT&lt;/strong&gt; on Chain B.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To &lt;strong&gt;return the NFT&lt;/strong&gt;, the wrapped NFT is &lt;strong&gt;burned&lt;/strong&gt; on Chain B, and a &lt;strong&gt;message is sent back&lt;/strong&gt; to unlock the original NFT.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;%F0%9F%8F%9B-on-chain-relayer-(our-approach)&quot; tabindex=&quot;-1&quot;&gt;🏛 On-Chain Relayer (Our Approach) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#%F0%9F%8F%9B-on-chain-relayer-(our-approach)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;✅ Fully decentralised, no external trust required.&lt;br /&gt;
✅ All logic is enforced via smart contracts.&lt;br /&gt;
✅ Works with protocols like LayerZero or Axelar.&lt;/p&gt;
&lt;h3 id=&quot;%E2%9A%A1-off-chain-relayer&quot; tabindex=&quot;-1&quot;&gt;⚡ Off-Chain Relayer &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#%E2%9A%A1-off-chain-relayer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;❌ Requires external nodes/validators to confirm transactions.&lt;br /&gt;
❌ Can introduce centralisation and trust assumptions.&lt;br /&gt;
❌ Relayers may become a point of failure.&lt;/p&gt;
&lt;p&gt;Our &lt;strong&gt;on-chain approach&lt;/strong&gt; ensures security and trustlessness by leveraging smart contracts for message passing. We’re using EVM chains for this example so the contracts preferrably written in solidity.&lt;/p&gt;
&lt;h3 id=&quot;nft-contract&quot; tabindex=&quot;-1&quot;&gt;NFT Contract &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#nft-contract&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;First, deploy an &lt;strong&gt;ERC-721 NFT&lt;/strong&gt; contract on &lt;strong&gt;both chains&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.19&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/access/Ownable.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MyNFT&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; ERC721URIStorage&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Ownable &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ERC721&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;MyNFT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MNFT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;mint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; tokenURI&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; onlyOwner &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_safeMint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_setTokenURI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenURI&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        nextTokenId&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;bridge-contract-(chain-a)-%E2%80%93-lock-nft-%26-send-message&quot; tabindex=&quot;-1&quot;&gt;Bridge Contract (Chain A) – &lt;strong&gt;Lock NFT &amp;amp; Send Message&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#bridge-contract-(chain-a)-%E2%80%93-lock-nft-%26-send-message&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Create &lt;code&gt;BridgeA.sol&lt;/code&gt; on &lt;strong&gt;Chain A&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.19&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@layerzerolabs/solidity-examples/contracts/lzApp/NonblockingLzApp.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;BridgeA&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; NonblockingLzApp &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    ERC721 &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nft&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; admin&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _nft&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NonblockingLzApp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        admin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        nft &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ERC721&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_nft&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;lockNFT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt; destChainId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; receiver&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Not NFT owner&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_lzSend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;destChainId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_nonblockingLzReceive&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint64&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;internal&lt;/span&gt; override &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;bridge-contract-(chain-b)-%E2%80%93-receive-%26-mint-wrapped-nft&quot; tabindex=&quot;-1&quot;&gt;Bridge Contract (Chain B) – &lt;strong&gt;Receive &amp;amp; Mint Wrapped NFT&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#bridge-contract-(chain-b)-%E2%80%93-receive-%26-mint-wrapped-nft&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Create &lt;code&gt;BridgeB.sol&lt;/code&gt; on &lt;strong&gt;Chain B&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.19&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@layerzerolabs/solidity-examples/contracts/lzApp/NonblockingLzApp.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;BridgeB&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; ERC721URIStorage&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; NonblockingLzApp &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; admin&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTMinted&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ERC721&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;WrappedNFT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;WNFT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NonblockingLzApp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_lzEndpoint&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        admin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_nonblockingLzReceive&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint64&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;internal&lt;/span&gt; override &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_safeMint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;_setTokenURI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://metadata-url&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTMinted&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; nextTokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        nextTokenId&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;unlocking-nfts-(return-to-chain-a)&quot; tabindex=&quot;-1&quot;&gt;Unlocking NFTs (Return to Chain A) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#unlocking-nfts-(return-to-chain-a)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Modify &lt;code&gt;BridgeB.sol&lt;/code&gt; to &lt;strong&gt;burn the wrapped NFT and send it back&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;burnNFT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt; destChainId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Not NFT owner&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;_burn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;_lzSend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;destChainId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Modify &lt;code&gt;BridgeA.sol&lt;/code&gt; to &lt;strong&gt;release the original NFT&lt;/strong&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_nonblockingLzReceive&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint64&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;internal&lt;/span&gt; override &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;decode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;payload&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    nft&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;let%E2%80%99s-test-our-bridge%3A&quot; tabindex=&quot;-1&quot;&gt;Let’s test our Bridge: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#let%E2%80%99s-test-our-bridge%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Deploy contracts&lt;/strong&gt; on two testnets (say, Base Sepolia &amp;amp; Polygon Amoy).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mint an NFT&lt;/strong&gt; on Chain A.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lock &amp;amp; transfer the NFT&lt;/strong&gt; using the bridge.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Verify minting of wrapped NFT&lt;/strong&gt; on Chain B.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Burn wrapped NFT&lt;/strong&gt; to return to Chain A.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;future-improvements-that-can-be-made%3A&quot; tabindex=&quot;-1&quot;&gt;Future Improvements that can be made: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#future-improvements-that-can-be-made%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;multi-chain-support&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Multi-Chain Support&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#multi-chain-support&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To enhance the functionality and reach of our bridge, we can consider adding support for additional EVM-compatible chains. This would involve integrating with popular networks like Binance Smart Chain, Avalanche, and Fantom, which would allow users to transfer NFTs across a wider range of platforms. Furthermore, expanding beyond EVM-compatible chains to include other blockchain ecosystems, such as Solana, Cosmos, and Polkadot, could significantly broaden the bridge’s capabilities. This expansion would require developing interoperability solutions to handle the unique characteristics and consensus mechanisms of these different blockchains. By doing so, we would enable seamless NFT transfers across a diverse array of blockchain networks, providing users with greater flexibility and access to a wider audience. This strategic enhancement could position our bridge as a leading solution in the rapidly evolving multi-chain NFT landscape.&lt;/p&gt;
&lt;h3 id=&quot;cross-chain-fees&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cross-Chain Fees&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#cross-chain-fees&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Implementing gas abstraction can significantly enhance the user experience by making transactions more seamless and user-friendly. Gas abstraction involves creating a system where users do not need to worry about paying gas fees directly in cryptocurrency. Instead, the system can handle these fees on behalf of the users, possibly by integrating a third-party service or using a relayer network. This approach can simplify the transaction process, especially for users who are not familiar with blockchain technology or do not hold the native cryptocurrency required for gas fees. By abstracting gas fees, developers can create a more intuitive and accessible platform, encouraging broader adoption and reducing barriers for entry into the blockchain ecosystem. Additionally, this can be particularly beneficial in scenarios involving cross-chain interactions, where users might otherwise need to manage multiple cryptocurrencies for gas fees on different chains.&lt;/p&gt;
&lt;h3 id=&quot;decentralised-governance&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Decentralised Governance&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-cross-chain-bridge/#decentralised-governance&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Decentralised Autonomous Organisations (DAOs) can play a crucial role in managing and governing bridge policies. By introducing DAO-controlled bridge policies, we can ensure that the decision-making process is transparent, democratic, and community-driven. This means that all stakeholders, including developers, users, and investors, can participate in proposing, discussing, and voting on changes to the bridge’s operational rules and guidelines. Such a system can enhance trust and accountability, as decisions are made collectively rather than by a centralised authority. Additionally, DAO governance can adapt more quickly to the evolving needs of the community and the market, allowing for more responsive and flexible policy adjustments. By leveraging the power of DAOs, we can create a more resilient and adaptable bridge infrastructure that aligns with the interests and values of its users.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that this was for learning purposes only. The real contracts will have to consider several security issues and vulnerabilities which we’ve assumed here, as part of the happy path. But it’s a start and would love to see at least some of you try it out and build more decentralised bridges. The bridges ecosystem is both quickly evolving and stagnant at the same time. Cross-chain messaging protocols have certainly pulled in a pin off the race for building decent decentralised bridges, but we’ve quite a few improvement yet to be made to achieve true trustless systems.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/4478b09b-d6bd-41b6-bb44-eb8c84b82d53.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>WebAssembly and Python Ecosystem</title>
		<link href="https://blog.anirudha.dev/wasm-py-ecosystem/"/>
		<updated>2025-02-05T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/wasm-py-ecosystem/</id>
		<content type="html">&lt;p&gt;WebAssembly (WASM) is transforming how we run code in lightweight, secure, and cross-platform environments. Initially designed for browsers, WASM has now expanded into &lt;strong&gt;serverless computing&lt;/strong&gt; and &lt;strong&gt;sandboxed environments&lt;/strong&gt;. While languages like Rust and Go have robust WASM support, Python’s dynamic nature makes it challenging to run efficiently in WASM today.&lt;/p&gt;
&lt;h2 id=&quot;why-webassembly-for-serverless-computing%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Why WebAssembly for Serverless Computing?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#why-webassembly-for-serverless-computing%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Near-Instant Startup&lt;/strong&gt;: WASM executes with minimal cold-start time, unlike containers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enhanced Security&lt;/strong&gt;: WASM runs in a sandboxed environment, preventing unauthorised system access.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Compact Footprint&lt;/strong&gt;: WASM modules are lightweight and easy to distribute.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Platform Agnostic&lt;/strong&gt;: Runs seamlessly in browsers, cloud environments, and edge devices.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Network Agnostic&lt;/strong&gt;: WASM can easily run on private clusters and secondary networks, making it the best choice even in Web3.0 ecosystem.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Despite these advantages, running Python efficiently in WASM poses unique challenges. So, let’s explore a few nuances and the current ecosystem looks like. We will then explore how we can work towards improving the current situation taking learnings from rust and go ecosystems.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://hacks.mozilla.org/wp-content/uploads/2019/08/04-01-star-diagram.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;running-python-in-webassembly&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Running Python in WebAssembly&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#running-python-in-webassembly&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;1.-using-pyodide-(cpython-in-wasm)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;1. Using Pyodide (CPython in WASM)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#1.-using-pyodide-(cpython-in-wasm)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Pyodide compiles CPython to WASM, allowing Python to run in browsers and serverless environments.&lt;/p&gt;
&lt;h4 id=&quot;install-pyodide%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Install Pyodide:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#install-pyodide%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;terminal-block&gt;pip install pyodide&lt;/terminal-block&gt;&lt;h4 id=&quot;run-a-python-script-in-pyodide%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Run a Python Script in Pyodide:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#run-a-python-script-in-pyodide%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; pyodide&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_python_code&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    py &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; pyodide&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;loadPyodide&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; py&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;runPython&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;print(&#39;Hello from Pyodide!&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; run_python_code&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;2.-using-pyscript-(python-in-the-browser-with-wasm)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;2. Using PyScript (Python in the Browser with WASM)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#2.-using-pyscript-(python-in-the-browser-with-wasm)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;PyScript simplifies running Python in the browser via Pyodide.&lt;/p&gt;
&lt;h4 id=&quot;run-python-in-html%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Run Python in HTML:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#run-python-in-html%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;code-block lang=&quot;xml&quot;&gt;&lt;pre class=&quot;language-xml&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;defer&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://pyscript.net/latest/pyscript.js&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;py-script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        print(&quot;Hello from PyScript!&quot;)&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;py-script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;3.-using-rustpython-(a-rust-based-python-interpreter-in-wasm)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;3. Using RustPython (A Rust-based Python Interpreter in WASM)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#3.-using-rustpython-(a-rust-based-python-interpreter-in-wasm)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;RustPython, a Python interpreter written in Rust, is optimised for WASM.&lt;/p&gt;
&lt;h4 id=&quot;install-rustpython%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Install RustPython:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#install-rustpython%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;terminal-block&gt;git clone https://github.com/RustPython/RustPython.git
cd RustPython
cargo build --release --target wasm32-wasi&lt;/terminal-block&gt;&lt;h4 id=&quot;run-python-in-rustpython-(wasm)%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Run Python in RustPython (WASM):&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#run-python-in-rustpython-(wasm)%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;token namespace&quot;&gt;rustpython_vm&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Interpreter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;token function-definition function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; interpreter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Interpreter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    interpreter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;enter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token closure-params&quot;&gt;&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;vm&lt;span class=&quot;token closure-punctuation punctuation&quot;&gt;|&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        vm&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;run_code&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;print(&#39;Hello from RustPython!&#39;)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; vm&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;new_scope&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;unwrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;&lt;img src=&quot;https://wasmlabs.dev/static/images/opt/wG1A9IWdyv-757.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Run using WASI runtime:&lt;/p&gt;
&lt;terminal-block&gt;wasmtime rustpython.wasm&lt;/terminal-block&gt;&lt;h2 id=&quot;deploying-a-fastapi-serverless-function-in-wasm&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Deploying a FastAPI Serverless Function in WASM&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#deploying-a-fastapi-serverless-function-in-wasm&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;install-fastapi-and-uvicorn&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Install FastAPI and Uvicorn&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#install-fastapi-and-uvicorn&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;terminal-block&gt;pip install fastapi uvicorn pyodide&lt;/terminal-block&gt;&lt;h3 id=&quot;create-a-main.py&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Create a&lt;/strong&gt; &lt;code&gt;main.py&lt;/code&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#create-a-main.py&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; fastapi &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; FastAPI&lt;br /&gt;&lt;br /&gt;app &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; FastAPI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token decorator annotation punctuation&quot;&gt;@app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;read_root&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hello from WASM!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;run-in-pyodide-(wasm-runtime)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Run in Pyodide (WASM Runtime)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#run-in-pyodide-(wasm-runtime)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; pyodide&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;run_wasm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;br /&gt;    py &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; pyodide&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;loadPyodide&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; py&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;runPythonAsync&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;from main import app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;FastAPI running in WebAssembly&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; run_wasm&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h2 id=&quot;performance-benchmark%3A-wasm-vs.-traditional-containers-vs.-rust%2Fgo-wasm&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Performance Benchmark: WASM vs. Traditional Containers vs. Rust/Go WASM&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#performance-benchmark%3A-wasm-vs.-traditional-containers-vs.-rust%2Fgo-wasm&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://kodekloud.com/blog/content/images/2023/03/Screenshot-2023-03-16-at-23.46.54.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We benchmark &lt;strong&gt;FastAPI deployed in:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WASM (Pyodide)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker (Traditional Serverless Container)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WASM (RustPython)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For fair comparision, we need to also look at wasm ecosystem in rust and go. As the current python wasm ecosystem is lacking, we should also take a look at what’s happening with our neighboring language ecosystems.&lt;/p&gt;
&lt;h3 id=&quot;benchmarking-with-wrk%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Benchmarking with&lt;/strong&gt; &lt;a href=&quot;https://github.com/wg/wrk&quot;&gt;wrk&lt;/a&gt;: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#benchmarking-with-wrk%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;wrk &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;t4 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;c100 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;d30s http&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;localhost&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;8000&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;approx-results%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Approx Results:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#approx-results%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Environment&lt;/th&gt;
&lt;th&gt;Requests/sec&lt;/th&gt;
&lt;th&gt;Avg Latency&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;WASM (Pyodide)&lt;/td&gt;
&lt;td&gt;~500&lt;/td&gt;
&lt;td&gt;10-30ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docker (FastAPI)&lt;/td&gt;
&lt;td&gt;~2000+&lt;/td&gt;
&lt;td&gt;3-5ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WASM (RustPython)&lt;/td&gt;
&lt;td&gt;~800&lt;/td&gt;
&lt;td&gt;7-15ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WASM (Rust)&lt;/td&gt;
&lt;td&gt;~5000+&lt;/td&gt;
&lt;td&gt;&amp;lt;1ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WASM (Go)&lt;/td&gt;
&lt;td&gt;~4000+&lt;/td&gt;
&lt;td&gt;&amp;lt;2ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;so%2C-what-can-be-conclude%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;So, what can be conclude:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/wasm-py-ecosystem/#so%2C-what-can-be-conclude%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rust and Go compiled to WASM vastly outperform Python-based WASM implementations.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Docker offers the best throughput for Python applications, making it ideal for high-performance APIs.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;RustPython outperforms Pyodide but remains slower than Rust/Go.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pyodide is more portable but has higher latency, making it ideal for browser-based execution.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;WASM offers greater security and portability but exhibits slightly higher latency than Docker.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;WebAssembly is an exciting technology for &lt;strong&gt;serverless Python computing&lt;/strong&gt;, offering:&lt;br /&gt;
✅ &lt;strong&gt;Faster startup times&lt;/strong&gt;&lt;br /&gt;
✅ &lt;strong&gt;Enhanced security&lt;/strong&gt;&lt;br /&gt;
✅ &lt;strong&gt;Improved portability&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.docker.com/wp-content/uploads/2024/04/2400x1260_wasm-vs-docker_diagram-01.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;However, for high-performance applications, &lt;strong&gt;Rust and Go WASM implementations&lt;/strong&gt; significantly outperform Python-based approaches. Python WASM is improving rapidly, and as tools like &lt;strong&gt;Pyodide, PyScript, and RustPython&lt;/strong&gt; advance, Python’s role in &lt;strong&gt;serverless WASM environments&lt;/strong&gt; will continue to expand. 🚀&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Minimising Dependencies</title>
		<link href="https://blog.anirudha.dev/cyberspace-os/"/>
		<updated>2025-02-01T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/cyberspace-os/</id>
		<content type="html">&lt;p&gt;In today’s world, technology is often seen as a tool for efficiency, but in reality, it has become a structure of control. Operating systems dictate how we interact with software, app stores determine what we can access, and centralised networks govern our digital presence. The prevailing belief is that these structures are necessary for stability, security, and usability. However, don’t you think that technology should minimise dependencies rather than create them. Instead of being locked into specific platforms, users and developers should be free to interact, build, and own their digital experiences without artificial barriers.&lt;/p&gt;
&lt;p&gt;The future of computing and web can not be walled gardens but open, permissionless, and decentralised protocols. We need to rethink the fundamental design of digital ecosystems, not as closed systems but as universal environments where applications and services are accessible to all, without intermediaries.&lt;/p&gt;
&lt;p&gt;Currently, the digital world is built on a fragmented ecosystem of operating systems, Windows, MacOS, and Linux, each with its own architecture, software packaging formats, and compatibility constraints. Even within Linux, the presence of multiple distributions (Ubuntu, Fedora, Arch, etc.) means that software developers must support various package managers like DEB, RPM, AppImage, Flatpak, Homebrew and Snap. This creates unnecessary complexity and overhead, forcing developers to maintain multiple versions of their applications, resolve dependency conflicts, and manage frequent updates for each platform.&lt;/p&gt;
&lt;p&gt;Beyond operating systems, cloud services and centralised application marketplaces have further deepened our dependence on proprietary infrastructures. Most modern applications rely on centralised servers for authentication, data storage, and computing resources, making them vulnerable to downtime, censorship, and high costs. This centralised model not only limits innovation but also creates gatekeepers who control access to digital services.&lt;/p&gt;
&lt;p&gt;Remeber &lt;a href=&quot;https://www.torproject.org/&quot;&gt;Tor&lt;/a&gt;? “The Onion Router”, an open-source privacy network designed to enable anonymous web browsing. It employs a technique called onion routing, which encrypts user data and bounces it through a series of volunteer-operated servers, or nodes, making it difficult to trace the origin of the traffic. It’s quite popular amongst tech audience but not so much known in the newer generation and is slowly fading away yet still. Why? It’s an incredible network and project.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/a444845f-a92f-465e-9af2-ada7b82d5084.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Because, it several challenges for regular users, primarily related to access, security, performance, and user experience. Many websites block traffic from Tor exit nodes, leading to difficulties accessing certain sites and frequent CAPTCHA prompts. Additionally, users face security risks from potentially malicious exit nodes that could intercept unencrypted traffic. Performance can also be an issue, as Tor often results in slower internet speeds and connection problems due to its complex routing process. Furthermore, the setup of Tor can be complicated for less tech-savvy individuals, which may discourage them from using the network effectively. The association of Tor with illegal activities can also create negative perceptions, impacting users’ willingness to utilise it for legitimate purposes. Overall, while Tor offers enhanced privacy, these challenges can significantly affect the user experience.&lt;/p&gt;
&lt;p&gt;Do we need a network then? No, we already got the tech. Started with TOR, but current web3 vibrant and somewhat crazy ecosystem is already making it’s mark. So, what do we need?&lt;/p&gt;
&lt;h3 id=&quot;how-about-a-new-os%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;How about a new OS?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cyberspace-os/#how-about-a-new-os%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is where CyberSpace OS comes in. A fully decentralised operating system that exists entirely on Web3 networks, offering a new way to interact with technology that is free from the constraints of traditional software and hardware ecosystems. CyberSpace OS, designed to break free from these limitations by offering a truly universal execution environment where applications are deployed directly on-chain as smart contracts or Web3-native dApps. Instead of being tied to a specific OS or hardware architecture, software would exist independently on a decentralised network, accessible from any device.&lt;/p&gt;
&lt;p&gt;With CyberSpace OS:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Developers &lt;strong&gt;deploy once&lt;/strong&gt; on a blockchain and make their applications universally accessible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users interact with applications &lt;strong&gt;without requiring installations, updates, or dependencies&lt;/strong&gt; on traditional OS platforms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The operating system itself is &lt;strong&gt;not a software package but a network protocol&lt;/strong&gt;, meaning that access to applications is fluid, borderless, and truly open.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The storage is partially distributed and partially **InterPlanetary File System (**IPFS) based.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This approach eliminates the need for package managers, compatibility layers, or centralised repositories. Instead of apps being tied to Windows, MacOS, or Linux distributions, they become accessible through decentralised execution environments that are maintained across a distributed network. With smart contract-driven applications, developers no longer need to worry about distribution logistics or maintenance across multiple platforms. Everything is handled in a trustless, automated manner on the blockchain.&lt;/p&gt;
&lt;p&gt;The benefits of a Web3-native OS extend far beyond decentralisation for its own sake. By eliminating dependencies on traditional operating systems and cloud infrastructure, CyberSpace OS drastically reduces costs associated with software development, distribution, and hosting.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cost Efficiency:&lt;/strong&gt; Cloud services are expensive, requiring developers to pay for hosting, maintenance, and bandwidth. With a decentralised network, computing resources can be distributed across nodes, reducing infrastructure costs while ensuring redundancy and uptime.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Performance Gains:&lt;/strong&gt; Instead of routing traffic through centralised data centers, decentralised execution allows applications to run closer to the end user, reducing latency and improving performance. By utilising Layer 2 scaling solutions, zk-rollups, and distributed computing, CyberSpace OS ensures high efficiency without sacrificing security.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simplified Development:&lt;/strong&gt; Developers no longer need to manage different OS versions, dependencies, or update cycles. A single deployment on CyberSpace OS ensures their application is always accessible and up to date.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;building-towards-a-truly-open-cyberspace&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Building Towards a Truly Open CyberSpace&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cyberspace-os/#building-towards-a-truly-open-cyberspace&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The long-term vision of CyberSpace OS is to create a &lt;strong&gt;self-sustaining digital world&lt;/strong&gt;, where users are not just consumers but active participants in an open, decentralised economy. Instead of relying on tech giants for software, storage, and computing, individuals and communities can collectively own and govern the infrastructure they depend on.&lt;/p&gt;
&lt;p&gt;In this world:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Users own their data and identity, free from the control of centralised platforms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Applications run on decentralised networks, ensuring resilience and censorship resistance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The operating system itself is &lt;strong&gt;not an installable product&lt;/strong&gt; but an evolving, trustless environment that runs across the blockchain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/e95fe58b-83ec-4cb6-9b90-0632fc15ce69.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-future-is-protocol-based%2C-not-platform-based&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Future is Protocol-Based, Not Platform-Based&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/cyberspace-os/#the-future-is-protocol-based%2C-not-platform-based&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For decades, the digital landscape has been dominated by platforms. Closed systems that dictate how technology is used, who has access, and how data flows. CyberSpace OS proposes an alternative: a world where &lt;strong&gt;protocols&lt;/strong&gt; replace platforms, ensuring that applications, services, and digital interactions remain open, permissionless, and universally accessible.&lt;/p&gt;
&lt;p&gt;This is not just an evolution of computing, it’s a fundamental shift in how we think about technology. By removing artificial dependencies and embracing decentralised, trustless networks, we can build a truly open CyberSpace. One where innovation is unhindered, costs are minimised, and users have complete control over their digital lives.&lt;/p&gt;
&lt;p&gt;The time has come to break free from outdated models and build an operating system for the future. CyberSpace OS is not just another alternative. It is the foundation for a new digital era!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Decentralised Identity</title>
		<link href="https://blog.anirudha.dev/did/"/>
		<updated>2025-01-19T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/did/</id>
		<content type="html">&lt;p&gt;As the digital world transitions to Web3, decentralisation promises to redefine how we interact online securely, privately, and without intermediaries. At the heart of this revolution lies &lt;strong&gt;Decentralised Identity (DID)&lt;/strong&gt;, a technology aimed at giving users complete control over their identity and interactions in the decentralised ecosystem. Let’s explore the world of DIDs and the impact it can have on our day-to-day life.&lt;/p&gt;
&lt;p&gt;In the Web2 paradigm, identity is centralised. Platforms like Google, Facebook, and Apple dominate authentication and identity management. A typical Web2 authentication flow involves:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Credential Storage:&lt;/strong&gt; Users create accounts on each platform, storing sensitive information like passwords and personal data.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Centralised Control:&lt;/strong&gt; Platforms manage, validate, and store user identities, often sharing data with third parties.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security and Privacy Risks:&lt;/strong&gt; These centralised models are prone to breaches, data misuse, and lack transparency.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This fragmented and insecure approach calls for a shift toward a decentralised and user-controlled identity system.&lt;/p&gt;
&lt;h1 id=&quot;what-is-did%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;What is DID?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/did/#what-is-did%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;DID is a self-sovereign identity system that allows users to create and control their identity without relying on centralised entities. A DID is a unique identifier tied to a cryptographic key, resolving to a DID Document stored on decentralised networks.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.w3.org/TR/did-core/diagrams/parts-of-a-did.svg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A DID might look like &lt;code&gt;did:ethr:0x1234...abcd&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It is portable, privacy-preserving, and interoperable across platforms and chains.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/1adfb744-0c51-4627-8344-af0edcaad35b.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;DIDs significantly improve user experience by addressing critical pain points.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unified Identity Across Platforms:&lt;/strong&gt; A single DID replaces the need for multiple accounts. Users can log in to various apps using the same identity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enhanced Privacy:&lt;/strong&gt; DIDs minimise data sharing. Users can verify their identity without exposing personal information using verifiable credentials.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;True Ownership:&lt;/strong&gt; Unlike centralised accounts, users own their DID, data, and assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain Interoperability:&lt;/strong&gt; DIDs work seamlessly across blockchains, enabling a consistent user experience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gasless Transactions:&lt;/strong&gt; Relayers linked to a DID can abstract gas fees, improving accessibility.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/15389678-f607-4b53-b129-42af53ee15a7.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h1 id=&quot;creating-and-using-a-did&quot; tabindex=&quot;-1&quot;&gt;Creating and Using a DID &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/did/#creating-and-using-a-did&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Users connect their Ethereum wallet (e.g., MetaMask) to a service that registers a DID, like a smart contract-based DID Registry.&lt;/p&gt;
&lt;p&gt;Here’s a basic smart contract for an Ethereum-based DID Registry:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DIDRegistry&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; dids&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;DIDRegistered&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; did&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;registerDID&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; _did&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bytes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dids&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;DID already exists&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        dids&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _did&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;DIDRegistered&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; _did&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getDID&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; dids&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;_user&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Applications resolve your DID to verify your identity and retrieve associated credentials, ensuring secure, password-free login.&lt;/p&gt;
&lt;p&gt;Your DID’s associated data, like profile information, is stored on decentralised networks such as Ceramic or IPFS, ensuring ownership and privacy.&lt;/p&gt;
&lt;p&gt;Imagine a gaming app, that integrates DID for seamless user experiences:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Onboarding:&lt;/strong&gt; Users log in with their Ethereum wallet, and the app generates their DID (&lt;code&gt;did:ethr:0x123...&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Platform Interactions:&lt;/strong&gt; Achievements earned in one game are verifiable credentials usable across other games.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Social Features:&lt;/strong&gt; Users add friends via their DID or ENS name (e.g., &lt;code&gt;GamerX.eth&lt;/code&gt;) and engage in encrypted chats using DIDComm.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gasless Play:&lt;/strong&gt; The app abstracts gas fees, ensuring smooth gameplay.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;ens-and-.eth-domains%3A-simplifying-did&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;ENS and .eth Domains: Simplifying DID&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/did/#ens-and-.eth-domains%3A-simplifying-did&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Ethereum Name Service (ENS)&lt;/strong&gt; bridges DIDs and user-friendliness. ENS translates long wallet addresses or DIDs into readable names like &lt;code&gt;john.eth&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;What .eth Means:&lt;/strong&gt; It’s a human-readable domain linked to a DID or wallet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt; ENS uses smart contracts to map &lt;code&gt;john.eth&lt;/code&gt; to an Ethereum address, which can be further linked to a DID for interoperability.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;evolution-of-dids&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Evolution of DIDs&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/did/#evolution-of-dids&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;DIDs make interacting with multiple blockchains simple by providing a unified identity layer. Regardless of whether an app runs on Ethereum, Polygon, or another chain, users only need one DID.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example Use Case:&lt;/strong&gt;&lt;br /&gt;
In a gaming app, a DID enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Asset purchases on Ethereum.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Gameplay interactions on Polygon.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A unified user profile across both chains.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://www.w3.org/TR/did-core/diagrams/did_detailed_architecture_overview.svg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Account abstraction turns wallets into programmable entities. When paired with a DID, users gain access to features like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gasless Transactions&lt;/strong&gt; via relayer services.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom Authentication&lt;/strong&gt; with biometrics or social recovery.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Programmable Wallets&lt;/strong&gt; tied to their DID for automated actions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Several active works going on in the field of DIDs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;W3C Standards:&lt;/strong&gt; Ongoing efforts to standardise DID and Verifiable Credentials. &lt;a href=&quot;https://www.w3.org/TR/did-core/&quot;&gt;Read more here.&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Layer 2 Scaling:&lt;/strong&gt; Optimising DID operations with zk-Rollups and optimistic rollups.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Social Recovery Models:&lt;/strong&gt; Community-based wallet recovery mechanisms tied to DIDs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain Abstraction:&lt;/strong&gt; Projects like Axelar and LayerZero are exploring DID integration for seamless multichain interoperability.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;challenges%3A&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Challenges:&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/did/#challenges%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Adoption:&lt;/strong&gt; Many apps still rely on centralised account systems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Standardisation:&lt;/strong&gt; Consistent DID implementation across platforms and chains is essential.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/75899c94-d88d-4b11-b37b-77c66aff285f.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As Web3 evolves, DIDs will play a pivotal role in bridging the gap between user experience and decentralisation. By abstracting away the complexities of blockchain interactions, DIDs empower users with control over their identities, assets, and data while enabling cross-platform interoperability.&lt;/p&gt;
&lt;p&gt;While DID is transformative, its adoption depends on achieving a balance between technical complexity and user experience. The goal is a Web3 ecosystem where users can easily create, use, and manage their decentralised identities without worrying about the underlying technology, a future where identity is truly in the hands of the user.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Understanding Liquidity Pools in Web3</title>
		<link href="https://blog.anirudha.dev/liquidity-pool/"/>
		<updated>2025-01-10T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/liquidity-pool/</id>
		<content type="html">&lt;p&gt;Liquidity pools in the context of traditional finance evolved over centuries, rooted in mechanisms designed to ensure that buyers and sellers can transact with minimal price volatility and at the right time. These mechanisms laid the foundation for the more modern, decentralized liquidity pools found in today’s digital finance (DeFi). In the early stages of financial markets, liquidity was primarily provided by market makers, typically wealthy individuals or institutions, who were willing to hold inventories of assets (stocks, bonds, commodities) and facilitate trades by ensuring there were always both buyers and sellers for each asset. In the 17th century, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Euronext_Amsterdam&quot;&gt;&lt;strong&gt;Amsterdam Stock Exchange&lt;/strong&gt;&lt;/a&gt; (established in 1602) was one of the first venues where market makers helped provide liquidity by buying and selling stocks of the &lt;strong&gt;Dutch East India Company&lt;/strong&gt;. This early form of liquidity provision was crucial in establishing stock trading as a viable form of investment. As financial markets grew throughout the 20th century, exchanges like the &lt;strong&gt;New York Stock Exchange (NYSE)&lt;/strong&gt; (founded in 1792) and the &lt;strong&gt;London Stock Exchange (LSE)&lt;/strong&gt; (founded in 1801) became central hubs for securities trading. These exchanges facilitated liquidity by creating centralized venues where buyers and sellers could meet.&lt;/p&gt;
&lt;p&gt;During the 1960s to 1980s, institutional investors such as mutual funds, pension funds, and hedge funds began playing a more significant role in managing large pools of capital. These funds were used to buy and sell a variety of assets, providing additional liquidity to financial markets. &lt;strong&gt;Mutual funds&lt;/strong&gt; and &lt;strong&gt;Exchange-Traded Funds (ETFs)&lt;/strong&gt;, for example, pooled capital from individual investors and made it easier for smaller investors to access large-scale liquidity. The creation of the &lt;strong&gt;SPDR S&amp;amp;P 500 ETF&lt;/strong&gt; in 1993 by State Street Global Advisors allowed institutional investors to pool their capital and give individual investors access to liquidity through the trading of ETF shares. In the 1970s, &lt;strong&gt;money market funds&lt;/strong&gt; emerged as a way for investors to earn interest while providing liquidity to short-term debt markets. These funds pooled capital from many individual investors and invested in low-risk, short-term debt instruments like Treasury bills, certificates of deposit (CDs), and commercial paper. The &lt;strong&gt;Vanguard Prime Money Market Fund&lt;/strong&gt;, launched in the 1970s, became one of the largest money market funds, pooling capital and providing liquidity to short-term debt markets.&lt;/p&gt;
&lt;p&gt;In the 1980s and beyond, derivatives markets like &lt;strong&gt;futures&lt;/strong&gt;, &lt;strong&gt;options&lt;/strong&gt;, and &lt;strong&gt;swaps&lt;/strong&gt; created sophisticated ways to hedge risks and add liquidity to underlying assets. These markets allowed traders to take positions on assets without directly buying or selling the asset itself, increasing liquidity and providing more ways to trade. The &lt;strong&gt;Chicago Mercantile Exchange (CME)&lt;/strong&gt; became a major hub for the trading of derivatives, offering futures contracts on commodities, financial instruments, and even stock indexes, which provided added liquidity and price discovery. The 2008 global financial crisis highlighted the importance of liquidity in maintaining financial stability. Central banks stepped in to provide liquidity to the banking system through &lt;strong&gt;quantitative easing (QE)&lt;/strong&gt; and other monetary policy tools. By buying assets such as government bonds, central banks created “liquidity pools” to stabilize financial markets and prevent a collapse of the banking system. The &lt;strong&gt;U.S. Federal Reserve&lt;/strong&gt; implemented &lt;strong&gt;QE&lt;/strong&gt; to inject liquidity into the economy by purchasing U.S. Treasury bonds and mortgage-backed securities (MBS). This action helped stabilize the financial system and provided banks with more liquidity to operate.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/858bf72f-3446-48b2-b53d-7353f5795a3e.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;A liquidity pool in Web3 refers to a collection of funds locked into a smart contract to facilitate decentralized trading, lending, and other financial activities on blockchain networks. It’s a foundational concept in decentralized finance (DeFi), enabling platforms to function without relying on traditional intermediaries like banks or centralized exchanges.&lt;/p&gt;
&lt;p&gt;At its core, a liquidity pool provides liquidity (available assets) for decentralized exchanges (DEXs) or other DeFi protocols, allowing users to trade assets efficiently. Popularized by platforms like Uniswap and Balancer, liquidity pools have become integral to the success of the decentralized ecosystem.&lt;/p&gt;
&lt;p&gt;Liquidity pools eliminate the need for traditional financial intermediaries like banks, brokers, or centralized exchanges. Instead, they use smart contracts to automate transactions and ensure trustless operations. This reduces costs, speeds up processes, and democratizes access to financial tools.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Decentralized Exchanges (DEXs)&lt;/strong&gt;: Platforms like Uniswap rely on liquidity pools for trading, replacing the traditional order book model with an automated market maker (AMM).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Trustless Transactions&lt;/strong&gt;: Users can trade directly from their wallets without trusting a centralized entity with custody of their funds.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Liquidity pools enable 24/7 trading without the constraints of traditional market hours. Unlike centralized systems, which can experience downtime due to technical or operational issues, DeFi platforms operate as long as the blockchain they’re built on is running. This ensures constant liquidity and access for users worldwide.&lt;/p&gt;
&lt;p&gt;Anyone with internet access and compatible assets can participate in liquidity pools, whether as a trader, liquidity provider, or investor. This inclusivity empowers individuals in regions with limited access to traditional financial systems, fostering global financial inclusion. Liquidity pools provide access to global markets for individuals who may lack bank accounts but have access to cryptocurrency. They allow seamless trading and liquidity provisioning across borders without additional fees or delays.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/aadb8770-fa8b-4f6c-a34a-3e7f03eee902.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Traditional exchanges rely on order books where buyers and sellers must match their orders. This process can lead to delays, especially for low-volume assets. Liquidity pools eliminate this dependency by enabling instant trades based on the pool’s available liquidity and AMM pricing model. Even obscure tokens with limited trading activity can find liquidity through pools, fostering a more vibrant and diverse market.&lt;/p&gt;
&lt;p&gt;Liquidity pools offer opportunities for users to earn passive income by becoming liquidity providers (LPs). In return for supplying assets to the pool, LPs earn a share of the transaction fees and, in many cases, additional rewards in the form of governance or incentive tokens.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Yield Farming&lt;/strong&gt;: Many DeFi platforms introduce farming programs where LPs can stake their LP tokens to earn even higher rewards.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Compounding Rewards&lt;/strong&gt;: By reinvesting earnings, LPs can maximize their returns over time.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://m.foolcdn.com/media/dubs/images/yield-farming-infographic.width-600.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In traditional finance, centralized entities or whales (large holders of assets) can manipulate markets by controlling liquidity. Liquidity pools, governed by smart contracts and often decentralized communities, mitigate this risk by spreading liquidity among many participants and operating transparently.&lt;/p&gt;
&lt;p&gt;Liquidity pools enable innovative financial products and services that were not feasible in traditional systems, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Token Swaps&lt;/strong&gt;: Instant swapping between tokens without needing a counterpart.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Synthetic Assets&lt;/strong&gt;: Creating and trading assets that mirror real-world commodities, stocks, or other financial instruments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Flash Loans&lt;/strong&gt;: Borrowing assets instantly without collateral, provided the loan is repaid within the same transaction block.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Liquidity pools help bootstrap new projects and tokens by providing initial liquidity, enabling seamless trading and adoption from day one. Projects can create liquidity pools to ensure users can easily buy and sell their tokens, fostering early adoption. Many platforms distribute governance tokens to LPs, encouraging decentralized decision-making and long-term community involvement. In centralized systems, trading and financial activities can be restricted by governments or institutions. Liquidity pools, hosted on decentralized blockchains, are resistant to censorship, ensuring that users retain their financial sovereignty. Liquidity pools increase the usability of tokens within an ecosystem. By locking tokens in pools, they gain immediate utility as tradeable and yield-generating assets. Even highly volatile tokens find utility and stability when paired in liquidity pools, as they facilitate trading and incentivize holders to provide liquidity.&lt;/p&gt;
&lt;h2 id=&quot;how-does-it-work%3F&quot; tabindex=&quot;-1&quot;&gt;How does it work? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#how-does-it-work%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A liquidity pool typically consists of two assets paired together (e.g., ETH/USDT). These pools operate using Automated Market Makers (AMMs), which determine the price of assets within the pool based on supply and demand using mathematical formulas.&lt;/p&gt;
&lt;h4 id=&quot;example-of-amm-formula%3A&quot; tabindex=&quot;-1&quot;&gt;Example of AMM Formula: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#example-of-amm-formula%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;One common formula is the constant product formula:&lt;/p&gt;
&lt;p&gt;$$x⋅y=k$$&lt;/p&gt;
&lt;p&gt;Where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;x&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;y&lt;/strong&gt;&lt;/em&gt; are the quantities of the two assets in the pool.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;k&lt;/strong&gt;&lt;/em&gt; is a constant.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When a user trades, the AMM adjusts the asset quantities, ensuring the product &lt;em&gt;&lt;strong&gt;k&lt;/strong&gt;&lt;/em&gt; remains constant. This model ensures liquidity at any price point.&lt;/p&gt;
&lt;h4 id=&quot;steps-for-trading%3A&quot; tabindex=&quot;-1&quot;&gt;Steps for Trading: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#steps-for-trading%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;A user sends one asset (e.g., ETH) to the pool.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The pool provides the equivalent value of the other asset (e.g., USDT) based on the AMM formula.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The trade is executed instantly via the smart contract.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;starting-and-participating-in-a-liquidity-pool&quot; tabindex=&quot;-1&quot;&gt;Starting and Participating in a Liquidity Pool &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#starting-and-participating-in-a-liquidity-pool&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Starting a Pool&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Identify a platform supporting liquidity pools (e.g., Uniswap, PancakeSwap, Balancer).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose a pair of assets and decide the initial liquidity ratio.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deposit the assets into the smart contract to initialize the pool.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pay the associated gas fees for the transaction.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Participating in an Existing Pool&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Select a pool and review its metrics (e.g., volume, fees, and liquidity).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deposit an equal value of the two assets into the pool.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Receive liquidity provider (LP) tokens, which represent your share of the pool.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://miro.medium.com/v2/resize:fit:1400/1*PMwLT1BZstsRQ4baV-eMgw.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;risks-associated-with-liquidity-pools&quot; tabindex=&quot;-1&quot;&gt;Risks Associated with Liquidity Pools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#risks-associated-with-liquidity-pools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While liquidity pools offer significant opportunities, they also come with inherent risks. Understanding these risks is crucial for anyone looking to participate as a trader, investor, or liquidity provider (LP).&lt;/p&gt;
&lt;h3 id=&quot;impermanent-loss&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Impermanent Loss&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#impermanent-loss&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Impermanent loss occurs when the price of the assets in a liquidity pool changes relative to their price when you initially deposited them. The loss is “impermanent” because it only materializes if you withdraw your assets before the prices revert. Suppose you deposit 1 ETH and 100 USDT into a pool (assuming ETH is priced at $100). If ETH’s price rises to $200, the AMM adjusts the pool’s asset ratio to maintain balance. When you withdraw, you might receive less ETH than expected, and the value of your holdings may be lower than if you had simply held the assets separately.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Who is Most Affected?&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;LPs in volatile asset pairs are more susceptible.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pools with stablecoins or correlated assets (e.g., USDC/DAI) experience minimal impermanent loss.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Opt for pools with stable or correlated assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Monitor asset prices and withdraw strategically when the market stabilizes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;smart-contract-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Smart Contract Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#smart-contract-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools rely on smart contracts, which are vulnerable to bugs, coding errors, or malicious exploits. A single vulnerability can lead to a complete loss of funds in the pool. For example, exploiters can use large, instant loans to manipulate the pool’s pricing algorithm, draining assets called &lt;strong&gt;Flash Loan Attack&lt;/strong&gt;. Another classic vulnerability called &lt;strong&gt;reentrancy attack&lt;/strong&gt; where an attacker repeatedly calls a function before its initial execution is completed. In 2020, the Harvest Finance hack exploited an imperfection in the protocol, leading to a loss of over $24 million.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Participate in pools from reputable platforms that undergo regular audits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Diversify your liquidity across multiple pools to reduce exposure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;slippage-and-price-impact&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Slippage and Price Impact&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#slippage-and-price-impact&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Large trades can cause significant changes in the price of assets within the pool. This is especially prevalent in pools with low liquidity.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Slippage&lt;/strong&gt;: The difference between the expected price of a trade and the actual price executed.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Price Impact&lt;/strong&gt;: For large trades, the AMM may shift the pool’s asset ratio significantly, causing unfavorable trading conditions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Trade in high-liquidity pools where slippage is minimal.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Break large trades into smaller chunks to reduce price impact.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;market-volatility-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Market Volatility Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#market-volatility-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Crypto markets are notoriously volatile, and sudden price swings can impact the value of your pool holdings or trading activities. A sudden market crash might cause users to withdraw funds all together, depleting liquidity and leading to higher slippage for trades.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Choose pools with stable or less volatile assets if you’re risk-averse.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Keep a close eye on market conditions and adjust your strategy accordingly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;regulatory-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Regulatory Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#regulatory-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Regulatory frameworks for DeFi are still evolving. Participating in liquidity pools can expose users to legal and compliance risks, especially in regions with unclear or restrictive crypto regulations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Potential Issues&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;KYC/AML compliance requirements may conflict with the anonymous nature of DeFi.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;New laws could classify LP tokens or governance tokens as securities, subjecting participants to additional legal obligations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jurisdictional Risks&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some countries may outright ban or heavily regulate DeFi platforms, leaving users in legal limbo.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Stay informed about the regulations in your jurisdiction.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Consider using platforms that comply with regional laws and offer transparency.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;liquidity-mining-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Liquidity Mining Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#liquidity-mining-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity mining, where platforms offer extra rewards (e.g., governance tokens) to incentivize LPs, can sometimes lead to unsustainable economic models.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Risks&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;High rewards may attract short-term participants, leading to “farm and dump” behavior where tokens lose value rapidly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Protocols offering unrealistic returns may collapse, leaving LPs with worthless assets.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Focus on protocols with sustainable reward models.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Diversify your positions across different pools and platforms.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;governance-and-protocol-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Governance and Protocol Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#governance-and-protocol-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;DeFi platforms often allow governance token holders to vote on changes. While this promotes decentralization, it can also introduce risks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Potential Issues&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Governance takeovers: A whale or coordinated group could gain control of the protocol and implement self-serving changes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Poor decision-making: Ineffective governance decisions may lead to changes that negatively impact liquidity providers or traders.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Participate in governance if you hold tokens.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose platforms with robust and active communities.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;platform-specific-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Platform-Specific Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#platform-specific-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Every DeFi platform operates differently, and some may have unique risks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unforeseen Risks&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Algorithmic errors in the AMM formula.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Failures in price oracles leading to incorrect pricing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dependency on Blockchain&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Congestion or high gas fees on the underlying blockchain (e.g., Ethereum) can make transactions prohibitively expensive.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Research the platform thoroughly before depositing assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prefer platforms with a proven track record and robust infrastructure.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;rug-pulls-and-exit-scams&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Rug Pulls and Exit Scams&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#rug-pulls-and-exit-scams&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Rug pulls occur when the creators of a liquidity pool or DeFi project withdraw all liquidity or funds, leaving participants with worthless assets. Unscrupulous developers launch a pool with enticing rewards, then drain the funds once liquidity is locked in.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Signs of Potential Rug Pulls&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Anonymous or unverifiable team members.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of audits or transparency about smart contracts.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of project expansion and clear roadmap ahead.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Avoid newly launched or unaudited projects.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose established platforms with strong reputations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;governance-of-liquidity-pools&quot; tabindex=&quot;-1&quot;&gt;Governance of Liquidity Pools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#governance-of-liquidity-pools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Governance of liquidity pools is crucial for maintaining the integrity, functionality, and adaptability of DeFi ecosystems. By balancing decentralization with effective decision-making structures, liquidity pools can ensure sustainable growth while empowering their communities to shape their future. As such, it’s a much bigger topic to be covered in this article, so I’ll probably take it up in a following article. Let’s cover a few case studies in the meantime:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Uniswap :&lt;/strong&gt; Uses UNI tokens for governance, allowing the community to vote on key protocol upgrades and treasury allocations. A highly decentralized model, but participation rates remain a concern.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://docs.uniswap.org/assets/images/anatomy-d22fb7ab46013a1195f086ee672468c7.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Balancer&lt;/strong&gt;: Balancer’s governance allows LPs to vote on pool parameters, incentivization strategies, and protocol improvements. Known for its innovative approach to managing multi-asset pools.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/91031d3f-e6fa-49b7-99b2-671bc4d52063.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SushiSwap&lt;/strong&gt;: SushiSwap’s governance is notable for its community-driven decision-making and frequent use of governance tokens to shape the protocol’s future.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/4c8f7a59-b477-47b0-b951-6e4fdd539701.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;regulations-and-legalities&quot; tabindex=&quot;-1&quot;&gt;Regulations and Legalities &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#regulations-and-legalities&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;KYC/AML Compliance&lt;/strong&gt;: Some jurisdictions may require Know Your Customer (KYC) and Anti-Money Laundering (AML) measures for liquidity providers and DeFi protocols.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Taxation&lt;/strong&gt;: Earnings from liquidity pools are often classified as taxable income or capital gains.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Securities Laws&lt;/strong&gt;: In certain regions, LP tokens or governance tokens might be classified as securities, subjecting them to stringent regulations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Consumer Protection&lt;/strong&gt;: Protocols must ensure transparency about risks to protect participants from fraud or misinformation.&lt;/p&gt;
&lt;h2 id=&quot;use-cases-of-liquidity-pools&quot; tabindex=&quot;-1&quot;&gt;Use Cases of Liquidity Pools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#use-cases-of-liquidity-pools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;decentralized-exchanges-(dexs)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Decentralized Exchanges (DEXs)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#decentralized-exchanges-(dexs)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools power automated market makers (AMMs), which are the backbone of decentralized exchanges. Instead of relying on traditional order books, AMMs use liquidity pools to execute trades based on mathematical formulas.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Uniswap&lt;/strong&gt; is one of the most popular DEXs, utilizing liquidity pools for trading various token pairs like ETH/USDT or DAI/USDC. Traders benefit from continuous liquidity, while liquidity providers earn a share of transaction fees. Uniswap’s innovative AMM model sparked the growth of DeFi and inspired similar platforms. Similar to Uniswap, &lt;strong&gt;Sushiswap&lt;/strong&gt; adds features like yield farming and governance participation for liquidity providers. SushiSwap incentivizes liquidity providers through its native token, SUSHI.&lt;/p&gt;
&lt;h3 id=&quot;yield-farming-and-liquidity-mining&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Yield Farming and Liquidity Mining&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#yield-farming-and-liquidity-mining&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools enable yield farming, where participants earn rewards by staking their assets in pools. Liquidity mining further incentivizes users by distributing governance tokens to liquidity providers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PancakeSwap&lt;/strong&gt;, a leading DEX on the Binance Smart Chain, rewards LPs with CAKE tokens. Users can “farm” additional rewards by staking LP tokens in Syrup Pools, amplifying their earnings. &lt;strong&gt;Curve Finance&lt;/strong&gt; specializes in stablecoin pools, allowing users to earn yields by providing liquidity to pairs like USDC/DAI or USDT/USDC. Curve’s CRV token is distributed as a reward, with higher rewards for users who lock their tokens for governance participation.&lt;/p&gt;
&lt;h3 id=&quot;cross-chain-swaps&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cross-Chain Swaps&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#cross-chain-swaps&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools enable seamless asset transfers across different blockchains, breaking down silos between ecosystems.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ThorChain&lt;/strong&gt; emerged as a cross-chain liquidity protocol that allows users to swap assets like BTC, ETH, and BNB without relying on centralized exchanges. Liquidity pools facilitate swaps by using native assets on both chains, ensuring trustless and efficient transactions. &lt;strong&gt;Multichain (formerly AnySwap)&lt;/strong&gt; offers liquidity pools to bridge assets across multiple blockchains, including Ethereum, Binance Smart Chain, and Avalanche.&lt;/p&gt;
&lt;h3 id=&quot;synthetic-asset-creation&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Synthetic Asset Creation&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#synthetic-asset-creation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools are used to back synthetic assets, which are tokenized representations of real-world assets like stocks, commodities, or indices.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Synthetix&lt;/strong&gt; enables the creation of synthetic assets (Synths) like sUSD (synthetic USD) and sBTC (synthetic Bitcoin). Liquidity pools ensure the collateralization of these Synths, allowing users to trade them on decentralized platforms. &lt;strong&gt;Mirror Protocol&lt;/strong&gt; allows users to mint and trade synthetic assets that track the price of real-world stocks, such as mTSLA (mirrored Tesla). Liquidity pools enable trading and collateralization, providing exposure to traditional markets in a decentralized manner.&lt;/p&gt;
&lt;h3 id=&quot;lending-and-borrowing-protocols&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Lending and Borrowing Protocols&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#lending-and-borrowing-protocols&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools also support lending and borrowing platforms, where users deposit assets to earn interest or borrow against their deposits.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Aave&lt;/strong&gt; operates liquidity pools where users can lend assets like ETH, DAI, or USDC and earn interest. Borrowers can use their deposits as collateral to borrow other assets, creating a decentralized credit market. &lt;strong&gt;Compound&lt;/strong&gt; allows users to supply assets into liquidity pools and earn COMP tokens as rewards. The protocol dynamically adjusts interest rates based on supply and demand in the pool.&lt;/p&gt;
&lt;h3 id=&quot;token-launchpads-and-initial-dex-offerings-(idos)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Token Launchpads and Initial DEX Offerings (IDOs)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#token-launchpads-and-initial-dex-offerings-(idos)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools play a critical role in token launchpads, where new projects launch their tokens and ensure liquidity from day one. &lt;strong&gt;Balancer&lt;/strong&gt;’s liquidity pools are used for token launch events, offering flexible weight configurations for new tokens and stable assets. Projects can set up weighted pools to control price discovery during token launches. &lt;strong&gt;Polkastarter&lt;/strong&gt; uses liquidity pools for IDOs, enabling projects to raise funds while providing liquidity for their tokens.&lt;/p&gt;
&lt;h3 id=&quot;stablecoin-stability-and-arbitrage&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Stablecoin Stability and Arbitrage&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#stablecoin-stability-and-arbitrage&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools help maintain the stability of stablecoins by facilitating arbitrage opportunities and reducing price deviations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Curve Finance&lt;/strong&gt;’s stablecoin-focused liquidity pools minimize slippage and impermanent loss, making them ideal for stablecoin trades. Arbitrage traders help keep stablecoin prices aligned across platforms by leveraging Curve’s efficient pools. &lt;strong&gt;MakerDAO (DAI)&lt;/strong&gt;’s liquidity pools on platforms like Uniswap and Curve ensure stable and efficient trading, helping maintain its peg to the US dollar.&lt;/p&gt;
&lt;h3 id=&quot;revenue-generation-for-daos-and-protocols&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Revenue Generation for DAOs and Protocols&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#revenue-generation-for-daos-and-protocols&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Protocols can create liquidity pools to generate revenue for their treasuries, ensuring sustainable growth and development.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Yearn Finance&lt;/strong&gt;’s Vaults use liquidity pools to optimize yield farming strategies, generating revenue for the protocol and its users. Governance ensures that funds are reinvested in development and user incentives. &lt;strong&gt;Bancor&lt;/strong&gt;’s liquidity pools not only generate fees but also protect LPs from impermanent loss through its single-sided staking mechanism.&lt;/p&gt;
&lt;h3 id=&quot;insurance-in-defi&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Insurance in DeFi&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#insurance-in-defi&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools are being used to back decentralized insurance protocols, where participants earn rewards by providing collateral for insurance claims.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nexus Mutual&lt;/strong&gt; uses liquidity pools to underwrite insurance policies for smart contract risks. Liquidity providers earn returns from premiums paid by users seeking coverage. &lt;strong&gt;InsurAce&lt;/strong&gt; pools provide coverage for risks like smart contract failures, stablecoin de-pegging, and more, offering diversified risk management options.&lt;/p&gt;
&lt;h3 id=&quot;gaming-and-nfts&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Gaming and NFTs&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#gaming-and-nfts&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Liquidity pools are now being integrated into gaming and NFT platforms, enabling new financial models within these ecosystems.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Axie Infinity&lt;/strong&gt;’s liquidity pools allow users to trade &lt;strong&gt;AXS&lt;/strong&gt; and &lt;strong&gt;SLP&lt;/strong&gt; tokens, which are core to the game’s economy. Liquidity providers earn fees from the vibrant trading activity driven by the game’s popularity. &lt;strong&gt;Rarible&lt;/strong&gt; pools facilitate liquidity for trading NFTs, ensuring users can buy and sell digital art seamlessly. The protocol rewards participants with &lt;strong&gt;RARI&lt;/strong&gt; tokens for providing liquidity.&lt;/p&gt;
&lt;h2 id=&quot;variations-of-liquidity-pools&quot; tabindex=&quot;-1&quot;&gt;Variations of Liquidity Pools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/liquidity-pool/#variations-of-liquidity-pools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Liquidity pools have evolved beyond the basic structures used in early decentralized finance (DeFi) protocols. Over time, developers and researchers have introduced various innovations, tailoring liquidity pools to specific use cases, improving capital efficiency, and reducing risks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dynamic Pools&lt;/strong&gt;: Pools like Balancer allow more than two assets and adjust the weight of each asset dynamically.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stablecoin Pools&lt;/strong&gt;: Pools such as Curve optimize for minimal slippage when trading stablecoins.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Incentivized Pools&lt;/strong&gt;: Platforms offer additional token rewards to attract liquidity providers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The variations of liquidity pools highlight the rapid innovation in the DeFi space. From simple single-asset pools to complex hybrid and concentrated pools, these structures cater to diverse use cases, offering tailored solutions for trading, lending, yield generation, and more. Real-world examples like Uniswap v3, Curve, Bancor, and Balancer demonstrate the growing utility of liquidity pools, while research-driven innovations promise even greater efficiency and functionality in the future. As DeFi evolves, liquidity pools will remain central to its success, driving financial inclusion and innovation.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/42769dde-8aa8-41ea-893b-068c79ccc82b.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Liquidity pools are a cornerstone of DeFi, driving decentralization and innovation in the financial world. While they offer lucrative opportunities, it’s crucial to understand the associated risks and navigate the evolving regulatory landscape carefully. By doing so, users can leverage this revolutionary technology to unlock the full potential of decentralized finance.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Decentralising Bridges</title>
		<link href="https://blog.anirudha.dev/decentralising-bridges/"/>
		<updated>2025-01-07T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/decentralising-bridges/</id>
		<content type="html">&lt;p&gt;In simple terms, bridges are tools that allow the transfer of assets, data, or even smart contract instructions between different blockchain networks. Think of them as the highways connecting isolated blockchain cities. For example, if you have some Ethereum (ETH) but want to use it on the Binance Smart Chain (BSC), you’d use a bridge to “wrap” your ETH into a token that works on BSC.&lt;/p&gt;
&lt;p&gt;The idea of blockchain bridges emerged as a response to the growing need for interoperability between siloed blockchain ecosystems. In the early days of blockchain, networks like Bitcoin and Ethereum operated in silos, each with its own set of rules, consensus mechanisms, and asset standards. This lack of connectivity limited the potential for innovation and collaboration across ecosystems.&lt;/p&gt;
&lt;p&gt;The first generation of blockchain bridges appeared around 2017–2018 during the ICO boom, as developers began exploring ways to transfer value and data between Ethereum and other nascent chains like EOS and TRON. These early bridges were mostly centralized, operated by single entities or consortiums. While they were functional, they relied heavily on trust, which contradicted the decentralised ethos of blockchain.&lt;/p&gt;
&lt;p&gt;By 2020, with the rise of DeFi (Decentralised Finance) and multi-chain ecosystems, the demand for more robust and decentralised bridges skyrocketed. Protocols like Polkadot and Cosmos introduced native interoperability solutions, while others like Ren and Thorchain developed bridges focused on specific use cases like Bitcoin-to-Ethereum transfers or decentralised swaps.&lt;/p&gt;
&lt;p&gt;Today, blockchain bridges are a critical part of the Web3 infrastructure. They come in various forms, including:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Asset-Specific Bridges&lt;/strong&gt;: Focused on transferring specific tokens (e.g., WBTC for Bitcoin on Ethereum).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Generic Message Bridges&lt;/strong&gt;: Capable of transferring arbitrary data and instructions between chains (e.g., Axelar).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Layer 2 Bridges&lt;/strong&gt;: Connecting Ethereum to its rollups (e.g., Arbitrum, Optimism).&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The ecosystem now includes both centralized and decentralised options, with billions of dollars locked in bridge protocols. Innovations in bridging technology have also introduced concepts like state proofs and zk-rollups to enhance security and scalability. However, challenges like hacks and inefficiencies remain prevalent, making the decentralization and improvement of bridges more important than ever.&lt;/p&gt;
&lt;h2 id=&quot;centralised-vs-decentralised-bridges&quot; tabindex=&quot;-1&quot;&gt;Centralised vs Decentralised Bridges &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#centralised-vs-decentralised-bridges&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In general, centralized applications offer simplicity, speed, and easier regulatory compliance but come with risks related to control, security, and privacy. In contrast, decentralized applications provide enhanced security, transparency, and user autonomy, but may face complexities, performance issues, and governance challenges.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Centralized Bridges&lt;/th&gt;
&lt;th&gt;Decentralized Bridges&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Control&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Operated by a single entity or organization.&lt;/td&gt;
&lt;td&gt;Operated by distributed validators or smart contracts.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Trust Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires users to trust the central operator to act honestly and securely.&lt;/td&gt;
&lt;td&gt;Trustless. Relies on network consensus and cryptographic security.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Transparency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited. Users have little visibility into internal operations.&lt;/td&gt;
&lt;td&gt;Fully transparent. Operations are recorded on-chain and governed by open protocols.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Censorship Resistance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Vulnerable to censorship. Operators can block or restrict transactions.&lt;/td&gt;
&lt;td&gt;Resistant to censorship. No single entity can manipulate or block transactions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Security Risks&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Single point of failure. High risk of hacks or insider fraud.&lt;/td&gt;
&lt;td&gt;Distributed risk. Depending on the robustness of the smart contracts and validator network.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Often faster, as centralization allows for streamlined operations.&lt;/td&gt;
&lt;td&gt;Can be slower due to the need for network consensus and decentralized verification.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Binance Bridge, Coinbase Wallet&lt;/td&gt;
&lt;td&gt;Wormhole, Polygon Bridge, Axelar, Thorchain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Innovation Flexibility&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited by the capabilities and goals of the operator.&lt;/td&gt;
&lt;td&gt;Open to community-driven improvements and integrations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;em&gt;There are 70+ bridges available today, distributed across various chains as per they support respectively.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/81a87548-88a0-46f7-a18d-9c98ac94aace.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Let’s explore some interesting projects amongst them to understand how they work further.&lt;/p&gt;
&lt;h2 id=&quot;axelar&quot; tabindex=&quot;-1&quot;&gt;Axelar &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#axelar&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Axelar is a decentralized interoperability network designed to facilitate secure communication and asset transfer across multiple blockchains. It operates using a robust, trustless infrastructure that prioritizes security and scalability. However, The multi-step verification process can lead to slightly longer transaction times compared to centralized solutions. Even so, Axelar stands out today as one of the prime go-to cross messaging layer due to some unique componenets:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decentralised Validator Network:&lt;/strong&gt; A network of validators runs the Axelar protocol, processing cross-chain transactions and maintaining security. Validators use &lt;strong&gt;Byzantine Fault Tolerant&lt;/strong&gt; (BFT) consensus to ensure the system remains operational even if a subset of validators act maliciously.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Gateway Contracts:&lt;/strong&gt; Each blockchain integrated with Axelar runs a gateway smart contract. These contracts act as the entry and exit points for messages and assets.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain Gateway Protocol (CGP):&lt;/strong&gt; The CGP enables seamless communication between blockchains by packaging transactions, signing them, and relaying them securely.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;One-Time Addresses:&lt;/strong&gt; For each cross-chain transaction, Axelar generates a one-time deposit address. This mechanism simplifies user experience by eliminating the need to deal with complex multi-signature processes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How Axelar Works:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;A user initiates a transfer from Blockchain A to Blockchain B using Axelar’s API or SDK.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The asset is locked in the gateway contract on Blockchain A.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Axelar validators verify the transaction, package it, and relay it to Blockchain B.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On Blockchain B, the gateway contract mints or unlocks the equivalent asset, completing the transaction.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.prod.website-files.com/65f28017eaba8cd1f912fa9f/661ae6d901628457de4c5f5c_DevelopCrossChainApp_GmpDiagram-1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;wormhole&quot; tabindex=&quot;-1&quot;&gt;Wormhole &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#wormhole&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wormhole is a decentralized bridge designed to connect high-performance blockchains like Solana, Ethereum, Binance Smart Chain, and others. It operates as a message-passing protocol, enabling both asset transfers and other data exchanges between chains. It did however, suffered a $325M exploit in 2022, highlighting the need for ongoing improvements. While decentralized, the relatively small number of Guardians poses a risk of collusion.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Guardians Network:&lt;/strong&gt; A decentralized network of validators known as Guardians monitors multiple chains for events. Guardians verify cross-chain transactions and sign messages to validate them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Core Layer:&lt;/strong&gt; Handles the core logic for cross-chain messaging and ensures that data integrity is maintained.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Wrapped Assets:&lt;/strong&gt; Tokens transferred via Wormhole are wrapped into equivalent representations on the target chain.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How Wormhole Works:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;A user locks an asset in a smart contract on the source chain (e.g., Ethereum).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Guardians detect the lock event and sign a message confirming the transaction.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The signed message is relayed to the target chain (e.g., Solana).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;On the target chain, the Wormhole protocol mints a wrapped version of the locked asset for the user.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/213f7dcb-7f61-4e35-885c-af6989bbe323.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;connext&quot; tabindex=&quot;-1&quot;&gt;Connext &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#connext&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Connext&lt;/strong&gt; is a decentralized protocol designed to facilitate fast, secure, and cost-effective cross-chain communication. It achieves this by using &lt;strong&gt;state channels&lt;/strong&gt; and a unique &lt;strong&gt;xCall architecture&lt;/strong&gt; for transferring value and data across Layer 2 networks and Ethereum. Unlike other bridges, Connext is tailored for fast, low-cost communication between Ethereum rollups and other Layer 2 solutions. By leveraging state channels, Connext minimizes on-chain transactions, significantly reducing gas fees. With xCall, developers can integrate cross-chain functionality into their applications without dealing with complex bridging mechanics. Connext’s router-based liquidity model ensures decentralization and eliminates reliance on a single liquidity provider. However, Connext is primarily designed for Layer 2 scaling solutions and doesn’t yet support all Layer 1 blockchains. The network relies heavily on router liquidity. Insufficient liquidity can delay or increase the cost of transactions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;State Channels:&lt;/strong&gt; Connext builds on state channels, a Layer 2 scalability solution that allows transactions to occur off-chain while retaining the security guarantees of the underlying blockchain. These channels minimize the number of on-chain interactions, reducing latency and gas costs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Routers:&lt;/strong&gt; Routers are liquidity providers in the Connext network. They facilitate cross-chain transactions by locking liquidity on one chain and unlocking it on the target chain. They earn fees for their service and must collateralize their positions to ensure security.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;xCall:&lt;/strong&gt; Connext’s xCall is a generic cross-chain communication primitive. It enables developers to build applications that pass messages or assets across chains without needing to handle complex bridging logic. This mechanism abstracts the bridging process for both developers and users, ensuring simplicity.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nomad Integration:&lt;/strong&gt; Connext uses Nomad’s optimistic roll-up model to verify and validate cross-chain interactions. This approach reduces trust assumptions and enhances security.&lt;/p&gt;
&lt;h3 id=&quot;how-connext-works&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;How Connext Works&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#how-connext-works&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transaction Initiation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A user starts a cross-chain transaction using a Connext-integrated dApp or wallet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For example, a user wants to transfer tokens from Optimism (Layer 2) to Polygon (another Layer 2).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Liquidity Locking:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The router locks the required liquidity on the source chain (Optimism) and forwards an off-chain message to the destination chain (Polygon).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Off-Chain Message Passing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Connext uses the xCall mechanism to relay the message securely and quickly across chains. The message includes transaction details, such as the asset amount and the recipient’s address.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transaction Finalization:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On the destination chain (Polygon), the router unlocks equivalent liquidity and sends it to the recipient’s wallet. This process is verified by the network, ensuring security and integrity.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://images.ctfassets.net/gjyjx7gst9lo/920020418/3575f3ea8c4992520e2e95031e48cffd/UnderTheHood.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;bridges-and-the-future-of-digital-assets&quot; tabindex=&quot;-1&quot;&gt;Bridges and the Future of Digital Assets &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#bridges-and-the-future-of-digital-assets&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Bridges will play a massive role in making digital assets more usable. Imagine a world where users don’t need to know which blockchain their assets reside on, they simply transact. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt;: The average user shouldn’t need to know technical details about bridging. A good decentralized bridge abstracts complexities like gas fees, token wrapping, and network selection. For instance, a user transferring stablecoins across chains shouldn’t need to worry about manually configuring gas tokens or selecting intermediary networks. All such intricacies should be handled in the background by the bridge’s architecture.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enhanced UX&lt;/strong&gt;: With smoother cross-chain swaps and wallet integrations, bridging becomes as simple as a single click. Wallets and dApps will incorporate intuitive interfaces that seamlessly execute bridging processes, allowing users to focus on their goals rather than the mechanisms.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interoperability-Driven Applications&lt;/strong&gt;: Applications will harness bridges to become truly chain-agnostic. For example, a DeFi app on Ethereum could directly interact with liquidity on Solana or Avalanche without requiring the user to know or manage the underlying mechanics.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This abstraction is key to mainstream adoption. Users care about outcomes, not mechanisms. By simplifying processes, bridges can drive the mass adoption of digital assets for everyday use cases, including payments&lt;/p&gt;
&lt;h2 id=&quot;security-concerns&quot; tabindex=&quot;-1&quot;&gt;Security Concerns &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-bridges/#security-concerns&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Decentralized bridges, while offering a trustless alternative, are not without their challenges.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Smart Contract Vulnerabilities&lt;/strong&gt;: Bugs or exploits in the smart contract code can lead to massive losses, as seen in various high-profile hacks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;: Conduct rigorous audits by reputable firms and incentivize white-hat hackers through bug bounty programs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sybil Attacks&lt;/strong&gt;: Malicious actors can attempt to overwhelm the validator network by creating multiple fake identities.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;: Implement robust mechanisms like Proof of Stake (PoS) or Proof of Authority (PoA) to ensure validators have a vested interest in the network’s security.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain Attack Surface&lt;/strong&gt;: Bridging increases the potential attack vectors since multiple chains and protocols are involved.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;: Use cryptographic techniques like zk-rollups and state proofs to secure interactions between chains.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Economic Incentive Exploits&lt;/strong&gt;: Attackers might manipulate incentives to destabilize the bridge’s operations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;: Regularly review and optimize incentive structures to align with security goals.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Decentralized Governance Risks&lt;/strong&gt;: Poorly designed governance mechanisms can lead to decision-making that compromises security.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mitigation&lt;/strong&gt;: Ensure governance models are decentralized and resistant to collusion.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Decentralized bridges are set to transform the blockchain ecosystem. Bridges will evolve to provide near-instant, cost-effective transfers, making multi-chain interactions indistinguishable from single-chain experiences. The blockchain industry will likely adopt universal protocols and standards for cross-chain communication, similar to how the internet uses TCP/IP. Advanced cryptographic techniques like zk-proofs and multi-party computation (MPC) will make bridges more secure and scalable. As DeFi and traditional finance converge, bridges will play a crucial role in enabling cross-platform transactions involving both crypto and fiat assets. Projects like Polkadot and Cosmos might pave the way for blockchain ecosystems where bridging is natively integrated, reducing the need for standalone solutions. By abstracting complexities and ensuring security, bridges will drive the mainstream adoption of blockchain technology, empowering users to interact with decentralized applications effortlessly.&lt;/p&gt;
&lt;p&gt;Decentralized bridges are not just a technological innovation, but a necessity for the future of web3. By addressing current challenges and pushing the boundaries of interoperability, they will enable a truly interconnected and user-friendly digital economy.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Token Sale Models</title>
		<link href="https://blog.anirudha.dev/token-sale-models/"/>
		<updated>2025-01-03T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/token-sale-models/</id>
		<content type="html">&lt;p&gt;Launching a crypto project comes with one big question: &lt;strong&gt;How do you sell your tokens?&lt;/strong&gt; Token sales are the lifeblood of most blockchain projects, fueling development, building communities, and driving adoption. But picking the right sales model isn’t just about raising funds. It’s about fairness, accessibility, and strategy.&lt;/p&gt;
&lt;p&gt;From simple “buy it now” pricing to dynamic auctions and even gamified lotteries, there’s a token sale model for every project. In this article, we’ll explore the most popular token sale mechanisms, breaking down how they work, their pros and cons, and even the math behind them. Whether you’re an investor curious about how tokens are distributed or a founder choosing the best method for your launch, this guide has you covered.&lt;/p&gt;
&lt;p&gt;Let’s dive in and decode the world of token sale models!&lt;/p&gt;
&lt;h2 id=&quot;fixed-price-sale&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Fixed Price Sale&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#fixed-price-sale&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You set a fixed price, and participants buy tokens at that price. It’s like buying groceries. Simple and predictable. Makes it easy for participants to calculate costs. Tokens are sold at a pre-determined price, and participants can purchase as many as they want within their limits. Many token offerings use this model. For instance, &lt;strong&gt;Filecoin’s presale&lt;/strong&gt; was based on a fixed price.&lt;/p&gt;
&lt;p&gt;$$Total Cost = Price Per Token × Number Of Tokens Purchased$$&lt;/p&gt;
&lt;p&gt;The cost is directly proportional to the number of tokens purchased. If the price is constant (e.g., $1 per token), buying 10 tokens costs $10. So, if the token price is &lt;strong&gt;0.01 ETH&lt;/strong&gt; and you buy 100 tokens:&lt;/p&gt;
&lt;p&gt;$$Total Cost=0.01×100=1 ETH$$&lt;/p&gt;
&lt;p&gt;Here’s a smart contract snippet for a fixed price sale in Solidity:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;constant&lt;/span&gt; PRICE &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.01&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;constant&lt;/span&gt; MAX_TOKENS &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; tokensSold&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buyTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; amount &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; PRICE&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Incorrect ETH amount&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokensSold &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; amount &lt;span class=&quot;token operator&quot;&gt;&amp;lt;=&lt;/span&gt; MAX_TOKENS&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Not enough tokens left&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    tokensSold &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Transfer tokens to buyer&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;It’s a decent model except it can lead to oversubscription or under-subscription. The risk of unequal distribution.&lt;/p&gt;
&lt;h2 id=&quot;dutch-auction&quot; tabindex=&quot;-1&quot;&gt;Dutch Auction &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#dutch-auction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The price starts high and gradually decreases until participants are willing to buy, or a reserve price is met. Think of it like a reverse eBay. &lt;strong&gt;Ethereum’s initial sale in 2015&lt;/strong&gt; used a Dutch auction, where early buyers paid a higher price. It encourages fair market price discovery and prevents “first-come-first-serve” unfairness.&lt;/p&gt;
&lt;p&gt;$$PriceT =Start Price−(&#92;tfrac{Start Price−End Price}{Duration} ×t)$$&lt;/p&gt;
&lt;p&gt;The price starts high and decreases linearly over time. At any point &lt;code&gt;t&lt;/code&gt;, the price depends on how much time has passed relative to the total auction duration.&lt;/p&gt;
&lt;p&gt;So, if the Start Price was 1 ETH, end price = 0.1 ETH, duration = 10 hours. At t=5 hours:&lt;/p&gt;
&lt;p&gt;$$Price=1−(&#92;tfrac{1−0.1}{10} ×5)=0.55ETH$$&lt;/p&gt;
&lt;p&gt;Here’s a solidity implementation of a Dutch auction:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; startTime &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;timestamp&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; startPrice &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; endPrice &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; duration &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt; days&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getPrice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; elapsedTime &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;timestamp &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; startTime&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;elapsedTime &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; duration&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; endPrice&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; startPrice &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;startPrice &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; endPrice&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; elapsedTime&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; duration&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;It does require participants to monitor prices closely can can be little complex for newcomers.&lt;/p&gt;
&lt;h2 id=&quot;english-auction&quot; tabindex=&quot;-1&quot;&gt;English Auction &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#english-auction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Participants bid for tokens, with the highest bidder receiving them. Think of Sotheby’s, but for tokens. One of the most simple auction model. It ensures maximum revenue and the tokens fo to those valuing them the most. &lt;strong&gt;Polkadot’s DOT token sale&lt;/strong&gt; used a modified English auction format.&lt;/p&gt;
&lt;p&gt;$$Winning Bid=max(Bids)$$&lt;/p&gt;
&lt;p&gt;So, if bids are 1 ETH, 1.5 ETH, and 2 ETH, the winning bid is:&lt;/p&gt;
&lt;p&gt;$$max⁡(1,1.5,2)=2 ETH$$&lt;/p&gt;
&lt;p&gt;Fairly straightforward to determine as well as implement:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Bid&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; bidder&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bid&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; bids&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;placeBid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    bids&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Bid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getHighestBid&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Bid &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    Bid &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; highest&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; bids&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;bids&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; highest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            highest &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; bids&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; highest&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Of course, it’s highly susceptible to bidding wars and might prove to be high barrier for small investors.&lt;/p&gt;
&lt;h2 id=&quot;lottery-sale&quot; tabindex=&quot;-1&quot;&gt;Lottery Sale &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#lottery-sale&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Participants enter a lottery, and winners are chosen to purchase tokens at a fixed price. It’s a bit like a raffle. The random allocation ensures fairness and prevents whales from dominating the sale. Binance Launchpad uses lottery-based sales for projects like &lt;strong&gt;WinkLink&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;$$Probability Of Winning= &#92;tfrac{Tickets Purchased By User}{Total Tickets} ​$$&lt;/p&gt;
&lt;p&gt;The more tickets you hold, the higher your chances of winning, but it’s still random. So, if you buy 5 tickets in a pool of 100 tickets:&lt;/p&gt;
&lt;p&gt;$$Probability=&#92;tfrac{5}{100}=5%$$&lt;/p&gt;
&lt;p&gt;We all understand basic concept of lottery, so this is also a fairly simple implementation:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; participants&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;enterLottery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    participants&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;pickWinner&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; onlyOwner &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; winnerIndex &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;keccak256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;abi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;encodePacked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;timestamp&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;difficulty&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; participants&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; winner &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; participants&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;winnerIndex&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Allocate tokens to winner&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Although, in this case, some participants might feel excluded and there’s no guarantee of allocation.&lt;/p&gt;
&lt;h2 id=&quot;first-come-first-serve-(fcfs)&quot; tabindex=&quot;-1&quot;&gt;First-Come-First-Serve (FCFS) &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#first-come-first-serve-(fcfs)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Tokens are allocated to participants in the order of their purchases until the supply is exhausted. Think of Black Friday deals. Simple to implement and understand. Motivates early participation which is huge positive for new projects. The &lt;strong&gt;ICO of Brave (BAT)&lt;/strong&gt; saw early participants snapping up tokens in seconds.&lt;/p&gt;
&lt;p&gt;$$Tokens Allocated=min(Tokens Requested,Tokens Available)$$&lt;/p&gt;
&lt;p&gt;You can only buy as many tokens as are left when it’s your turn. Early participants get the most tokens. So, if 1,000 tokens are available and a participant requests 500 tokens:&lt;/p&gt;
&lt;p&gt;$$Tokens Allocated=min(500,1000)=500$$&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buyTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokensSold &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; MAX_TOKENS&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Sold out&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    tokensSold&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Transfer tokens&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;However, this might create server overload or congestion. May disadvantage slower participants or participants with slower validators or network coverage.&lt;/p&gt;
&lt;h2 id=&quot;bonding-curve&quot; tabindex=&quot;-1&quot;&gt;Bonding Curve &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#bonding-curve&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The price of tokens increases dynamically based on demand, typically governed by a mathematical curve. t’s like buying concert tickets. The more demand, the higher the price. &lt;strong&gt;Uniswap’s liquidity pools&lt;/strong&gt; use bonding curves to set token prices dynamically. It incentivises early participation and ensures continuous price discovery. (My personal favourite too if implemented properly.)&lt;/p&gt;
&lt;p&gt;$$Price=Base Price+k×Supply^n$$&lt;/p&gt;
&lt;p&gt;Where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;k&lt;/em&gt; is a scaling factor,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;n&lt;/em&gt; determines the curve’s steepness,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Supply is the number of tokens sold so far.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As more tokens are sold, the price increases exponentially or quadratically. Let’s say for &lt;code&gt;Base price = 0.01 ETH&lt;/code&gt;, &lt;code&gt;k=0.001&lt;/code&gt;, &lt;code&gt;n=2&lt;/code&gt;, and &lt;code&gt;100&lt;/code&gt; tokens sold:&lt;/p&gt;
&lt;p&gt;$$Price=0.01+0.001×100^2=1.01 ETH$$&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getPrice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; supply&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;pure&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; BASE_PRICE &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;supply &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; CURVE_FACTOR&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Although there’s quite a strong foundation, It might get complex for users to understand. The early adopters may gain disproportionate advantages as well, which arguably is justified to an extent.&lt;/p&gt;
&lt;h2 id=&quot;tiered-sale&quot; tabindex=&quot;-1&quot;&gt;Tiered Sale &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#tiered-sale&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Tokens are sold in phases, with each tier having different prices and conditions. It encourages early participation by offering discounts and has a predictable structure. &lt;strong&gt;Polkastarter&lt;/strong&gt; often runs tiered sales where early buyers get discounts.&lt;/p&gt;
&lt;p&gt;Different tiers have fixed prices. The tier you’re in determines the price you pay. So, if &lt;strong&gt;Tier 1&lt;/strong&gt; price is &lt;code&gt;0.01 ETH&lt;/code&gt; and &lt;strong&gt;Tier 2&lt;/strong&gt; price is &lt;code&gt;0.02 ETH&lt;/code&gt;, buying during Tier 1 costs:&lt;/p&gt;
&lt;p&gt;$$Price=0.01×Tokens Purchased$$&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; tiers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0.01&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.02&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.03&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; currentTier&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;buyTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; tiers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;currentTier&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Incorrect price&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    currentTier&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Transfer tokens&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Simple model. While later participants may feel penalized, the early tiers can be dominated by whales.&lt;/p&gt;
&lt;h2 id=&quot;batch-auction&quot; tabindex=&quot;-1&quot;&gt;Batch Auction &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/token-sale-models/#batch-auction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All bids are collected in a batch, and the clearing price is determined to allocate tokens to participants proportionally. &lt;strong&gt;Gnosis Protocol&lt;/strong&gt; uses batch auctions for price discovery.&lt;/p&gt;
&lt;p&gt;$$Clearing Price = &#92;tfrac{Total Funds Committed}{Total Tokens Available}$$&lt;/p&gt;
&lt;p&gt;All bids are pooled together. The clearing price is determined by dividing the total funds by the tokens available. If &lt;code&gt;10 ETH&lt;/code&gt; is committed for 1,000 tokens:&lt;/p&gt;
&lt;p&gt;$$Clearing Price=&#92;tfrac{10}{1000}=0.01 ETH$$&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; clearingPrice&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;finalizeAuction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; onlyOwner &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Calculate clearing price based on bids&lt;/span&gt;&lt;br /&gt;    clearingPrice &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;calculateClearingPrice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Apart from the above, there have been Hybrid Models as well which combine one or more of the above models for various factors from fairness, revenue generation, simplying terms, higher market penetration and so on.&lt;/p&gt;
&lt;p&gt;Choosing the right token sale model is a mix of strategy, technical feasibility, and audience understanding. By aligning your model with your goals, tokenomics, and market conditions, you can ensure a successful launch that sets your Web3 project up for long-term growth.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Synthetic Asset Tokens</title>
		<link href="https://blog.anirudha.dev/synthetic-asset-tokens/"/>
		<updated>2024-12-20T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/synthetic-asset-tokens/</id>
		<content type="html">&lt;p&gt;Imagine having access to the value of an asset, say, Tesla stock, without ever owning it. That’s essentially what synthetic asset tokens (or just “synthetics”) do. These are blockchain-based tokens that mimic the value of real-world assets, such as stocks, commodities, or even fiat currencies. Think of them as financial doppelgängers: they look, act, and feel like the original, but they exist entirely in the digital realm.&lt;/p&gt;
&lt;p&gt;In the traditional financial market, synthetic assets are not new. Derivatives like futures and options have been around for decades, allowing traders to bet on the price of an asset without ever owning it. Synthetic tokens simply bring this concept to the blockchain, leveraging smart contracts to handle everything transparently and automatically.&lt;/p&gt;
&lt;p&gt;Derivatives exist in web3 as well already. However, there’s still lot of scepticism around it. Derivatives like futures, options, and perpetual swaps already exist and are widely used. Both derivatives and synthetic tokens are tied to an underlying asset, such as Bitcoin, Ethereum, or traditional stocks like Tesla. The performance of these assets directly affects the value of the derivative or synthetic token. Just as derivatives allow traders to speculate or hedge risks, synthetic asset tokens let users gain exposure to the price of assets without actually owning them.&lt;/p&gt;
&lt;p&gt;Crypto derivatives have gained significant traction, especially in speculative trading. Futures and perpetual swaps on exchanges like Binance, Bybit, and dYdX dominate trading volumes. They offer high liquidity and enable speculation on crypto prices. Traders and institutions use derivatives to manage risk, especially in highly volatile markets. Many jurisdictions have banned or restricted derivatives trading due to concerns over high leverage and investor risk (e.g., Binance halting derivatives in several countries). The extreme price swings in crypto make derivatives riskier than their traditional counterparts, leading to liquidations for unprepared traders.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://academy.synfutures.com/content/images/size/w1000/2021/12/1-5-derivatives-1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Traditional finance views synthetics as tools for hedging and speculation. Want to protect yourself from the wild price swings of oil without owning physical barrels? A synthetic derivative could be your best friend. Similarly, traders use them to speculate on price movements, essentially making money out of thin air, if they play their cards right.&lt;/p&gt;
&lt;p&gt;In the tokenized asset market, synthetic tokens serve a similar purpose, but with a blockchain twist. They’re used for:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Global Accessibility&lt;/strong&gt;: You don’t need a brokerage account to own a synthetic version of Apple stock. Just a crypto wallet will do.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fractional Ownership&lt;/strong&gt;: Want exposure to gold but can’t afford a whole ounce? Synthetic tokens can be fractioned down to tiny denominations.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Decentralized Finance (DeFi)&lt;/strong&gt;: Platforms like Synthetix allow users to mint synthetic tokens using their crypto as collateral.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Like any financial innovation, synthetic asset tokens come with their own set of advantages and challenges.&lt;/p&gt;
&lt;h4 id=&quot;pros&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Pros&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#pros&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: Traditional markets often have barriers, like location, regulations, or account requirements. Synthetic tokens tear those walls down.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Efficiency&lt;/strong&gt;: Transactions happen on the blockchain, which means they’re often faster and cheaper than traditional methods.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Liquidity Boost&lt;/strong&gt;: Synthetic tokens can unlock liquidity by bringing otherwise illiquid assets into a tradable, digital format.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;cons&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cons&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#cons&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt;: They’re not beginner-friendly. Understanding how synthetics work requires some financial and blockchain literacy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Regulation&lt;/strong&gt;: Governments haven’t fully figured out how to regulate synthetic tokens, which could lead to legal uncertainties. Hell, some governements are yet to figure to crypto itself.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Counterparty Risk&lt;/strong&gt;: In DeFi, your synthetics depend on smart contracts and oracles. If something goes wrong there, your assets could be at risk.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here’s where things get exciting. Synthetic asset tokens can significantly improve liquidity in the crypto and NFT markets by unlocking idle assets, diversification and bridging markets. Imagine converting an NFT, typically illiquid, into a synthetic token that can be freely traded. This opens up an entirely new avenue for liquidity in the NFT space. Traders could gain exposure to other markets (stocks, gold, real estate) without leaving the crypto ecosystem. Synthetic tokens could serve as a bridge between traditional and crypto markets. For example, a synthetic token pegged to the S&amp;amp;P 500 index could attract traditional investors into the blockchain world.&lt;br /&gt;
In essence, synthetics have the potential to make markets more fluid, more inclusive, and more interconnected.&lt;/p&gt;
&lt;p&gt;A few platforms and projects are already leveraging synthetic asset tokens:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Synthetix&lt;/strong&gt;: Synthetix is one of the leading platforms for synthetic assets. It allows users to mint Synths tokens representing real-world assets like sUSD (synthetic USD), sBTC (synthetic Bitcoin), and even synthetic stocks. Synthetix uses Chainlink oracles to ensure accurate pricing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mirror Protocol&lt;/strong&gt;: Built on Terra, Mirror Protocol enabled synthetic versions of stocks like mAAPL (synthetic Apple stock) and mGOOGL (synthetic Google stock). It gained popularity for allowing users outside the U.S. to trade synthetic U.S. stocks. However, Terra’s collapse affected its adoption.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NFTy&lt;/strong&gt; &lt;em&gt;(👀)&lt;/em&gt;: Imagine a platform where synthetic tokens represent a basket of the top 500 NFT collections. It creates a new layer of liquidity and market exposure for NFT enthusiasts.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let’s skip to look into code for a bit.&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SyntheticAssetToken&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;SyntheticAssetToken&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; symbol &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;SAT&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint8&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; decimals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; totalSupply&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; balanceOf&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; allowance&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; collateralRatio &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 200% collateral required&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; collateralLocked&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; collateral&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; owner&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        owner &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onlyOwner&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; owner&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Only the owner can perform this action&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Events&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Approval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; owner&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; spender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Mint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; collateral&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Burn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; collateralReturned&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Transfer tokens&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Insufficient balance&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Approve an allowance for another address&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;approve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; spender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        allowance&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;spender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Approval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; spender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Transfer tokens on behalf of another address&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Insufficient balance&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;allowance&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Allowance exceeded&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;to&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        allowance&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Mint synthetic tokens by locking ETH as collateral&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;mint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; requiredCollateral &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; collateralRatio&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; requiredCollateral&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Insufficient collateral&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        collateral&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        totalSupply &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        collateralLocked &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Mint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Burn synthetic tokens and withdraw collateral&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;burn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Insufficient token balance&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; collateralToReturn &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; collateralRatio&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;collateral&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; collateralToReturn&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Insufficient collateral locked&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        balanceOf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        totalSupply &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        collateral&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; collateralToReturn&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        collateralLocked &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; collateralToReturn&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;collateralToReturn&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Burn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; collateralToReturn&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Fallback function to handle ETH sent directly to the contract&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;fallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;receive&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Users lock ETH as collateral, and the contract mints synthetic tokens (&lt;code&gt;SAT&lt;/code&gt;) for them. The required collateral is 200% of the token’s value (adjustable by modifying &lt;code&gt;collateralRatio&lt;/code&gt;). Users can burn their synthetic tokens to reclaim the collateral they locked. The contract also supports ERC-20 functions like &lt;code&gt;transfer&lt;/code&gt;, &lt;code&gt;approve&lt;/code&gt;, and &lt;code&gt;transferFrom&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Please note that this smart contract is for understanding need only and not to be used in real production use-case. It needs to have further price oracles, liquidation and governance models included for that, not to mention security.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://story.madfish.solutions/wp-content/uploads/2021/09/Synthetics_benefits-1024x576.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As exciting as synthetic asset tokens are, they come with significant security concerns. Since these tokens are entirely reliant on blockchain technology and smart contracts, their safety depends on the robustness of the underlying code and ecosystem.&lt;/p&gt;
&lt;h3 id=&quot;smart-contract-vulnerabilities&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Smart Contract Vulnerabilities&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#smart-contract-vulnerabilities&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Smart contracts are immutable once deployed, meaning any bug in the code can be catastrophic. Hackers can exploit vulnerabilities to drain collateral, mint unauthorized tokens, or manipulate token behavior.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;: The 2020 &lt;em&gt;bZx protocol&lt;/em&gt; exploit resulted in losses of millions due to flaws in its smart contract logic.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;price-oracle-manipulation&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Price Oracle Manipulation&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#price-oracle-manipulation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Synthetic tokens rely on price oracles to mirror the value of real-world assets. If an oracle is compromised or manipulated, the synthetic token’s value could diverge drastically, leading to losses for users.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Example&lt;/strong&gt;: In 2022, several DeFi platforms experienced oracle attacks where attackers manipulated prices to profit from undercollateralized positions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;collateral-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Collateral Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#collateral-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Synthetic tokens require collateral backing to maintain trust and stability. If collateral values drop suddenly (e.g., during a market crash), the synthetic asset system could become undercollateralized, leading to insolvency and loss of funds.&lt;/p&gt;
&lt;h3 id=&quot;rug-pulls-and-governance-exploits&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Rug Pulls and Governance Exploits&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#rug-pulls-and-governance-exploits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In decentralized systems, malicious actors could take over governance (via token voting) and implement changes that siphon funds or destroy the ecosystem.&lt;/p&gt;
&lt;h3 id=&quot;regulatory-compliance-risks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Regulatory Compliance Risks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/synthetic-asset-tokens/#regulatory-compliance-risks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Since synthetic tokens mimic traditional assets, they often blur the line between DeFi and traditional finance. Regulatory bodies like the SEC in the U.S. or the RBI in India could impose restrictions or fines on platforms operating without compliance.&lt;/p&gt;
&lt;p&gt;Governance is essential to ensure the stability, transparency, and adaptability of synthetic asset platforms. Without proper governance, these systems can devolve into chaos, whether through technical issues, regulatory non-compliance, or community mismanagement.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Updating Parameters&lt;/strong&gt;: Adjusting collateral ratios, fees, and system rules in response to market conditions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security Audits&lt;/strong&gt;: Funding regular audits to identify and patch vulnerabilities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Price Oracle Management&lt;/strong&gt;: Ensuring that oracles used for price feeds are reliable, decentralized, and tamper-proof.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Emergency Response&lt;/strong&gt;: Providing mechanisms to pause or roll back operations during unexpected attacks or exploits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Regulatory Compliance&lt;/strong&gt;: Proactively adapting to legal requirements, such as Know Your Customer (KYC) and Anti-Money Laundering (AML) measures.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We can infact learn a lot from traditional financial governance as they’ve gone through similar states involving synthetic assets or derivatives.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;SEC’s Role&lt;/strong&gt;: In traditional finance, the U.S. SEC (Securities and Exchange Commission) enforces regulations that protect investors, ensure market fairness, and penalize fraud. Synthetic token platforms could learn from the SEC’s stringent oversight of derivatives and securities markets to build trust.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;RBI’s Approach&lt;/strong&gt;: The Reserve Bank of India oversees monetary policy and ensures that banks maintain sufficient reserves. Similarly, synthetic token platforms need to enforce collateralization rules to prevent insolvency.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Many synthetic token projects already implement decentralized governance models, where token holders vote on key decisions. However, these systems need to balance decentralization with expertise; relying solely on token holders without checks can lead to uninformed or malicious decisions.&lt;/p&gt;
&lt;p&gt;In decentralized synthetic asset markets, reputation will be a key differentiator. Fund managers with strong track records will likely attract more users, liquidity providers, and partnerships. However, reputation isn’t just a personal asset; it elevates the entire market by fostering trust and reducing skepticism about decentralized finance.&lt;/p&gt;
&lt;p&gt;As the synthetic asset ecosystem grows, we will be introducing decentralized reputation scoring systems in NFTy, think “on-chain LinkedIn for fund managers”. Reputation could become a tradable asset in itself, shaping the future of decentralized markets just as much as the assets being tokenized. We can cover more on building reputation later.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://academy-public.coinmarketcap.com/optimized-uploads/33d76d0d4aab45b9b02ebab17820373f.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Synthetic asset tokens are still in their early days, and the use cases we’re seeing are just the tip of the iceberg. What could the future hold?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized Real Estate&lt;/strong&gt;: Imagine investing in synthetic tokens representing global real estate markets, all from your phone.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Synthetic ESG Assets&lt;/strong&gt;: Tokens tied to sustainability indices or carbon credits could attract socially conscious investors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom Market Creation&lt;/strong&gt;: Want a token that tracks the value of “most streamed artists on Spotify”? With synthetics, you can create it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What we can say for sure is that Synthetic asset tokens are more than just a trend. They’re a fundamental shift in how we think about ownership, liquidity, and financial accessibility. The big question isn’t just &lt;em&gt;what can we do with synthetics now?&lt;/em&gt; but rather &lt;em&gt;what haven’t we thought of them yet?&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>How does Chain Abstraction work?</title>
		<link href="https://blog.anirudha.dev/how-does-chain-abstraction-work/"/>
		<updated>2024-12-17T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/how-does-chain-abstraction-work/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;If you’re looking to learn about the basics about Chain Abstraction, then read &lt;a href=&quot;https://blog.anirudha.dev/chain-abstraction&quot;&gt;this article&lt;/a&gt; instead.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Technically speaking, chain abstraction means abstracting away the differences between blockchain networks to provide a seamless experience. The goal is to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simplify User Interaction:&lt;/strong&gt; Make it easy for users to interact with apps without worrying about which chain they’re on.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enable Interoperability:&lt;/strong&gt; Allow assets, data, and actions to move freely between chains.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reduce Complexity for Developers:&lt;/strong&gt; Provide unified tools and APIs to build cross-chain applications.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To achieve chain abstraction, several tools and mechanisms come into play.&lt;/p&gt;
&lt;h2 id=&quot;cross-chain-bridges&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cross-Chain Bridges&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/how-does-chain-abstraction-work/#cross-chain-bridges&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Bridges connect different blockchains, enabling the transfer of assets and data between them. Think of them as digital highways. For example, if you want to move your tokens from Ethereum to Binance Smart Chain, a bridge handles the heavy lifting.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;You lock your tokens on the source chain (e.g., Ethereum).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The bridge mints an equivalent amount of tokens on the destination chain (e.g., Binance Smart Chain).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When you want to reverse the process, the tokens on the destination chain are burned, and the original tokens are unlocked.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;swaps-and-liquidity-protocols&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Swaps and Liquidity Protocols&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/how-does-chain-abstraction-work/#swaps-and-liquidity-protocols&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Swapping tokens across chains often requires decentralized exchanges (DEXs) or protocols like &lt;a href=&quot;https://app.uniswap.org/&quot;&gt;Uniswap&lt;/a&gt; and &lt;a href=&quot;https://www.sushi.com/ethereum/swap&quot;&gt;SushiSwap&lt;/a&gt;. Some advanced protocols like &lt;a href=&quot;https://thorchain.org/&quot;&gt;Thorchain&lt;/a&gt; take it a step further by supporting native cross-chain swaps without wrapping tokens.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Liquidity pools on different chains allow you to trade one token for another.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Cross-chain swap protocols use bridges under the hood to move assets while maintaining a smooth experience.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;interoperability-protocols&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Interoperability Protocols&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/how-does-chain-abstraction-work/#interoperability-protocols&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Protocols like &lt;a href=&quot;https://polkadot.com/&quot;&gt;Polkadot&lt;/a&gt; and &lt;a href=&quot;https://cosmos.network/&quot;&gt;Cosmos&lt;/a&gt; focus on making blockchains inherently interoperable. They create ecosystems where chains can share data and assets natively.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Relay Chains:&lt;/strong&gt; Central hubs that coordinate communication between connected blockchains.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IBC (Inter-Blockchain Communication):&lt;/strong&gt; A protocol standard used in Cosmos to let chains talk to each other securely. All contracts follow the &lt;a href=&quot;https://github.com/cosmos/ibc&quot;&gt;Interchain Standards (ICS)&lt;/a&gt; for the Cosmos network &amp;amp; interchain ecosystem.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;universal-wallets&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Universal Wallets&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/how-does-chain-abstraction-work/#universal-wallets&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Tools like &lt;a href=&quot;https://particle.network/&quot;&gt;Particle Network&lt;/a&gt; enable universal account wallets that work across multiple chains. Instead of manually switching between networks, these wallets auto-detect and handle transactions on the right chain.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Chain detection and configuration happen automatically.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Transactions are routed to the correct blockchain without user intervention.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;rpc-aggregators&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;RPC Aggregators&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/how-does-chain-abstraction-work/#rpc-aggregators&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Remote Procedure Call (RPC) endpoints are gateways to blockchains. Aggregators like Alchemy and Infura provide a unified interface to interact with multiple blockchains, abstracting away the need to set up individual endpoints.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.particle.network/content/images/2024/06/image1-5.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Chain abstraction is the backbone of many user-friendly crypto applications. Lets see a few examples:&lt;/p&gt;
&lt;p&gt;Imagine you’re using a decentralized finance app to swap Ethereum (ETH) for Binance Coin (BNB). Here’s what it looks like from your perspective:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You open the app and select &lt;code&gt;ETH&lt;/code&gt; as the token to swap.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You choose &lt;code&gt;BNB&lt;/code&gt; as the token to receive.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You click “Swap” and confirm the transaction.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;From your perspective, it’s a one-click process. Behind the scenes, multiple tools work together to make it seamless.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The app detects that ETH is on Ethereum and BNB is on Binance Smart Chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A cross-chain bridge locks your ETH on Ethereum and creates a wrapped version on Binance Smart Chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The app uses a liquidity pool to exchange the wrapped ETH for BNB.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finally, the app transfers BNB to your wallet on Binance Smart Chain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here’s a simple Solidity contract for locking tokens on Ethereum and emitting an event to notify a bridge:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TokenLock&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;TokenLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; lockedBalances&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;lockTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Amount must be greater than 0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Simulate token lock (e.g., ERC20 transfer to contract)&lt;/span&gt;&lt;br /&gt;        lockedBalances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Emit event for bridge to pick up&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;TokenLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This contract locks tokens on Ethereum and emits an event. A bridge service listens to the event and handles minting on the destination chain.&lt;/p&gt;
&lt;p&gt;Lets take another example. Imagine you own an NFT on Ethereum but want to sell it on a Solana-based marketplace. Chain abstraction allows this by bridging the NFT to Solana while ensuring its metadata and ownership history remain intact.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The NFT is locked on Ethereum, and a wrapped version is created on Solana.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The marketplace interacts with the Solana version, displaying it as if it were native to Solana.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;When the NFT is sold, the buyer can choose to keep it on Solana or transfer it back to Ethereum.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC721/IERC721.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;NFTBridge&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    IERC721 &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nftContract&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _nftContract&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        nftContract &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;IERC721&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_nftContract&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;lockNFT&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;nftContract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Not the owner&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Transfer the NFT to the bridge contract&lt;/span&gt;&lt;br /&gt;        nftContract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transferFrom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Emit event for bridge service&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;NFTLocked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; destinationChain&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;In this example, the contract locks an NFT and emits an event. The bridge then handles minting the wrapped NFT on the target chain.&lt;/p&gt;
&lt;p&gt;How about EVM to Cosmos perhaps?&lt;/p&gt;
&lt;p&gt;Here’s an example illustrating how a smart contract on Ethereum can interact with a Cosmos chain using IBC:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SPDX-License-Identifier: MIT&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;EVMToCosmosBridge&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;TokenSentToCosmos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;indexed&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; cosmosAddress&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; balances&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sendToCosmos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;memory&lt;/span&gt; cosmosAddress&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Amount must be greater than 0&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Simulate token lock (e.g., ERC20 transfer to contract)&lt;/span&gt;&lt;br /&gt;        balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Emit event for Cosmos chain to pick up&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;TokenSentToCosmos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; cosmosAddress&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This contract locks tokens on Ethereum and emits an event for an IBC-compatible relayer to transfer the equivalent tokens to a Cosmos chain.&lt;/p&gt;
&lt;p&gt;On the Cosmos side, a module listens for IBC events and handles incoming tokens:&lt;/p&gt;
&lt;code-block lang=&quot;rust&quot;&gt;&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;package tokenbridge&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;github.com/cosmos/cosmos-sdk/types&quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;github.com/cosmos/ibc-go/modules/core/04-channel/types&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;func &lt;span class=&quot;token class-name&quot;&gt;HandleTokenTransfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ctx sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; msg types&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;MsgRecvPacket&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; error &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Decode the packet&lt;/span&gt;&lt;br /&gt;    var data &lt;span class=&quot;token class-name&quot;&gt;TokenTransferPacketData&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; err &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; json&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Unmarshal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Packet&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; err &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; nil &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; err&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Mint the tokens for the recipient&lt;/span&gt;&lt;br /&gt;    recipient &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;AccAddress&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Recipient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    amount &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;NewCoin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Denom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;NewInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; err &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MintTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ctx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; recipient&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; err &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; nil &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; err&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; nil&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;func &lt;span class=&quot;token class-name&quot;&gt;MintTokens&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ctx sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; recipient sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;AccAddress&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Coin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; error &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// Use the bank module to mint and send tokens&lt;/span&gt;&lt;br /&gt;    bankKeeper &lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;GetBankKeeper&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; bankKeeper&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;MintCoins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ctx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ModuleName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sdk&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;NewCoins&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This Cosmos module listens for incoming IBC packets, decodes the token transfer details, and mints tokens to the recipient’s address. It complements the Ethereum-side contract to complete the abstraction.&lt;/p&gt;
&lt;p&gt;Now, since blockchains are inherently siloed networks, they ideally wouldn’t know to even listen each other. That’s where the bridges and other tools come in. Even with bridges, potential limitations still exists. If the cross-chain bridge experiences congestion, your transaction might be delayed. Additionally, if there’s insufficient liquidity in the liquidity pool for the target token, you might get unfavorable rates or the swap could fail entirely. Lastly, any issues with the smart contracts underlying the bridge or pool could result in transaction errors or delays.&lt;br /&gt;
Despite these risks, robust protocols and fallback mechanisms are constantly evolving to mitigate such problems. Scalability can also become a bottleneck as the number of connected chains increases, requiring more resources to maintain performance. Security is another concern, as cross-chain communication introduces additional attack surfaces, such as vulnerabilities in the relay chains or the Inter-Blockchain Communication (IBC) protocol. Addressing these issues is critical for achieving robust and secure interoperability.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;There’s a long way to go to achieve true chain abstraction, but we’re on the way already…&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Manga, Manhua and Manhwa</title>
		<link href="https://blog.anirudha.dev/manga-manhua-manhwa/"/>
		<updated>2024-12-15T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/manga-manhua-manhwa/</id>
		<content type="html">&lt;p&gt;If you’ve ever stumbled into the world of Asian graphic novels, you’ve probably come across the big three: &lt;strong&gt;Manga&lt;/strong&gt; (Japanese graphic novels), &lt;strong&gt;Manhua&lt;/strong&gt; (Chinese graphic novels), and &lt;strong&gt;Manhwa&lt;/strong&gt; (Korean graphic novels). At first glance, they might all look like stylish black-and-white panels filled with expressive characters. But look closer, and you’ll find a rich tapestry of differences woven from their unique cultural, historical, and creative roots. So, let’s dive in and explore these fantastic worlds, no passport required!&lt;br /&gt;
&lt;em&gt;Don’t kill me for the word “comics”. Its just a reference to make it easier to understand comparing with western graphic novels.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;manga%3A-the-og-(original-graphic)-of-asian-comics&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Manga: The OG (Original Graphic) of Asian Comics&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/manga-manhua-manhwa/#manga%3A-the-og-(original-graphic)-of-asian-comics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Manga is Japan’s pride and joy, with roots tracing back to &lt;strong&gt;ukiyo-e woodblock prints&lt;/strong&gt; from the Edo period (1603–1867). But modern manga as we know it exploded post-WWII, thanks to Osamu Tezuka’s “Astro Boy.” Tezuka’s cinematic style was revolutionary, and his work set the stage for manga’s global domination.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Format:&lt;/strong&gt; Usually black-and-white and printed in small booklets or magazines like &lt;em&gt;Shonen Jump&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Direction:&lt;/strong&gt; Right to left. Yes, it’s the ultimate “read me backward” experience.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Art Style:&lt;/strong&gt; Highly detailed characters with larger-than-life emotions (those teary, sparkling eyes are iconic).&lt;/p&gt;
&lt;p&gt;From &lt;em&gt;Naruto&lt;/em&gt; kicking butt in ninja villages to &lt;em&gt;Death Note&lt;/em&gt; making us question our moral compasses, manga has something for everyone. There are genres for boys (&lt;em&gt;shonen&lt;/em&gt;), girls (&lt;em&gt;shoujo&lt;/em&gt;), adults (&lt;em&gt;seinen&lt;/em&gt;), and beyond.&lt;/p&gt;
&lt;p&gt;Manga is thriving globally. Platforms like MangaPlus bring serialized chapters to international fans, and anime adaptations only amplify the craze (&lt;em&gt;Demon Slayer&lt;/em&gt;, anyone?). It’s not just entertainment, it’s an economic powerhouse in Japan. &lt;strong&gt;Shonen Jump&lt;/strong&gt;, one of the most iconic and influential manga magazines in the world, published by the Japanese company &lt;strong&gt;Shueisha&lt;/strong&gt; made manga culture appeal far-reaching, captivating readers of all ages and genders with its diverse roster of stories. A lot of popular manga like &lt;em&gt;Dragon Ball&lt;/em&gt;, &lt;em&gt;Naruto&lt;/em&gt;, &lt;em&gt;One Piece&lt;/em&gt;, and &lt;em&gt;Demon Slayer, Jujutsu Kaisen, Bleach and many more&lt;/em&gt; all got their start in this magazine.&lt;/p&gt;
&lt;p&gt;If you’re getting started, here’s my top recommendations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dragon Ball Z :&lt;/strong&gt; &lt;em&gt;The OG power-up and fight series that defined a generation.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;One Piece :&lt;/strong&gt; &lt;em&gt;Pirates, treasures, and a stretchy hero. What’s not to love?&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Naruto :&lt;/strong&gt; &lt;em&gt;The journey of a knucklehead ninja with dreams of becoming Hokage.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Attack on Titan :&lt;/strong&gt; &lt;em&gt;Giant man-eating creatures? A dystopian masterpiece.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Death Note :&lt;/strong&gt; &lt;em&gt;A notebook that kills? Cue moral dilemmas and epic mind games.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fullmetal Alchemist :&lt;/strong&gt; &lt;em&gt;Alchemy, brotherly bonds, and an unforgettable story.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Demon Slayer (Kimetsu no Yaiba) :&lt;/strong&gt; &lt;em&gt;Demon hunting with a side of breathtaking animation.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bleach :&lt;/strong&gt; &lt;em&gt;Soul Reaper stuck in human world and epic journey begins&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Jujutsu Kaisen :&lt;/strong&gt; &lt;em&gt;Curses, exorcists, and a protagonist who eats a finger. Wild ride.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vinland Saga :&lt;/strong&gt; &lt;em&gt;Vikings and real history woven into an epic story.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokyo Revengers :&lt;/strong&gt; &lt;em&gt;Time travel, gangs, and redemption arcs galore.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hunter x Hunter&lt;/strong&gt; : &lt;em&gt;Adventure packed story of a world opening into larger world.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Parasyte :&lt;/strong&gt; &lt;em&gt;Alien parasites take over humans&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;There’s plenty more but these would be good starting points.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/47415c57-5fc6-4367-af2b-0ca40884318f.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;manhua%3A-the-chinese-renaissance-of-comics&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Manhua: The Chinese Renaissance of Comics&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/manga-manhua-manhwa/#manhua%3A-the-chinese-renaissance-of-comics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Manhua dates back to 19th-century satirical drawings. While early manhua was mostly based around political settings, it evolved into a vibrant storytelling medium by the 20th century. Thanks to the internet boom, digital manhua exploded in popularity.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Format:&lt;/strong&gt; Often in vibrant &lt;strong&gt;full color&lt;/strong&gt;, breaking away from manga’s monochromatic traditions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Direction:&lt;/strong&gt; Left to right, like most Western comics. (&lt;em&gt;Your brain thanks you.&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Art Style:&lt;/strong&gt; Slick, sharp lines and ethereal vibes, especially in &lt;strong&gt;cultivation&lt;/strong&gt; (think martial arts meets fantasy) genres.&lt;/p&gt;
&lt;p&gt;Manhua loves epic fantasy (&lt;em&gt;cultivation tales like “Tales of Demons and Gods”&lt;/em&gt;), historical romance, and revenge-driven dramas. There’s often a philosophical touch, reflecting Confucian values or Taoist mysticism.&lt;/p&gt;
&lt;p&gt;China’s strict censorship laws have shaped manhua’s themes, keeping them relatively tame. However, platforms like &lt;em&gt;Tencent Comics&lt;/em&gt;, &lt;em&gt;Bilibili Comics&lt;/em&gt; and &lt;em&gt;Kuaikan Manhua&lt;/em&gt; are pushing them to global audiences. The industry still struggles to match manga’s global reach, but it’s making steady strides.&lt;/p&gt;
&lt;p&gt;If you’re getting started, here’s my top recommendations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tales of Demons and Gods :&lt;/strong&gt; &lt;em&gt;Cultivation fantasy with a reincarnated protagonist aiming to change fate.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The King’s Avatar :&lt;/strong&gt; &lt;em&gt;E-sports meets a gaming prodigy’s rise to glory.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Soul Land (Douluo Dalu) :&lt;/strong&gt; &lt;em&gt;Martial arts and magical beast fusion battles.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Apotheosis :&lt;/strong&gt; &lt;em&gt;A journey from a slave to a god epic cultivation vibes.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Martial Peak :&lt;/strong&gt; &lt;em&gt;An endless quest for strength in a martial arts universe.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Battle Through the Heavens :&lt;/strong&gt; &lt;em&gt;Alchemy, martial arts, and the ultimate underdog story.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Versatile Mage :&lt;/strong&gt; &lt;em&gt;A magic school story with a rebellious protagonist who defies norms.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Star Martial God Technique :&lt;/strong&gt; &lt;em&gt;A quest to master the universe’s strongest martial arts technique.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Ravages of Time :&lt;/strong&gt; &lt;em&gt;Historical epic inspired by China’s Three Kingdoms period.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;God of Martial Arts :&lt;/strong&gt; &lt;em&gt;A world where martial arts determine life, death, and destiny.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ultimate of All Ages :&lt;/strong&gt; &lt;em&gt;Man from the ancient past, who awakens in a world thousands of years into the future&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/bac9cc84-7a82-4b72-ab77-a3c54e2f3a19.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;My friend Sreeram maintains &lt;a href=&quot;https://kitsu.app/users/1460649/library?media=manga&quot;&gt;this list&lt;/a&gt; that you can also follow for more recommendations.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;manhwa%3A-the-webtoon-revolution&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Manhwa: The Webtoon Revolution&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/manga-manhua-manhwa/#manhwa%3A-the-webtoon-revolution&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Manhwa blossomed in Korea post-WWII but faced setbacks during the country’s political turmoil. By the 2000s, digital manhwa (aka &lt;strong&gt;webtoons&lt;/strong&gt;) redefined the game. Korean creators took advantage of smartphones, creating vertical-scrolling comics designed for seamless online reading.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Format:&lt;/strong&gt; Full-color, &lt;strong&gt;vertical scrolling&lt;/strong&gt;, perfect for phone addicts (guilty!).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Direction:&lt;/strong&gt; Left to right.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Art Style:&lt;/strong&gt; Clean, modern, and often cinematic, with dynamic paneling.&lt;/p&gt;
&lt;p&gt;Manhwa is fearless when it comes to tackling adult themes (&lt;em&gt;hello, “Solo Leveling” and “Lore Olympus”&lt;/em&gt;). From heartwarming romances (&lt;em&gt;“True Beauty”&lt;/em&gt;) to action-packed epics (&lt;em&gt;“Tower of God”&lt;/em&gt;), manhwa often blends K-drama vibes with stunning visuals.&lt;/p&gt;
&lt;p&gt;Manhwa is leading the digital comics world, and platforms like &lt;em&gt;LINE Webtoon, Lezhin Comics, Toomics&lt;/em&gt; and &lt;em&gt;KakaoPage&lt;/em&gt; are expanding its global footprint. Thanks to Netflix adaptations (&lt;em&gt;Sweet Home&lt;/em&gt;, &lt;em&gt;Hellbound&lt;/em&gt;), manhwa is practically a household name now.&lt;/p&gt;
&lt;p&gt;If you’re getting started, here’s my top recommendations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Solo Leveling :&lt;/strong&gt; &lt;em&gt;From weakling to world’s strongest hunter, an action-packed journey.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tower of God :&lt;/strong&gt; &lt;em&gt;A mysterious tower, tests of strength, and betrayal at every turn.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Omniscient Reader’s Viewpoint :&lt;/strong&gt; &lt;em&gt;Imagine waking up in your favorite web novel’s apocalyptic world.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Beginning After the End&lt;/strong&gt; : &lt;em&gt;A king reincarnated into world of magic&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;True Beauty :&lt;/strong&gt; &lt;em&gt;A heartwarming story of self-esteem and romance with K-drama adaptation in 2020.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Breaker :&lt;/strong&gt; &lt;em&gt;Martial arts battles with a secretive and charismatic mentor.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Noblesse :&lt;/strong&gt; &lt;em&gt;A vampire awakening in modern society, epic fights and humor included.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The God of High School&lt;/strong&gt; : &lt;em&gt;A high school martial arts competition takes crazy turn.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sweet Home :&lt;/strong&gt; &lt;em&gt;Survival horror with a psychological twist. Monsters, everywhere.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bastard :&lt;/strong&gt; &lt;em&gt;Thriller meets psychological horror with a chilling father-son dynamic.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Nano Machine :&lt;/strong&gt; &lt;em&gt;Nano machines from future makes kid rise up in Demonic Cult and path to the strongest. Also has other manhwa in same universe like&lt;/em&gt; &lt;em&gt;&lt;strong&gt;Absolute Sword Sense&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Gamer :&lt;/strong&gt; &lt;em&gt;High-school student with special powers make real world feel like gaming.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Academy’s Underground Professor :&lt;/strong&gt; &lt;em&gt;Former Assassin becomes professor and becomes entangled in the academy’s hidden secrets, political conspiracies, and mysterious powers.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/150eee81-2d70-4121-9b18-e6cf76fb2b18.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I’m slightly partial to action packed series but there’s plenty of popular titles in various genres available as well.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;what-sets-them-apart%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;What Sets Them Apart?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/manga-manhua-manhwa/#what-sets-them-apart%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Aspect&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Manga&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Manhua&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Manhwa&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Origin&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Japan&lt;/td&gt;
&lt;td&gt;China&lt;/td&gt;
&lt;td&gt;Korea&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Reading Direction&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Right to left&lt;/td&gt;
&lt;td&gt;Left to right&lt;/td&gt;
&lt;td&gt;Left to right&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Art Style&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Black-and-white, detailed&lt;/td&gt;
&lt;td&gt;Full-color, sleek&lt;/td&gt;
&lt;td&gt;Full-color, cinematic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serialized in magazines&lt;/td&gt;
&lt;td&gt;Digital or print&lt;/td&gt;
&lt;td&gt;Digital (vertical)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Global Reach&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Widely known&lt;/td&gt;
&lt;td&gt;Growing steadily&lt;/td&gt;
&lt;td&gt;Exploding internationally&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;
&lt;p&gt;Manga, manhua, and manhwa may share DNA, but they’ve evolved into distinct art forms with unique flavors. Manga feels like a trusted old friend, manhua like a mystical storyteller, and manhwa like your tech-savvy, trendsetting sibling.&lt;/p&gt;
&lt;p&gt;Apart from these, there are some one-shots which comes up such as my fav donghua web series Link Click. So many art forms out there telling amazing stories. :)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/1b2b2afd-a563-4220-a712-a4bc8ecec366.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Don’t be hating in any of them. Love and enjoy each 😉 story and their unique experience.&lt;/p&gt;
&lt;p&gt;💙&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Chain Abstraction</title>
		<link href="https://blog.anirudha.dev/chain-abstraction/"/>
		<updated>2024-12-09T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/chain-abstraction/</id>
		<content type="html">&lt;p&gt;Say you want to make an online payment, and instead of just clicking a button, you have to figure out whether the store accepts Visa, Mastercard, or PayPal. Now multiply that headache by 100x, and you’ve got the current state of blockchains. This is where &lt;strong&gt;chain abstraction&lt;/strong&gt; steps in — the fintech equivalent of a universal payment processor but for blockchains. It makes the Web3 world less about mind-numbing details and more about getting stuff done.&lt;/p&gt;
&lt;p&gt;Let’s dive into what chain abstraction is, why it’s the hero we need, and how you can build cool things around it.&lt;/p&gt;
&lt;h2 id=&quot;what-is-chain-abstraction-anyway%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;What Is Chain Abstraction Anyway?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#what-is-chain-abstraction-anyway%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Imagine using Venmo, Apple Pay, or Google Pay without worrying about how they talk to your bank or credit card. That’s chain abstraction for blockchains. It’s all about hiding the complex, nerdy stuff like gas fees, token standards, and wallet types so users and developers can focus on what matters: &lt;em&gt;buying that damn mocha&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;It makes interacting with blockchains feel less like coding in the Matrix and more like using Spotify. In short, it’s the magic trick that lets blockchains talk to each other and work together seamlessly.&lt;/p&gt;
&lt;h2 id=&quot;why-do-we-even-need-this%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Why Do We Even Need This?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#why-do-we-even-need-this%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Blockchains are amazing, but let’s be real: they’re a pain to use. Each chain has its quirks, its rules, and its own language. For instance:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ethereum&lt;/strong&gt; makes you worry about gas fees.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Solana&lt;/strong&gt; dazzles you with speed but has its own wallet ecosystem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Binance Smart Chain&lt;/strong&gt; screams, “Hey, we’re cheap!” but you still have to bridge assets manually.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Imagine if every payment app required you to know the bank’s internal workings. You’d delete them in a heartbeat. That’s why we need chain abstraction to fix these headaches:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Simplified User Experience&lt;/strong&gt;&lt;br /&gt;
You don’t care which blockchain an app is on. You just want to use it without Googling, “How to send tokens from Polygon to Arbitrum.”&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;More Collaboration, Less Competition&lt;/strong&gt;&lt;br /&gt;
Developers can focus on innovation instead of building the same tools for every blockchain.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Onboarding for the Masses&lt;/strong&gt;&lt;br /&gt;
Your grandma won’t care about gas fees or token bridges, but she might use Web3 if it’s as easy as buying something on Amazon.&lt;/p&gt;
&lt;p&gt;Think of chain abstraction as turning a messy fintech system into a unified, user-friendly experience:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No More Wallet Chaos&lt;/strong&gt;: Whether it’s MetaMask, Phantom, or Keplr, users can use one interface to access all their assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Universal Gas Fees&lt;/strong&gt;: Users pay with whatever tokens they have, instead of scrambling to swap for ETH, SOL, or MATIC.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain Transactions Made Easy&lt;/strong&gt;: Think of it as a blockchain version of Wise for international transfers, but instant and decentralized.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Several blockchain superheroes are already working on this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LayerZero&lt;/strong&gt;: The omnichain messaging protocol. Think WhatsApp but for blockchains.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cosmos (IBC)&lt;/strong&gt;: The OG of chain abstraction, letting blockchains chat like old friends.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Axelar Network&lt;/strong&gt;: Focused on secure cross-chain communication. Think of it as a blockchain VPN.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Polkadot&lt;/strong&gt;: Parachains make interoperability look easy, kinda like how Apple devices magically sync.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Superfluid&lt;/strong&gt;: Abstracts token standards for seamless asset streaming across different chains.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.prod.website-files.com/63996d8b3c061af402fa0609/65df4d995d272413da344412_Chain%20Abstraction.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;how-does-it-work%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;How Does It Work?&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#how-does-it-work%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chain abstraction operates like the middleware in your favorite fintech app.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Middleware Layers&lt;/strong&gt;: Like Stripe for payments, middleware abstracts the complexity of multi-chain interactions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Universal Wallets&lt;/strong&gt;: These wallets hide the “What chain are you on?” question.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gas Fee Abstraction&lt;/strong&gt;: Imagine paying transaction fees in whatever token you like. No more “insufficient ETH” pop-ups.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;so%2C-how-to-build-on-chain-abstraction&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;So, How to Build on Chain Abstraction&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#so%2C-how-to-build-on-chain-abstraction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’re a builder looking to jump in, here’s your cheat sheet:&lt;/p&gt;
&lt;h3 id=&quot;understand-the-ecosystem&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Understand the Ecosystem&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#understand-the-ecosystem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Spend time with protocols like LayerZero, Cosmos, and Axelar. They’re like the Lego sets for chain abstraction.&lt;/p&gt;
&lt;h3 id=&quot;keep-security-in-mind&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Keep Security in Mind&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#keep-security-in-mind&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Cross-chain means more doors to lock. Study cryptographic techniques and get comfy with audits.&lt;/p&gt;
&lt;h3 id=&quot;use-dev-friendly-tools&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Use Dev-Friendly Tools&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#use-dev-friendly-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Tools like Axelar SDK or Ethereum’s EIP-4337 are your best friends. Don’t reinvent the wheel.&lt;/p&gt;
&lt;h3 id=&quot;think-like-a-fintech-startup&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Think Like a Fintech Startup&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#think-like-a-fintech-startup&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Build for scalability and usability. If your app isn’t grandma-friendly, try again.&lt;/p&gt;
&lt;h3 id=&quot;some-cool-ideas-to-build&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Some Cool Ideas to Build&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chain-abstraction/#some-cool-ideas-to-build&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Here are some project ideas to flex your developer muscles:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Chain DeFi Superapp&lt;/strong&gt;&lt;br /&gt;
Think Revolut, but for DeFi. Let users swap, lend, and stake across chains in one interface.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gasless Transactions dApp&lt;/strong&gt;&lt;br /&gt;
Let users pay fees in their favorite token or abstract gas fees entirely.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Blockchain Expedia&lt;/strong&gt;&lt;br /&gt;
Aggregate dApps across chains so users can search for services like booking flights or investing, without worrying about chains.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Chain abstraction is like the UPI (Unified Payments Interface) of the blockchain world. It’s making blockchains talk to each other, play well together, and be user-friendly for everyone. If Web3 is ever going to rival fintech giants like PayPal or Stripe, this is the way forward.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Developers, this is your moment. Start building tools that make blockchains boring in the best way where the tech just works, and users don’t even notice the chains under the hood. At DripVerse, this is going to be the next frontier to build on. Keep an eye out folks…&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Chaos Theory</title>
		<link href="https://blog.anirudha.dev/chaos-theory/"/>
		<updated>2024-11-26T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/chaos-theory/</id>
		<content type="html">&lt;p&gt;Let’s talk about chaos. Not the “forgot your wallet, keys, and phone” kind of chaos, but the deep, philosophical, scientific kind. The one that makes you question if the flutter of a butterfly’s wings in Bengaluru could really spark a thunderstorm in New York. Chaos theory is basically the science of surprise. &lt;em&gt;Predicting the unpredictable&lt;/em&gt;. It’s like trying to organize your desktop files: no matter how much effort you put in, something random (or seemingly random) will inevitably throw everything out of whack. Just like that stupid &lt;code&gt;.DS_Store&lt;/code&gt; and you keep having to add to your &lt;code&gt;.gitignore&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At its core, chaos theory studies systems that are highly sensitive to initial conditions. Commonly known as “butterfly effect”. In short, small things can have big consequences. Kind of like sending a “k” in response to someone’s long emotional text. Of course, it might not be intentional. Perhaps you were occupied, driving or otherwise engaged mentally, and the logical part of your brain said to send an acknowledgement to their effort. You didn’t even mean to reply and yet you hurt the person who put an ample amount of time in sharing their deepest desires.&lt;/p&gt;
&lt;p&gt;Living in Bengaluru itself sometimes feels like total chaos. You might start with a sunny morning and end with a cyclone, all because a few atoms of air decided to take a different route. It’s a system so complex that even supercomputers give up halfway and ask for a coffee break. (Hopefully, its decaf.)&lt;/p&gt;
&lt;p&gt;But here’s the twist: chaos doesn’t mean total randomness. It’s like a toddler on a sugar high. Erratic, yes, but following its own strange logic. Chaos theory finds patterns in the madness, revealing that seemingly random events often have an underlying order. Some of us tend to understand it on a level unexplained by science. Call it intuition, gut feeling, experience or sixth sense. &lt;em&gt;Spidy sense if you’re spiderman.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/e1bb2499-4ef1-4a3b-8d5b-1c37befa2a4a.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;You encounter chaos every day, whether you realize it or not. Ever tried cooking dinner while on a video call, only to accidentally salt your tea and drink your soup? Or how about commuting in Bengaluru traffic? It’s a living, breathing example of a chaotic system where every honk feels like it could alter the entire timeline. You never which way the auto driver will turn. Keep you guessing and on your feet.&lt;/p&gt;
&lt;p&gt;Chaos is also why you can’t predict your social media feed. Algorithms try their best, but your decision to randomly like one cat meme over another might send your entire feed spiraling into chaos. Now you’re stuck with ads for cat food, and you don’t even own a pet.&lt;/p&gt;
&lt;h3 id=&quot;the-digital-butterfly-effect&quot; tabindex=&quot;-1&quot;&gt;The Digital Butterfly Effect &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chaos-theory/#the-digital-butterfly-effect&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In cyberspace, chaos theory takes on a whole new meaning. The internet is a hyper-connected, highly sensitive system where small changes—like a single line of buggy code—can snowball into global meltdowns. A small commit in an unknown library can bring down tech giants and nobody would have a clue of what happened cause that one intern happily strolled off home already.&lt;/p&gt;
&lt;p&gt;Take cybersecurity, for example. A tiny vulnerability in a server can let hackers in, causing cascading chaos across networks. Or think about AI. A chatbot misinterprets one user’s sarcasm, and suddenly, the entire algorithm thinks everyone loves pineapple on pizza. Hell no. Keep that shit away from my pizza, thanks.&lt;/p&gt;
&lt;p&gt;Social media today is the new ground for chaos. A single tweet can spark revolutions, cancel celebrities, or send stock markets tumbling. Of course it first needs to reach masses. But sometimes an unknown random account can overthrow billions of dollars from the market. It’s chaos theory on steroids, amplified by algorithms that thrive on unpredictability.&lt;/p&gt;
&lt;p&gt;There has been attempts to define this chaos in the past. Some have even come up with mathematical proofs and equations. Read more about the work from the greats from &lt;strong&gt;Henri Poincare (1889)&lt;/strong&gt; and &lt;strong&gt;Cartwight and Littlewood (1945)&lt;/strong&gt; to modern theories from &lt;strong&gt;Feigenbaum (1978)&lt;/strong&gt; who studied modern day calculator and focused on the bifurcation cascade of the logistic map. Particularly, the way that bifurcations piled on top of bifurcations in a forking structure that showed increasing detail at increasingly fine scales.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/d98c9670-db59-451c-a24d-d50511701f7a.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Chaos theory, at its core, is about unpredictability in complex systems. It’s not inherently a bad thing, but when left unchecked, its implications can “consume” us. Specially in the modern context of interconnected digital lives.&lt;/p&gt;
&lt;p&gt;In cyberspace, even small actions (like liking a post or sending a tweet) can spiral into unintended consequences. Algorithms thrive on chaotic systems, serving us a never ending stream of content designed to hold our attention. Before you know it, you’re 3 hours deep into cat video territory with no way out. A minor oversight, a weak password or an unpatched system, can snowball into global disruptions. Just imagine a single compromised smart device setting off a chain of ransomware attacks. In the interconnected chaos of cyberspace, small errors have catastrophic potential.&lt;/p&gt;
&lt;p&gt;The randomness of chaotic systems can make us feel powerless. If we don’t understand why algorithms recommend certain things or why systems behave erratically, we’re essentially passengers on a runaway train.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Chaos doesn’t have to consume us. It can empower us if we respect it. Let it challenge us, teach us, and inspire us. But let’s not hand it the keys to the kingdom without safeguards. After all, the goal isn’t to control every butterfly. It’s to ensure their flutters create growth, not destruction.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, how do we embrace chaos in cyberspace without letting it consume us?&lt;/p&gt;
&lt;h3 id=&quot;cybersecurity-resilience&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cybersecurity Resilience&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chaos-theory/#cybersecurity-resilience&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We need systems that can handle surprises. Think firewalls and protocols that can adapt, recover, and bounce back faster than your Uber driver navigating Bengaluru traffic.&lt;/p&gt;
&lt;h3 id=&quot;algorithm-transparency&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Algorithm Transparency&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chaos-theory/#algorithm-transparency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Chaotic systems are bad enough without black-box algorithms making decisions nobody understands. Let’s demand clarity and accountability from AI systems. Personally I really don’t like black box systems. Makes me utterly nervous.&lt;/p&gt;
&lt;h3 id=&quot;decentralized-networks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Decentralized Networks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chaos-theory/#decentralized-networks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Centralized systems are like that one Jenga piece holding the tower together—too much pressure, and they collapse. Decentralization could distribute the load and reduce systemic vulnerabilities.&lt;/p&gt;
&lt;h3 id=&quot;ethics-in-ai-and-web3&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Ethics in AI and Web3&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/chaos-theory/#ethics-in-ai-and-web3&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As we dive into Web3 and AI-driven worlds, ethical guidelines need to be as robust as the code itself. Because the last thing we need is chaotic systems learning bad behavior from us. Clearer the guidelines, the more cases it handles, the more monitored it becomes. It’s like raising a kid I suppose.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/aff82376-4d59-43b0-99d7-2fb6e784b88d.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Chaos is here to stay, both in the real world and the digital one. And while we can’t predict or control everything, we can create systems that are resilient, transparent, and ethical. Think of it as learning to dance with the butterfly rather than swatting it away. So, whether it’s a misplaced decimal in a line of code or a viral meme that shifts global consciousness, chaos is both the problem and the solution. Let’s embrace it, adapt to it, and maybe, just maybe, turn it into a force for good in our shiny new digital frontier.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Find meaning to the madness. Both outside and within!&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Network Interfaces</title>
		<link href="https://blog.anirudha.dev/network-interfaces/"/>
		<updated>2024-11-23T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/network-interfaces/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;I was working on a side project, which led me to study about various network interfaces. Felt like some rabit hole I fell through. Before I knew it, I had listing down over 10 different network interfaces. So, thought of putting them together for somebody else also studying network interfaces.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;TCP/IP, or Transmission Control Protocol/Internet Protocol, is a framework that organizes the communication protocols used on the internet and similar networks. TCP/IP network interfaces are the backbone of modern digital communication, enabling devices to connect and exchange data seamlessly across various network types. These interfaces form the essential link between hardware and software, facilitating everything from local area networks (LANs) to global internet connectivity. With options ranging from Ethernet and Wi-Fi to advanced protocols like MPLS and VPN interfaces, TCP/IP ensures scalability, reliability, and versatility in diverse applications.&lt;/p&gt;
&lt;p&gt;The TCP/IP protocol suite supports a wide range of network interfaces.&lt;/p&gt;
&lt;h3 id=&quot;standard-ethernet-version-2-(en)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Standard Ethernet Version 2 (en)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#standard-ethernet-version-2-(en)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Ethernet Version 2, created by Digital Equipment Corporation, Intel, and Xerox (DIX), is the go-to standard for wired local networks. Think of it as the classic way to connect your desktop to a router using an Ethernet cable (you know, the one with the RJ45 connector). It’s super reliable and perfect for high-speed connections, whether you’re setting up a home office or a big office network. Simple, solid, and it just works!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: High reliability, consistent speed, and wide adoption.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Limited mobility compared to wireless standards like Wi-Fi.&lt;/p&gt;
&lt;h3 id=&quot;ieee-802.3-(et)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;IEEE 802.3 (et)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#ieee-802.3-(et)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;IEEE 802.3 is the standard behind Ethernet that works with twisted-pair and fiber-optic cables. It covers specs like 10BASE-T and 100BASE-TX, which power Fast Ethernet using Cat 5e cables in many offices. It’s super reliable and has become the backbone of modern Ethernet networks, especially in enterprise environments.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Scalability from 10 Mbps to 100 Gbps; supports various media types.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Higher cost for fiber-optic variants compared to copper-based standards.&lt;/p&gt;
&lt;h3 id=&quot;token-ring-(tr)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Token Ring (tr)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#token-ring-(tr)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Token Ring is an old-school LAN tech where devices take turns to talk by passing a “token” around—kind of like a speaking stick in a meeting. It was big back in the day, especially in banking systems with IBM’s Token Ring networks. While it’s pretty much obsolete now, it did a great job of ensuring no two devices tried to send data at the same time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Deterministic access; suitable for real-time systems.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Slower than Ethernet; less flexible due to token passing.&lt;/p&gt;
&lt;h3 id=&quot;serial-line-internet-protocol-(slip)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Serial Line Internet Protocol (SLIP)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#serial-line-internet-protocol-(slip)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;SLIP was one of the first protocols used for point-to-point connections over serial lines. If you remember the dial-up modems from the ’90s, that’s where SLIP came into play, helping to send IP packets over those old telephone lines. It may be outdated now, but it was a big step forward in getting the internet up and running in its early days.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Simple and lightweight.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: No error detection; replaced by Point-to-Point Protocol (PPP).&lt;/p&gt;
&lt;h3 id=&quot;loopback-(lo)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Loopback (lo)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#loopback-(lo)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The loopback interface is like a virtual playground for your computer’s network. It’s what you use when you access &lt;code&gt;localhost&lt;/code&gt; (127.0.0.1) to test things like web servers or debug apps without needing an actual network connection. Perfect for internal testing and troubleshooting, it’s always there when you need it!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Always available and highly reliable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Limited to local machine interactions.&lt;/p&gt;
&lt;h3 id=&quot;fddi-(fiber-distributed-data-interface)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;FDDI (Fiber Distributed Data Interface)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#fddi-(fiber-distributed-data-interface)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;FDDI is a high-speed network tech that uses fiber optics, perfect for handling big jobs like connecting backbone networks in cities. It’s built to be super fast and reliable, making it great for things like video streaming and other high-bandwidth tasks across wide-area networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Redundancy through dual-ring architecture.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Expensive compared to Ethernet; largely obsolete today.&lt;/p&gt;
&lt;h3 id=&quot;serial-optical-(so)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Serial Optical (so)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#serial-optical-(so)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Serial optical tech is all about sending data over long distances using fiber optic cables. It’s what connects data centers and makes high-speed, low-latency communication possible. Perfect for when you need to move a lot of data fast and over a long stretch!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Extremely low latency and high bandwidth.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: High installation and maintenance costs.&lt;/p&gt;
&lt;h3 id=&quot;atm-(asynchronous-transfer-mode)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;ATM (Asynchronous Transfer Mode)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#atm-(asynchronous-transfer-mode)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;ATM largely relies on a networking technology using fixed-size cells for reliable data transmission. It was popular with broadband ISPs for handling data, voice, and video all on the same network. Great at juggling different types of traffic efficiently, it was a solid choice for reliable communication back in the day.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Guaranteed bandwidth for real-time services.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Complex configuration; overshadowed by modern IP-based technologies.&lt;/p&gt;
&lt;h3 id=&quot;point-to-point-protocol-(ppp)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Point-to-Point Protocol (PPP)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#point-to-point-protocol-(ppp)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;PPP is the protocol that makes direct connections between two nodes work, like DSL connections between your modem and ISP. It added features like security and authentication, making internet access safer and more reliable. It took over from SLIP and quickly became the better option for getting online.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Supports authentication and compression.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Inefficient for modern high-speed connections.&lt;/p&gt;
&lt;h3 id=&quot;virtual-ip-address-(vi)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Virtual IP Address (vi)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#virtual-ip-address-(vi)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Virtual IPs let multiple devices or services share the same IP address, which is super handy for things like load balancers in cloud setups. They help keep systems running smoothly by balancing traffic and ensuring high availability and redundancy. Essential for keeping things reliable in distributed systems!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Improves redundancy and fault tolerance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Requires advanced configuration and monitoring.&lt;/p&gt;
&lt;h3 id=&quot;apple-ncm-private-interface-(anpi)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Apple NCM Private Interface (anpi)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#apple-ncm-private-interface-(anpi)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Apple’s NCM Private Interface (anpi) is their own custom setup for networking and connectivity. Think USB-to-Ethernet adapters for MacBooks and other Apple devices—it’s all about making things work smoothly within the Apple ecosystem. Just another way Apple keeps everything connected seamlessly!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Seamless user experience for Apple devices.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Proprietary; limited to Apple environments.&lt;/p&gt;
&lt;h3 id=&quot;apple-specific-for-vpn-and-back-to-my-mac-(utun)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Apple Specific for VPN and Back to My Mac (utun)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#apple-specific-for-vpn-and-back-to-my-mac-(utun)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;utun&lt;/code&gt; interface in macOS is used for VPNs and remote desktop connections, like when you access your MacBook remotely using &lt;strong&gt;Back to My Mac&lt;/strong&gt;. It’s all about making sure Apple users can securely connect to their devices from anywhere. A simple way to stay connected, even when you’re not right in front of your Mac! However it might show up even when your Back to My Mac is disabled or inaccessible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Tailored for privacy and encryption.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Exclusivity to macOS; less customizable than generic VPN solutions.&lt;/p&gt;
&lt;h3 id=&quot;bonded-interfaces-(bond)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Bonded Interfaces (bond)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#bonded-interfaces-(bond)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Bonded interfaces combine multiple network connections into one super-fast, high-bandwidth link. It’s like merging several lanes on a highway to handle more traffic at once. Servers use things like Link Aggregation Control Protocol (LACP) to balance the load and add redundancy, making sure your network stays fast and reliable, even if one link fails.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Increases speed and fault tolerance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Requires hardware and software compatibility.&lt;/p&gt;
&lt;h3 id=&quot;vpn-interfaces-(tun%2Ftap)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;VPN Interfaces (tun/tap)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#vpn-interfaces-(tun%2Ftap)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;tun&lt;/code&gt; and &lt;code&gt;tap&lt;/code&gt; interfaces are key for VPN connections. &lt;code&gt;tun&lt;/code&gt; handles routing packets, while &lt;code&gt;tap&lt;/code&gt; works at the Ethernet level. They’re used in setups like OpenVPN or WireGuard to create secure, encrypted internet connections. Basically, they help you safely surf the web or connect to a network even when you’re on a public or unsecured network.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Strong encryption and flexibility.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Slower than direct connections due to encryption overhead.&lt;/p&gt;
&lt;h3 id=&quot;isdn-(integrated-services-digital-network)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;ISDN (Integrated Services Digital Network)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#isdn-(integrated-services-digital-network)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;ISDN (Integrated Services Digital Network) was a big deal back in the day for transferring both voice and data over the same line. It was used for things like video conferencing in the early 2000s, especially in remote areas where newer tech wasn’t available. ISDN helped bridge the gap between old-school analog and modern digital communication.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Supports simultaneous voice and data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Outdated; replaced by DSL and fiber technologies.&lt;/p&gt;
&lt;h3 id=&quot;vlan-interfaces-(vlan)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;VLAN Interfaces (vlan)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#vlan-interfaces-(vlan)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;VLANs (Virtual LANs) let you split up a network into smaller, isolated segments, all using the same physical hardware. With VLAN tagging on managed switches, you can control and separate traffic, boosting both security and efficiency. It’s like creating mini-networks within a big one, so things stay organized and safe.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Reduces broadcast traffic and enhances security.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Configuration complexity for large setups.&lt;/p&gt;
&lt;h3 id=&quot;virtual-machine-interfaces-(vmx%2C-vnet%2C-etc.)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Virtual Machine Interfaces (vmx, vnet, etc.)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#virtual-machine-interfaces-(vmx%2C-vnet%2C-etc.)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Virtual Machine Interfaces, like &lt;code&gt;vmx&lt;/code&gt; or &lt;code&gt;vnet0&lt;/code&gt; in VMware and VirtualBox, are used to connect virtual machines to networks in virtualized environments. They’re perfect for simulating networks during development and testing. These interfaces are essential for making virtualization and cloud computing run smoothly by setting up virtual networks within your machines.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Highly customizable and scalable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Relies heavily on host system performance.&lt;/p&gt;
&lt;h3 id=&quot;mpls-(multiprotocol-label-switching)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;MPLS (Multiprotocol Label Switching)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#mpls-(multiprotocol-label-switching)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;MPLS (Multiprotocol Label Switching) is a method for forwarding data that helps optimize how traffic flows across networks. It’s often used in enterprise WANs to make sure data moves quickly and efficiently. By minimizing delays, MPLS ensures low-latency communication, especially across large networks.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Efficient and scalable for enterprise WANs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Costly and requires specialised expertise.&lt;/p&gt;
&lt;h3 id=&quot;fibre-channel-over-ethernet-(fcoe)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Fibre Channel over Ethernet (FCoE)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#fibre-channel-over-ethernet-(fcoe)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Fibre Channel over Ethernet combines Ethernet with high-speed Fibre Channel technology, making it perfect for storage networking. It’s commonly used in data centers to connect servers to shared storage systems, letting everything run smoothly and efficiently while keeping speeds high. It’s like merging two networks to create one super-fast, reliable connection for storage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Simplifies data center cabling.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Requires compatible hardware and specialised management.&lt;/p&gt;
&lt;h3 id=&quot;lte%2F5g-(cellular)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;LTE/5G (cellular)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#lte%2F5g-(cellular)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;LTE and 5G are all about getting fast internet on the go, using cellular networks. Whether you’re tethering mobile data to your laptop via a hotspot or just using it on your phone, these technologies provide high-speed wireless internet for your devices, letting you stay connected no matter where you are.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Mobility and wide coverage.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Prone to signal interference; higher latency than wired networks.&lt;/p&gt;
&lt;h3 id=&quot;infiniband-(ib)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;InfiniBand (ib)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#infiniband-(ib)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It’s a super-fast networking technology used in high-performance computing (HPC) environments, like supercomputers and large clusters. It’s built for low-latency, high-throughput data transfers, delivering extreme performance where speed and efficiency are key. Perfect for environments that need to move huge amounts of data quickly and reliably.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Low latency and high throughput.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: High cost; limited to specialised use cases.&lt;/p&gt;
&lt;h3 id=&quot;virtual-ethernet-(veth)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Virtual Ethernet (veth)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#virtual-ethernet-(veth)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Virtual Ethernet (veth) is a software-based interface used to connect containers and virtual machines in environments like Docker or Kubernetes. It handles networking within containerized applications, ensuring they can communicate with each other. There’s also another similar &lt;code&gt;docker&lt;/code&gt; interface which shows up for docker containers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Lightweight and efficient.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Not suitable for physical networking.&lt;/p&gt;
&lt;h3 id=&quot;bluetooth-(bt)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Bluetooth (bt)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#bluetooth-(bt)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Bluetooth (bt) is a short-range wireless tech that lets devices connect without cables. It’s what you use to pair things like wireless headphones to your smartphone or connect IoT devices with minimal power usage. It’s perfect for a wide range of wireless connections, from gadgets to smart home devices.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Low power consumption and ease of use.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Limited range and data transfer speed.&lt;/p&gt;
&lt;h3 id=&quot;wi-fi-(wireless-lan-interface)-(wlan)&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Wi-Fi (Wireless LAN Interface) (wlan)&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/network-interfaces/#wi-fi-(wireless-lan-interface)-(wlan)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Wireless tech that connects devices to local networks, like the Wi-Fi at home or in your office. It’s what lets you get online without needing cables, whether it’s on your phone, laptop, or tablet. It’s the most popular way to connect wirelessly to the internet and networks today.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Flexibility and ease of deployment.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Lower reliability and security compared to wired networks.&lt;/p&gt;
&lt;p&gt;Hopefull, this gave you a brief over the commonly known network interfaces in recent times.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Each of these interfaces has unique advantages, making them essential in various networking scenarios, from enterprise data centers to everyday consumer technology to your very own home lab. Understanding their capabilities helps optimise their deployment in modern network environments.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There are even more network interfaces than listed above here. But, will leave them to be explored in near future.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The Power of Example</title>
		<link href="https://blog.anirudha.dev/example/"/>
		<updated>2024-11-21T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/example/</id>
		<content type="html">&lt;p&gt;In the labyrinth of modern life, where individuality is often celebrated above all else, the idea of leading by example remains an esoteric yet vital concept. For the modern individual—a seeker of authenticity and a curator of their experiences—the power of example is not merely about imitation. It is about setting a precedent that inspires action, demonstrates clarity, and communicates intentions in ways words alone cannot.&lt;/p&gt;
&lt;p&gt;Whether you are launching a product, building a platform, or starting a business, the principle of leading by example is a cornerstone of credibility and success. It transcends rhetoric, presenting a tangible blueprint of possibilities for your audience, stakeholders, or users.&lt;/p&gt;
&lt;p&gt;When introducing something new—be it a groundbreaking product, a revolutionary platform, or an entrepreneurial venture—uncertainty is the greatest hurdle. The unfamiliar breeds skepticism. People crave a tangible representation of your promise. This is where the power of example comes into play.&lt;/p&gt;
&lt;p&gt;For a new product, a well-designed demo video or prototype demonstrates its utility better than any ad copy. Visual storytelling in a demo video can capture attention and build excitement, showcasing real-life scenarios where the product solves problems or enhances experiences. A prototype, on the other hand, allows stakeholders—be it investors, collaborators, or early adopters—to physically or virtually interact with the product, gaining firsthand insight into its functionality, design, and reliability.&lt;/p&gt;
&lt;p&gt;Such examples not only demonstrate utility but also foster emotional engagement. They help customers visualize how the product fits into their lives, making the value proposition clearer. Whether it’s the intuitive interface of a new app, the cutting-edge design of a gadget, or the unique features of a software tool, a demo or prototype reduces uncertainty, accelerates decision-making, and establishes credibility in ways that words alone cannot.&lt;/p&gt;
&lt;p&gt;This approach is particularly effective in today’s digital-first world, where attention spans are short, and visuals often carry more weight than text. A compelling demonstration can serve as the ultimate proof point, converting curiosity into commitment.&lt;/p&gt;
&lt;p&gt;For a platform, showcasing early adopters or case studies provides tangible proof of its value, helping potential users understand how it can meet their specific needs. By highlighting real-world applications, such examples turn abstract features into relatable outcomes, making the platform’s benefits not only clear but also credible.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/9fb7d78580cb4be4f487548a39fba012.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In its early days, &lt;strong&gt;LinkedIn&lt;/strong&gt; showcased stories of professionals who used the platform to land new job opportunities or grow their networks. These success stories provided relatable examples of how the platform could be valuable for career growth, convincing others to join and use the platform for similar outcomes.&lt;br /&gt;
Before &lt;strong&gt;Slack&lt;/strong&gt; became a household name in workplace communication, the company highlighted how early adopters like NASA’s Jet Propulsion Laboratory used it to streamline team collaboration. Sharing case studies of how teams used Slack to enhance productivity resonated with other organizations looking for similar solutions.&lt;br /&gt;
&lt;strong&gt;Shopify&lt;/strong&gt; frequently shares case studies of small businesses and entrepreneurs who used its platform to create successful online stores. By showcasing stories of users who turned ideas into profitable businesses, Shopify appeals to aspiring entrepreneurs by proving its relevance in the e-commerce space.&lt;br /&gt;
&lt;strong&gt;Coursera&lt;/strong&gt; effectively highlights stories of learners who transitioned into new careers or gained significant professional skills through its courses. By sharing these testimonials, Coursera inspires prospective learners to see how the platform can help them achieve similar goals.&lt;br /&gt;
As a platform for online payments, &lt;strong&gt;Stripe&lt;/strong&gt; gained early traction by showcasing how startups like Lyft and Kickstarter successfully used its API to handle their payment processing. These examples gave developers confidence in the platform’s reliability and scalability, accelerating its adoption.&lt;/p&gt;
&lt;h3 id=&quot;why-it-works%3A&quot; tabindex=&quot;-1&quot;&gt;Why It Works: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/example/#why-it-works%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Relevance&lt;/strong&gt;: Case studies show potential users how they might use the platform, reducing uncertainty.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Proof of Success&lt;/strong&gt;: Highlighting early adopters’ achievements builds trust by demonstrating the platform’s real-world effectiveness.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inspiration&lt;/strong&gt;: These stories inspire users by illustrating the potential outcomes of adopting the platform, making them more likely to engage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By leveraging early adopters and case studies, platforms can foster credibility, build a sense of community, and accelerate user acquisition by aligning their features with real-life outcomes. This approach transforms potential skepticism into excitement, turning hesitant prospects into loyal users. &lt;em&gt;&lt;strong&gt;Even for a startup or business&lt;/strong&gt;&lt;/em&gt;*, the founder’s conduct and transparency in decisions set the tone for company culture and customer trust.*&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/11e0820978c0dbdd353ec4223911c6ed.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Just as stories are essential for emotional resonance, examples are the proof points that convert abstract ideas into actionable understanding. In the world of software development, Test-Driven Development (TDD) emphasizes writing tests before writing the actual code. These tests serve as examples of what the program is supposed to do. They ensure clarity, define expectations, and create a framework within which innovation can thrive.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Clarity&lt;/strong&gt;: Tests, like examples, define the outcomes. They ensure everyone—from developers to stakeholders—understands the objectives.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Incremental Growth&lt;/strong&gt;: By starting small and iteratively adding features that pass predefined tests, TDD mirrors how businesses can use small, clear examples to grow credibility.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Feedback Loop&lt;/strong&gt;: The continuous validation of code through tests mirrors how real-world examples validate a business’s promises.&lt;/p&gt;
&lt;p&gt;Adopting the ethos of TDD in broader contexts emphasizes the importance of defining goals through actionable, testable precedents. Whether it’s a startup pitch or a marketing strategy, thinking in terms of clear, “testable” examples can make abstract ambitions more relatable and trustworthy.&lt;/p&gt;
&lt;h3 id=&quot;tesla%E2%80%99s-product-strategy&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Tesla’s Product Strategy&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/example/#tesla%E2%80%99s-product-strategy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Tesla didn’t just sell the idea of electric vehicles; it delivered the Tesla Roadster, a high-performance sports car, as proof of concept. The example set the tone for its revolutionary approach to sustainable energy.&lt;/p&gt;
&lt;h3 id=&quot;openai%E2%80%99s-transparency-with-gpt-models&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;OpenAI’s Transparency with GPT Models&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/example/#openai%E2%80%99s-transparency-with-gpt-models&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;OpenAI regularly shares research papers and use-case demos to educate and set an example for AI’s ethical potential. These actions demonstrate their commitment to innovation and responsibility.&lt;/p&gt;
&lt;h3 id=&quot;airbnb%E2%80%99s-early-user-strategy&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Airbnb’s Early User Strategy&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/example/#airbnb%E2%80%99s-early-user-strategy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Before Airbnb scaled, its founders went door-to-door to help hosts perfect their listings. This example of dedication not only enhanced trust but also demonstrated the platform’s value to both hosts and guests.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The power of example is universal, yet its execution varies across contexts. From inspiring team members to convincing potential investors, the principles of clarity, reliability, and demonstrable proof remain constant.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	<entry>
		<title>What&#39;s Your Paranoia?</title>
		<link href="https://blog.anirudha.dev/paranoia/"/>
		<updated>2024-11-18T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/paranoia/</id>
		<content type="html">&lt;p&gt;In the complex maze of the modern mind, where every turn presents a new fear, a new inadequacy, or a new ambition, lies the pervasive whisper of paranoia. Not the kind typically associated with conspiracy theories or spy thrillers, but a more subtle, insidious form that has become almost a default setting for human interaction in today’s society. Here, we explore the multifaceted nature of personal paranoia, its origins, its impacts, and its philosophical implications.&lt;/p&gt;
&lt;h2 id=&quot;the-spectrum-of-modern-paranoia&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Spectrum of Modern Paranoia&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#the-spectrum-of-modern-paranoia&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Paranoia today isn’t just about fearing surveillance or betrayal; it’s a broad spectrum that includes the fear of time slipping away, not accumulating enough knowledge, not achieving enough success, or not possessing enough wealth. This isn’t clinical paranoia but rather a societal condition where we measure themselves against an ever-escalating standard of what it means to be ‘enough’.&lt;/p&gt;
&lt;h3 id=&quot;time-%E2%8F%B1%EF%B8%8F&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Time ⏱️&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#time-%E2%8F%B1%EF%B8%8F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The relentless march of time in a society obsessed with productivity and youth fosters a pervasive paranoia of aging, creating an almost existential fear of falling behind. We are constantly reminded that success has an unspoken expiration date, with youth glorified as the peak of vitality, creativity, and relevance. This fixation seeps into our daily lives, pressuring us to achieve more in less time, to seize every fleeting opportunity, and to stay perpetually “in the game.” It transforms the natural process of aging into something to be resisted, denied, or even feared, as though the mere passage of years diminishes our value. This paranoia is amplified by social media’s highlight reels and the cultural obsession with “overnight success,” leaving many feeling as if they’re racing against an invisible clock, desperate to capture life’s elusive milestones before the sands of time run out. In this unrelenting pursuit, we often overlook the quiet beauty of living in the moment, trading peace for a battle against a clock that never pauses.&lt;/p&gt;
&lt;h3 id=&quot;knowledge-%F0%9F%93%96&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Knowledge&lt;/strong&gt; 📖 &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#knowledge-%F0%9F%93%96&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In an age where information is at our fingertips yet overwhelming, there’s a constant anxiety about not knowing enough, about being left behind in the intellectual race. The internet has democratized access to knowledge, but it has also created a relentless pressure to keep up. Professionals feel compelled to master every new industry trend, fearing obsolescence in a hyper-competitive job market where expertise seems to have an ever-shortening shelf life. For instance, a software developer might feel inadequate if they aren’t fluent in the latest programming languages, even if their core skills remain relevant. Similarly, a student scrolling through endless online courses may feel paralyzed, unable to decide which skill to learn, all the while haunted by the thought that everyone else is learning faster, achieving more, also known as &lt;em&gt;&lt;strong&gt;Choice Overload&lt;/strong&gt;&lt;/em&gt;. Even outside of formal education or work, the sheer volume of information—news updates, academic papers, social media debates—creates a gnawing fear of being uninformed or excluded from critical conversations. This constant exposure to the vastness of what we don’t know fuels a deep-seated paranoia that, no matter how much we learn, it will never be enough. In a way, we are all living in imposter syndrome. How did we all collectively get here together?&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/906a4e65-6a76-4703-8e92-b697c2480d56.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;success-%F0%9F%8F%86&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Success 🏆&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#success-%F0%9F%8F%86&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Defined by societal benchmarks, success can become a source of paranoia where failure, or even just the lack of extraordinary achievement, feels like a personal catastrophe. This pressure often manifests in careers, where the absence of rapid promotions or prestigious titles can feel like falling behind in an invisible competition. For example, a young entrepreneur may feel consumed by anxiety if their startup doesn’t become the next billion-dollar unicorn within a few years, especially when bombarded by stories of prodigies who achieve massive success before turning 30.&lt;/p&gt;
&lt;p&gt;Students often grapple with this paranoia as well, comparing themselves to peers publishing groundbreaking research or securing scholarships to elite institutions. Similarly, on social media platforms, creators face an unspoken race to amass followers, likes, and viral moments, with each day that passes without such milestones exacerbating the fear of irrelevance.&lt;/p&gt;
&lt;p&gt;Even in personal lives, societal benchmarks can overshadow individuality. The expectation to marry by a certain age, buy a home, or achieve financial independence creates an underlying paranoia of “not making it” in time. A 35-year-old who chooses to travel or explore unconventional paths might feel judged or question their decisions when compared to peers who are seemingly settled.&lt;/p&gt;
&lt;p&gt;These societal pressures cultivate an environment where the pursuit of success isn’t just about growth but about avoiding the stigma of perceived failure, leaving many trapped in a cycle of self-doubt and relentless striving.&lt;/p&gt;
&lt;h3 id=&quot;wealth-%F0%9F%92%B0&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Wealth&lt;/strong&gt; 💰 &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#wealth-%F0%9F%92%B0&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The visibility of wealth via social media and global connectivity has turned financial security into a race where many feel they are lagging. Platforms like Instagram and TikTok showcase lavish lifestyles, luxury vacations, and material possessions that often serve as symbols of success. This constant exposure can create an illusion that everyone else is thriving financially, leaving many grappling with feelings of inadequacy.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“The more we are surrounded by people who have apparently attained a great deal, the more difficult it becomes to be content with anything less.”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;– Alain de Botton&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For someone struggling to make ends meet or simply building their financial foundation, seeing peers—or even strangers—displaying their achievements can foster an insidious paranoia. Questions like &lt;em&gt;“Am I earning enough?”&lt;/em&gt; or &lt;em&gt;“Will I ever achieve that level of wealth?”&lt;/em&gt; just rage through on a daily basis. The pressure is magnified in a world where wealth is often equated with worth, and financial setbacks are sometimes perceived as personal failures rather than circumstantial challenges.&lt;/p&gt;
&lt;h2 id=&quot;since-the-postmodern-society&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Since the Postmodern Society&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#since-the-postmodern-society&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This pervasive paranoia didn’t emerge in a vacuum. It’s a child of postmodernity, where traditional narratives have been fragmented, and the individual is thrown into a world of infinite choices, identities, and paths. The breakdown of grand narratives leaves a void, often filled with personal insecurities and fears, many of which we still carry on, alongwith the ever increasing new variants of the same.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/40b6d7ae3a171f21ca0c723de60f8bf9.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;shaping-communities-and-life&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Shaping Communities and Life&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#shaping-communities-and-life&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This collective paranoia shapes not just individual psyches but entire communities. It fosters a competitive rather than cooperative societal framework where:&lt;/p&gt;
&lt;p&gt;Trust becomes scarce as we suspect others of harboring the same insecurities or worse, of possessing what we lack. Relationships become fragile, overshadowed by silent comparisons and unspoken doubts. Even moments of connection can feel transactional, weighed down by the fear of ulterior motives or hidden agendas. In a world where everyone seems to be competing for the same finite resources—be it success, validation, or affection—vulnerability becomes a risk too great to take.&lt;/p&gt;
&lt;p&gt;Community Building is challenged as people, driven by their fears, might retreat into themselves, or engage in superficial interactions based on perceived status or success. Life Choices are often influenced more by fear of what might go wrong than by passion or joy, leading to a life lived in anticipation of disaster rather than celebration of possibility.&lt;/p&gt;
&lt;h2 id=&quot;a-double-edged-sword&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;A Double-Edged Sword&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/paranoia/#a-double-edged-sword&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For some, it can fuel ambition, pushing us to work harder, learn more, and strive for better, viewing life as a game that must be played to win. It can heighten awareness of real dangers or societal issues, prompting proactive behavior in areas like personal security or financial planning.&lt;br /&gt;
However, the constant undercurrent of fear can lead to stress, anxiety, and depression, undermining the very success it seeks to achieve. It might erode the essence of human connections, replacing empathy with envy or indifference.&lt;/p&gt;
&lt;p&gt;The fears we harbor shape the decisions we make, the relationships we build, and the paths we choose. Yet, here lies a paradox:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Creation of Reality&lt;/strong&gt;: If paranoia shapes our actions, are we not also shaping our reality? Could our destiny be both a manifestation of our fears and our desires?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Choice&lt;/strong&gt;: Knowing this, we stand at a crossroads where we can either let paranoia dictate our journey or use our awareness to navigate by starlight rather than storm clouds.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a society striving for progress, could we perhaps see paranoia not just as a burden but as a signal? A call to delve deeper into ourselves, to understand what truly unnerves us and why. That part of your brain you’ve locked away, avoided, averted and ignored.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/91c92d3e-64de-4a38-a4f0-7bf07e585b94.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;By confronting our fears, we might strip away the layers of societal expectation to find what genuinely matters to us. We can begine to understand our common fears could bridge divides, fostering a sense of shared human experience rather than competition. Most importantly, talk about it. Doesn’t matter with whom. However paranoid you are, you must trust at least one person. Perhaps our destiny is not predefined but is instead the sum of our reactions to our fears, where overcoming paranoia becomes an evolutionary step toward a more enlightened existence.&lt;/p&gt;
&lt;p&gt;As we navigate this age of personal paranoia, we are left with pivotal questions: &lt;em&gt;Are we prisoners of our fears, or are they the very lessons that guide our evolution?&lt;/em&gt; &lt;em&gt;Can we transform paranoia from a shadow over our lives into a tool for personal and collective awakening?&lt;/em&gt; &lt;em&gt;What kind of human do we become when we decide to confront our deepest fears, and how does this choice resonate through the tapestry of our destiny?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let me know if you find the answers before me. :)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Decentralising the Web</title>
		<link href="https://blog.anirudha.dev/decentralising-the-web/"/>
		<updated>2024-11-17T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/decentralising-the-web/</id>
		<content type="html">&lt;p&gt;The web, in its earliest form, was envisioned as a decentralized platform—a space where anyone could share information without gatekeepers. Over time, however, the internet has become centralized. A handful of corporations now control vast amounts of online data, dictating how we interact, transact, and communicate. This centralization has led to issues like censorship, data privacy violations, and monopolistic practices. Sorry, didn’t mean to go full Mr Robot here. This is more on technical advancement and why you should care about it.&lt;/p&gt;
&lt;p&gt;Decentralizing the web is a movement to restore power to individuals by creating systems where data and control are distributed, not concentrated. At its core is the idea of a web owned by its users rather than intermediaries. It is the foundation of what we now call &lt;strong&gt;Web3&lt;/strong&gt; or &lt;strong&gt;Web3.0&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;the-promise-of-blockchain-and-what-led-to-its-success&quot; tabindex=&quot;-1&quot;&gt;The Promise of Blockchain and What Led to Its Success &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-the-web/#the-promise-of-blockchain-and-what-led-to-its-success&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Blockchain technology lies at the heart of decentralization. A blockchain is a distributed ledger that records transactions across multiple computers, ensuring transparency and immutability. The technology became mainstream with Bitcoin, a decentralized cryptocurrency introduced in 2009. It offered a revolutionary alternative to traditional banking systems by allowing peer-to-peer transactions without intermediaries.&lt;/p&gt;
&lt;p&gt;Blockchain’s success stems from its potential to solve real-world problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Trust&lt;/strong&gt;: Transactions are secure, verified, and transparent.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ownership&lt;/strong&gt;: Users own their data and digital assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: Decentralized networks are open to anyone with internet access.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The Ethereum blockchain expanded this promise by introducing &lt;strong&gt;smart contracts&lt;/strong&gt;, enabling decentralized applications (dApps). This innovation fueled the rise of decentralized finance (DeFi), non-fungible tokens (NFTs), and decentralized autonomous organizations (DAOs), paving the way for Web3.&lt;/p&gt;
&lt;h3 id=&quot;the-current-state-of-blockchain-and-web3&quot; tabindex=&quot;-1&quot;&gt;The Current State of Blockchain and Web3 &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-the-web/#the-current-state-of-blockchain-and-web3&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Despite its promise, blockchain and Web3 are still evolving. Challenges include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scalability&lt;/strong&gt;: Networks like Ethereum are working to handle larger transaction volumes efficiently.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Experience&lt;/strong&gt;: Web3 interfaces are often complex for everyday users.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Regulation&lt;/strong&gt;: Governments are grappling with how to regulate decentralized technologies without stifling innovation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Energy Concerns&lt;/strong&gt;: While proof-of-stake has mitigated some issues, energy usage remains a topic of debate.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the bright side, the Web3 ecosystem is thriving:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;DeFi&lt;/strong&gt; platforms manage billions in assets.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NFTs&lt;/strong&gt; are transforming art, gaming, and digital ownership.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Major players like Solana, Cosmos ecosystem, and Layer 2 solutions like Base, Optimism, Arbitrum as well as other protocols like uniswap, eigen layer, axelar and as such more are driving innovation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;where-are-we-headed%3F&quot; tabindex=&quot;-1&quot;&gt;Where Are We Headed? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-the-web/#where-are-we-headed%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The future of Web3 looks promising, with advancements in scalability, interoperability, and usability. As blockchain becomes more integrated into everyday applications, we may see:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Decentralized identity&lt;/strong&gt; systems replacing traditional login credentials.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tokenized economies&lt;/strong&gt;, where users earn from participation in digital ecosystems made popular with stable coins.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Metaverse adoption&lt;/strong&gt;, powered by blockchain-based assets and platforms.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This shift isn’t just about technology—it’s about empowering individuals, fostering creativity, and enabling more equitable economic opportunities.&lt;/p&gt;
&lt;h4 id=&quot;why-should-you-care%3F&quot; tabindex=&quot;-1&quot;&gt;Why Should You Care? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-the-web/#why-should-you-care%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Centralized systems limit freedom and control. Embracing decentralization can redefine how we interact with technology, making the digital world more equitable and open.&lt;/p&gt;
&lt;h4 id=&quot;how-do-you-start%3F&quot; tabindex=&quot;-1&quot;&gt;How Do You Start? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/decentralising-the-web/#how-do-you-start%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Learn&lt;/strong&gt;: Explore blockchain basics via platforms like Coursera, YouTube, or Web3-focused communities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Experiment&lt;/strong&gt;: Create a crypto wallet, interact with dApps, or play around with various digital tokens and cryptocurrencies.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Engage&lt;/strong&gt;: Join Web3 communities and participate in discussions on platforms like Twitter, Discord, or Reddit.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Watch for emerging trends in DeFi, NFTs, and decentralized social platforms. Look for projects that align with your values, and be part of building the decentralized future.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;As we decentralize the web, we move closer to Tim Berners-Lee’s vision of an internet that is “for everyone.” Blockchain and Web3 offer not just technological advancement but also a philosophical shift—one where power, control, and opportunity are redistributed.&lt;/p&gt;
&lt;p&gt;As Vitalik Buterin, the creator of Ethereum, aptly put it:&lt;br /&gt;
&lt;em&gt;“We don’t need to wait for some kind of future revolution; we just need to keep building piece by piece, solving problems as they come up, and eventually, we’ll get there.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	<entry>
		<title>The Perfect Flaw</title>
		<link href="https://blog.anirudha.dev/the-perfect-flaw/"/>
		<updated>2024-11-02T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/the-perfect-flaw/</id>
		<content type="html">&lt;p&gt;In a world increasingly drawn to the pursuit of perfection, the notion of embracing flaws may seem counterintuitive. Yet, these so-called “flaws” might just be what make us remarkable. This paradox is beautifully encapsulated in the concept of &lt;em&gt;The Perfect Flaw&lt;/em&gt;—the idea that imperfections are not just acceptable but also essential in defining authenticity, resilience, and growth.&lt;/p&gt;
&lt;p&gt;The concept has deep roots across cultures and philosophies. In Japan, the aesthetic of &lt;em&gt;wabi-sabi&lt;/em&gt; emphasizes beauty in imperfection, embracing the incomplete and impermanent. Similarly, &lt;em&gt;kintsugi&lt;/em&gt;, the art of repairing pottery with gold, values the cracks as part of an object’s story rather than signs of damage. Western philosophy also resonates with this notion through thinkers like Nietzsche, who argued that “what does not kill us makes us stronger,” suggesting that our struggles are pathways to greatness.&lt;/p&gt;
&lt;h3 id=&quot;the-perfect-flaw-in-creativity&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Perfect Flaw in Creativity&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-perfect-flaw/#the-perfect-flaw-in-creativity&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Creative fields thrive on imperfections, serendipity, and divergence from norms. Many of history’s most iconic works of art and literature have come from artists who defied conventions or revealed personal vulnerabilities. Van Gogh’s bold brushstrokes, Frida Kahlo’s unapologetic representation of pain, and even Hemingway’s pared-down prose reflect the beauty of embracing one’s unique vision, however unconventional.&lt;/p&gt;
&lt;p&gt;Moreover, imperfections in creativity often inspire innovation. When a “perfect” idea doesn’t work out, it is often the pivot or adaptation—the so-called flaw in the original plan—that leads to breakthrough. Think about Post-it notes, the accidental creation that revolutionized office spaces worldwide. The concept of a “flawed” adhesive became a billion-dollar idea because someone was willing to view a perceived mistake as an opportunity.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/7359f1aea31be62e39805e9fa4a1ec8f.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-perfect-flaw-in-personal-growth&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Perfect Flaw in Personal Growth&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-perfect-flaw/#the-perfect-flaw-in-personal-growth&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The journey of self-improvement often brings a focus on our weaknesses, but &lt;em&gt;The Perfect Flaw&lt;/em&gt; suggests a new way to view them. Instead of seeking to eliminate flaws, we could see them as areas of growth and character-building. Recognizing and accepting our limitations allows us to understand ourselves more fully, to navigate life with humility, and to foster empathy towards others facing similar struggles.&lt;/p&gt;
&lt;p&gt;Embracing imperfections enables resilience; when we accept failure as a natural step rather than a debilitating setback, we become less afraid to take risks. Every imperfection reveals an opportunity for self-reflection and renewal, helping us grow in ways perfectionism might stifle.&lt;/p&gt;
&lt;h3 id=&quot;the-perfect-flaw-in-technology-and-innovation&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Perfect Flaw in Technology and Innovation&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-perfect-flaw/#the-perfect-flaw-in-technology-and-innovation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Technology and design industries often emphasize precision and perfection, yet some of the most groundbreaking products have come from an acknowledgment of imperfection. Think about the evolution of software; no software version is ever perfect, and updates are constant, acknowledging the room for growth. &lt;em&gt;The Perfect Flaw&lt;/em&gt; is central to an iterative design process, where continuous improvement outpaces the unrealistic goal of a “perfect” product from the outset.&lt;/p&gt;
&lt;p&gt;In emerging fields like artificial intelligence, the beauty of imperfection is even more pronounced. A perfect algorithm would be static, inflexible, and perhaps even incapable of handling real-world variables. Embracing the unpredictability in data allows AI to adapt, improve, and learn, which is a powerful nod to &lt;em&gt;The Perfect Flaw&lt;/em&gt; in action.&lt;/p&gt;
&lt;h3 id=&quot;the-perfect-flaw-as-a-life-philosophy&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Perfect Flaw as a Life Philosophy&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-perfect-flaw/#the-perfect-flaw-as-a-life-philosophy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Adopting &lt;em&gt;The Perfect Flaw&lt;/em&gt; as a personal philosophy allows for greater freedom, self-acceptance, and joy. Instead of measuring our worth by impossible standards, we appreciate the journey and recognize that our unique imperfections add depth to our lives.&lt;/p&gt;
&lt;p&gt;By viewing flaws as integral parts of ourselves rather than defects, we gain clarity, strength, and authenticity. The journey to becoming a better version of ourselves need not imply achieving flawlessness, but rather learning, growing, and accepting who we are.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/eafb87a2f2a9ae87d272672ab9766b00.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-perfect-flaw-in-shaping-evolution&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Perfect Flaw in Shaping Evolution&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-perfect-flaw/#the-perfect-flaw-in-shaping-evolution&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Evolution thrives on variation, and those variations—often perceived as “flaws” or deviations from an ideal standard—are what enable species to adapt to changing environments. These variations are not mistakes but are, in fact, the raw material on which natural selection operates. The concept of &lt;em&gt;The Perfect Flaw&lt;/em&gt; in evolution reveals how nature embraces imperfections as a means of strengthening species across generations.&lt;/p&gt;
&lt;p&gt;For example, genetic mutations are random changes in DNA that may initially seem like flaws. While many mutations are neutral or even harmful, a select few confer advantages that help individuals survive and reproduce in specific environments. Over time, these advantageous “flaws” spread through the population, allowing it to better withstand challenges such as climate shifts, predators, or diseases. A classic example is the peppered moth in England, which developed a darker coloration during the Industrial Revolution, a mutation that allowed it to blend in with soot-covered trees and avoid predation. What was initially an oddity in coloration became a survival advantage as environmental conditions changed.&lt;/p&gt;
&lt;p&gt;Similarly, human evolution has benefited from imperfections that have shaped our unique abilities. For instance, the mutation that led to sickle-cell anemia—a condition that distorts red blood cells—provides a degree of immunity to malaria in carriers, which has proven advantageous in regions where malaria is prevalent. Here, what might seem like a genetic “flaw” actually confers resilience against a major health threat.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Perfect Flaw&lt;/em&gt; also allows for behavioral evolution. In social species, individuals who deviate from typical behavior patterns can introduce new social structures or survival strategies, ultimately benefiting the group as a whole. For instance, cooperation in wolf packs and altruistic behaviors in primates allow these groups to respond flexibly to environmental stresses, such as food scarcity or the presence of predators.&lt;/p&gt;
&lt;p&gt;At the species level, &lt;em&gt;The Perfect Flaw&lt;/em&gt; fosters biodiversity, creating ecosystems rich in variety and resilience. A perfectly homogenous species or ecosystem would be highly vulnerable to sudden environmental changes, whereas a diverse population can adapt and survive through the strength of its variations. Nature’s tolerance for imperfection is, in essence, a testament to the value of diversity as an adaptive force.&lt;/p&gt;
&lt;p&gt;In the grand scheme of life on Earth, &lt;em&gt;The Perfect Flaw&lt;/em&gt; shapes evolution by ensuring that imperfection isn’t merely tolerated but essential. The resilience of life depends on these so-called flaws—natural deviations that, far from being errors, are pathways to survival and adaptation. Thus, &lt;em&gt;The Perfect Flaw&lt;/em&gt; isn’t just a philosophical concept; it’s a fundamental principle that has governed the evolution of all life. Embracing imperfections doesn’t hinder progress; it drives it, both in nature and in ourselves.&lt;/p&gt;
&lt;p&gt;The pursuit of perfection often leaves us dissatisfied and critical of our lives, while &lt;em&gt;The Perfect Flaw&lt;/em&gt; invites us to reframe this mindset. When we see imperfection as part of the human experience, we can finally begin to live more authentically, to innovate with courage, and to form deeper connections with those around us.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;So, perhaps our most perfect qualities are not those that make us flawless, but rather those that make us real. In that raw, authentic state, we find a beauty that is not only rare but also truly irreplaceable. In embracing &lt;em&gt;The Perfect Flaw&lt;/em&gt;, we embrace ourselves.&lt;/p&gt;
&lt;/blockquote&gt;
</content>
	</entry>
	
	<entry>
		<title>Imagination: The Final Interface</title>
		<link href="https://blog.anirudha.dev/imagination-the-final-interface/"/>
		<updated>2024-10-27T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/imagination-the-final-interface/</id>
		<content type="html">&lt;p&gt;In an era where technological advances continue to break the boundaries of what once seemed like science fiction, we stand at a crossroads between the physical and the digital. The interface has always been the bridge between humans and machines—beginning with the simple command-line, evolving through graphical user interfaces (GUIs), and now, the immersive experiences of augmented reality (AR) and virtual reality (VR). Yet, despite these advancements, the ultimate interface, one that requires no intermediary hardware or software, remains within us: our imagination.&lt;/p&gt;
&lt;h3 id=&quot;the-evolution-of-human-machine-interfaces&quot; tabindex=&quot;-1&quot;&gt;The Evolution of Human-Machine Interfaces &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/imagination-the-final-interface/#the-evolution-of-human-machine-interfaces&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;From early computing, where users had to type exact commands to communicate with a machine, to today’s sophisticated touchscreens and voice commands, interfaces have become more intuitive, more human. The keyboard and mouse revolutionized user interaction, but it wasn’t until the advent of the smartphone that the notion of a device being a natural extension of the user became more pronounced.&lt;/p&gt;
&lt;p&gt;Today, we are witnessing the rise of immersive technologies. Virtual reality places users in completely fabricated worlds, while augmented reality superimposes digital information onto the physical world. These interfaces are designed to blend the real and the virtual, but even in their most advanced forms, they require physical devices—smartphones, VR headsets, or AR glasses.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/235faeb5106960ae806206932ce29bfe.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But what if the need for external devices disappeared? What if the interface became so seamless that it transcended the material world entirely?&lt;/p&gt;
&lt;h3 id=&quot;enter-imagination%3A-the-ultimate-interface&quot; tabindex=&quot;-1&quot;&gt;Enter Imagination: The Ultimate Interface &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/imagination-the-final-interface/#enter-imagination%3A-the-ultimate-interface&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Imagination has always been at the heart of human innovation. It’s the space where our thoughts, dreams, and possibilities converge. Historically, it has been the playground for writers, artists, and philosophers. However, what if our imaginations could directly shape the digital world around us, turning thoughts into action without the need for any intermediary?&lt;/p&gt;
&lt;p&gt;This concept, often explored in science fiction, is now approaching the fringes of reality. Brain-computer interfaces (BCIs) have demonstrated the potential to turn neural signals into digital commands, allowing users to control machines with their thoughts. Companies like Neuralink and Kernel are at the forefront of this movement, aiming to create a future where the human brain becomes the interface to everything digital.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/82050a085dd97463a6ea2b546521436b.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;However, the idea of imagination as the final interface goes beyond the mere translation of thoughts into commands. It envisions a future where our mental landscape becomes the canvas for creating, experiencing, and interacting with digital environments. In this world, instead of manipulating a screen or speaking commands, you simply imagine your desired outcome, and it becomes real in the digital space.&lt;/p&gt;
&lt;h3 id=&quot;potential-of-an-imagination-based-interface&quot; tabindex=&quot;-1&quot;&gt;Potential of an Imagination-Based Interface &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/imagination-the-final-interface/#potential-of-an-imagination-based-interface&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Limitless Creation&lt;/strong&gt;: With imagination as the interface, the boundaries of creation would be limitless. Artists and designers could shape digital environments as quickly as they could think, and everyday users could construct personalized virtual worlds in an instant.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Intuitive Interaction&lt;/strong&gt;: Unlike today’s devices, which require a learning curve, interacting with your own imagination would be second nature. Your thoughts would guide the experience, making it as intuitive as breathing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Accessibility for All&lt;/strong&gt;: One of the greatest challenges with current technology is accessibility. Imagination-based interfaces could level the playing field, allowing individuals with disabilities or limitations to interact with the digital world in a completely natural way.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;New Forms of Communication&lt;/strong&gt;: Language barriers would vanish. Instead of verbalizing thoughts, people could share their raw, unfiltered ideas directly through neural connections, enabling a form of communication far richer than anything words can provide.&lt;/p&gt;
&lt;h3 id=&quot;challenges-and-ethical-considerations&quot; tabindex=&quot;-1&quot;&gt;Challenges and Ethical Considerations &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/imagination-the-final-interface/#challenges-and-ethical-considerations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;While the concept of imagination as the final interface is exciting, it also presents profound challenges. The idea of linking our minds directly to digital systems opens up complex ethical questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Privacy&lt;/strong&gt;: If thoughts can be transformed into commands, how do we protect individuals from having their private thoughts accessed or exploited?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;: As with any technology, a direct neural interface would need to be protected against hacking or malicious interference. The consequences of breaching such an interface could be catastrophic.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Identity and Authenticity&lt;/strong&gt;: In a world where imagination creates reality, how do we distinguish between the physical and the imagined? How do we maintain a sense of identity when the line between what’s real and what’s not becomes so blurred?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/314b14bec5b75cf49865f7f7ab83c7bc.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;imagination-meets-reality&quot; tabindex=&quot;-1&quot;&gt;Imagination Meets Reality &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/imagination-the-final-interface/#imagination-meets-reality&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Despite the challenges, the future of an imagination-based interface isn’t just a dream—it’s a possibility that the technological world is actively exploring. With advances in neuroscience, artificial intelligence, and brain-computer interfaces, the bridge between imagination and reality is narrowing. What once belonged to the realm of fiction may soon be part of our everyday lives.&lt;/p&gt;
&lt;p&gt;At its core, imagination is where all human progress begins. It’s the engine of innovation, the source of creativity, and the final frontier in our quest to merge the digital and the real. As we look toward a future where imagination becomes the interface, we must remember that the most powerful technology we have always had has been within us all along.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The final interface may not be something we touch, see, or hear—it may be something we already possess. Imagination, untethered from the constraints of physical devices, has the potential to become the most advanced interface of all. It is here, at the intersection of thought and technology, that humanity will find its greatest frontier yet. With imagination as the guide, the possibilities for innovation, creation, and connection are truly limitless.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Of course, this needs to be studied more…&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/ab190b12419c3abbf1d6f73a5e10da2a.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Designing The Perfect Incentivised System - Part 2</title>
		<link href="https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/"/>
		<updated>2024-10-24T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/</id>
		<content type="html">&lt;p&gt;A lot of the recent rise in isekai anime also suggests a favorable wind towards perfecting our system.&lt;/p&gt;
&lt;p&gt;In the anime &lt;em&gt;Hunter x Hunter&lt;/em&gt;, the incentive system plays a crucial role in driving the narrative and character development, particularly in the context of the Hunter Exam and various arcs throughout the series.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/e86642535ce1826c72f6dfce2ebc8bc4.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h1 id=&quot;the-hunter-exam&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Hunter Exam&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-hunter-exam&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The most prominent example of an incentive system in &lt;em&gt;Hunter x Hunter&lt;/em&gt; is the Hunter Exam, which is designed to evaluate the potential of aspiring Hunters. This exam offers various incentives and motivations for participants, leading to a competitive environment.&lt;/p&gt;
&lt;h4 id=&quot;key-features%3A&quot; tabindex=&quot;-1&quot;&gt;Key Features: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#key-features%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Status and Prestige&lt;/strong&gt;: Becoming a Hunter is a prestigious achievement that grants access to exclusive resources, knowledge, and opportunities. The allure of becoming a Hunter motivates numerous characters to enter the exam, despite its dangers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/39807beb644d9f047eb27a3519dfed8a.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Diverse Challenges&lt;/strong&gt;: The exam comprises multiple stages, each presenting unique challenges that test candidates’ physical and mental abilities. The variety of tasks incentivizes different skill sets and encourages teamwork and strategy.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Elimination Format&lt;/strong&gt;: The exam’s competitive nature, where candidates are eliminated based on performance, adds a layer of urgency. This structure incentivizes candidates to perform at their best to avoid being cut from the competition.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;individual-and-team-incentives&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Individual and Team Incentives&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#individual-and-team-incentives&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Throughout the series, characters often face situations where individual goals conflict with group objectives, reflecting the dynamics of incentive systems.&lt;/p&gt;
&lt;h4 id=&quot;examples%3A&quot; tabindex=&quot;-1&quot;&gt;Examples: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#examples%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Alliances and Betrayals&lt;/strong&gt;: Characters like Gon, Killua, and Leorio form alliances to navigate challenges. However, their individual motivations can lead to conflicts, showcasing the tension between personal and collective goals.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Personal Growth&lt;/strong&gt;: The characters are often driven by personal desires—Gon’s quest to find his father, Killua’s struggle for independence from his family, and Kurapika’s desire for revenge. These individual incentives create depth in their motivations and actions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;nen-and-its-role-as-an-incentive-system&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Nen and Its Role as an Incentive System&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#nen-and-its-role-as-an-incentive-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The Nen system in &lt;em&gt;Hunter x Hunter&lt;/em&gt; serves as a complex incentive structure that rewards training, strategy, and creativity in combat.&lt;/p&gt;
&lt;h4 id=&quot;key-features%3A-1&quot; tabindex=&quot;-1&quot;&gt;Key Features: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#key-features%3A-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Personalization&lt;/strong&gt;: Nen abilities are unique to each user and are based on their personality and experiences. This personalization incentivizes Hunters to invest time and effort into mastering their abilities, as they become extensions of themselves.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Strategic Thinking&lt;/strong&gt;: The Nen system encourages strategic thinking, as users must understand their strengths and weaknesses and those of their opponents. The incentive to outsmart foes adds layers to battles, making them not just about power but also about wits.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;consequences-and-trade-offs&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Consequences and Trade-offs&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#consequences-and-trade-offs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The series also highlights the consequences of the incentive systems in place, particularly regarding the ethical implications of the Hunters’ choices.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Moral Dilemmas&lt;/strong&gt;: Characters often face moral dilemmas where the pursuit of their goals can lead to negative consequences for others. For instance, some Hunters prioritize their objectives over the well-being of others, raising questions about the ethics of their actions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sacrifices&lt;/strong&gt;: The journey of becoming a Hunter often requires personal sacrifices, be it in terms of relationships, physical well-being, or moral integrity. This reflects the trade-offs inherent in any incentive system.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-auction-and-the-underworld&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Auction and the Underworld&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-auction-and-the-underworld&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another significant incentive system is the auction and underworld dealings that occur later in the series, particularly during the Greed Island and Chimera Ant arcs.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/4bd570283a05392dc715b1489c4c0080.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h4 id=&quot;features%3A&quot; tabindex=&quot;-1&quot;&gt;Features: &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#features%3A&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scarcity and Value&lt;/strong&gt;: Rare items and information become valuable commodities in the auction system, incentivizing Hunters to participate in dangerous missions to acquire them. The allure of these items drives characters into conflict and competition. 💎&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Risk vs. Reward&lt;/strong&gt;: The underworld emphasizes the risk involved in pursuing rewards. Characters must weigh the potential gains against the dangers they face, illustrating the high stakes associated with their desires. ⚖&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;In &lt;em&gt;Hunter x Hunter&lt;/em&gt;, the various incentive systems—ranging from the Hunter Exam to the Nen system and the underworld dealings—serve to shape character motivations, drive the plot, and explore deeper themes of morality, competition, and personal growth. The complexity of these systems reflects the series’ intricate storytelling, making it a rich exploration of human desires and the consequences of pursuing them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id=&quot;tower-of-god&quot; tabindex=&quot;-1&quot;&gt;Tower of God &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#tower-of-god&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/4255d41e189d4a71c5019525b6fe3aff.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In the anime &lt;em&gt;Tower of God&lt;/em&gt;, we see the incentive system is intricately woven into the narrative and serves as a crucial mechanism for driving character motivations, conflicts, and the overall plot. The Tower itself functions as a multi-layered arena where characters face various challenges, each governed by its own set of incentives and rules.&lt;/p&gt;
&lt;h3 id=&quot;climbing-the-tower&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Climbing the Tower&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#climbing-the-tower&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;At the core of &lt;em&gt;Tower of God&lt;/em&gt; is the overarching goal of climbing the Tower, which serves as the primary incentive for many characters. The Tower promises immense power, wealth, and the chance to achieve one’s dreams at the top.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Desire for Power and Fulfillment&lt;/strong&gt;: Each character has their own motivations for climbing, ranging from personal ambition to the desire to reunite with loved ones. For example, Bam’s journey is driven by his desire to find Rachel, while other characters seek glory or revenge.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/34633b38f5c5ffa4f9502e2e94f3ce3f.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Challenges and Trials&lt;/strong&gt;: The Tower is divided into multiple floors, each presenting unique tests and challenges. Successfully overcoming these trials serves as an incentive for characters to prove their strength and skill.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-role-of-rankers&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Role of Rankers&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-role-of-rankers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Within the Tower, there are two main categories of climbers: regulars and rankers. Rankers are those who have already ascended and achieved a high status, serving as both mentors and adversaries to the regulars.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Authority and Status&lt;/strong&gt;: Rankers hold significant power and influence within the Tower, and this status serves as a major incentive for regulars to aspire to reach their level. This dynamic creates a competitive atmosphere where regulars must constantly prove themselves.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rewards and Responsibilities&lt;/strong&gt;: Rankers often receive special privileges and responsibilities, which can incentivize them to assist or manipulate regulars in their ascent. The relationships between rankers and regulars can create complex social dynamics based on competition and cooperation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/2e20731f1a03c04ebfb82b25fdb12707.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-test-and-competition-structure&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Test and Competition Structure&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-test-and-competition-structure&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The various tests within the Tower are structured to foster competition among regulars, which is a fundamental aspect of the incentive system.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Teamwork vs. Individualism&lt;/strong&gt;: Many challenges require cooperation among climbers, creating a dual incentive of working together to succeed while also competing for individual glory. This dynamic is evident in the early tests, where characters must form alliances to survive.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Elimination and Advancement&lt;/strong&gt;: The competitive nature of the tests means that failure results in elimination from the Tower, which serves as a powerful motivator. The threat of elimination encourages characters to push their limits and take risks.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/d67baa30dfeb7fc08fc6902a379adaa6.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In &lt;em&gt;Tower of God&lt;/em&gt;, the incentive system is multifaceted, shaping the motivations and actions of characters as they navigate the challenges of the Tower. The interplay between personal desires, competition, and the hierarchical structure of regulars and rankers creates a rich narrative landscape. The series delves into the complexities of ambition, sacrifice, and the human experience, making the incentive system an integral part of its storytelling.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id=&quot;solo-levelling&quot; tabindex=&quot;-1&quot;&gt;Solo Levelling &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#solo-levelling&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/5f1adb41dd6c0f8fbb953384332a7b81.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;One of my personal favorites.&lt;/em&gt; In the anime &lt;em&gt;&lt;strong&gt;Solo Leveling&lt;/strong&gt;&lt;/em&gt;, the ranking and incentive system is central to the story’s premise and character development. The world is divided into Hunters—individuals who possess supernatural abilities and engage in battles against monsters from dungeons. The ranking system not only categorizes Hunters but also serves as a key incentive mechanism, motivating characters to grow stronger and face increasingly formidable challenges. Here’s a detailed exploration of the ranking and incentive system in &lt;em&gt;Solo Leveling&lt;/em&gt;:&lt;/p&gt;
&lt;h3 id=&quot;hunter-ranks&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Hunter Ranks&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#hunter-ranks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The ranking system in &lt;em&gt;Solo Leveling&lt;/em&gt; categorizes Hunters based on their strength and abilities. The ranks are typically divided into several tiers, from the lowest to the highest:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;E-Rank&lt;/strong&gt;: The weakest category, often consisting of inexperienced Hunters with limited abilities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;D-Rank&lt;/strong&gt;: Slightly stronger than E-Rank, but still considered low-tier.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;C-Rank&lt;/strong&gt;: Competent Hunters capable of handling moderate threats.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;B-Rank&lt;/strong&gt;: Stronger Hunters who can take on more challenging dungeons.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;A-Rank&lt;/strong&gt;: Highly skilled Hunters with significant abilities and experience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;S-Rank&lt;/strong&gt;: The elite class of Hunters, known for their exceptional strength and prowess.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/5fc97165457cd818bd4bce7d0d2a3753.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This ranking system not only establishes a hierarchy among Hunters but also influences their status, opportunities, and how they are treated in society.&lt;/p&gt;
&lt;h3 id=&quot;incentives-for-levelling-up&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Incentives for Levelling Up&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#incentives-for-levelling-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The ranking system provides various incentives for Hunters to level up and improve their abilities.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Recognition and Prestige&lt;/strong&gt;: Higher-ranked Hunters gain social status and respect. The desire to be recognized as a strong and capable Hunter drives many characters to strive for improvement.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Access to Better Resources&lt;/strong&gt;: Higher ranks often translate to access to more lucrative missions and dungeons, as well as better gear and resources. This creates a tangible incentive for Hunters to train and advance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Financial Rewards&lt;/strong&gt;: Completing higher-level dungeons typically yields greater monetary rewards. As Hunters rise in rank, the potential for earning increases, motivating them to take on more challenging tasks.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Of course in this anime only our protagonist can level up.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-role-of-dungeons&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Role of Dungeons&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-role-of-dungeons&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Dungeons are critical to the ranking system, as they serve as the primary battlegrounds for Hunters. The difficulty of the dungeon often corresponds to the rank of the Hunters needed to clear it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Increased Challenge&lt;/strong&gt;: Higher-ranked dungeons require stronger Hunters, presenting a significant incentive for individuals to level up. The potential for earning greater rewards in higher-level dungeons drives Hunters to improve their skills.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Experience and Growth&lt;/strong&gt;: The process of entering dungeons allows Hunters to gain valuable experience, level up, and hone their abilities. As they face stronger monsters, they have the opportunity to prove themselves and ascend in rank.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-protagonist%E2%80%99s-journey&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Protagonist’s Journey&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#the-protagonist%E2%80%99s-journey&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The story follows Sung Jin-Woo, an E-Rank Hunter who starts at the bottom of the ranking system. After a near-fatal encounter in a double dungeon, he gains a unique ability that allows him to “level up” in a video game-like manner.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/1ab7a083948427e701858462b6413a0f.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unique Incentive Mechanism&lt;/strong&gt;: Jin-Woo’s ability to level up independently of the traditional ranking system sets him apart. This mechanic serves as a powerful incentive for his growth, as he can train and gain strength rapidly compared to his peers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Transformative Growth&lt;/strong&gt;: As he levels up, Jin-Woo transitions from being one of the weakest Hunters to an S-Rank Hunter. His journey highlights the incentives tied to perseverance, dedication, and the pursuit of power.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;social-and-psychological-factors&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Social and Psychological Factors&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#social-and-psychological-factors&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The ranking and incentive system also explores social dynamics and psychological motivations among Hunters.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Competition and Rivalry&lt;/strong&gt;: The hierarchical nature of the ranking system fosters competition among Hunters. This rivalry can lead to alliances or conflicts, as individuals strive to outperform one another.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fear of Weakness&lt;/strong&gt;: Many Hunters experience anxiety about their rank, as being labeled weak can lead to social stigma and reduced opportunities. This fear drives characters to push themselves harder and take greater risks to improve their status.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;consequences-of-the-system&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Consequences of the System&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-2/#consequences-of-the-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The ranking and incentive system in &lt;em&gt;Solo Leveling&lt;/em&gt; also has its darker aspects, revealing the pressures and challenges that come with the pursuit of power.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Moral Dilemmas&lt;/strong&gt;: Characters may face ethical choices when pursuing their goals, such as sacrificing others for personal gain or engaging in ruthless competition.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mental Strain&lt;/strong&gt;: The constant pressure to rank up and improve can lead to mental strain and burnout, as Hunters push themselves to their limits.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/9cfdcb65ce98c49be2f8c4477dbe6665.avif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The ranking and incentive system in &lt;em&gt;Solo Leveling&lt;/em&gt; serves as a vital framework for character motivations, societal dynamics, and the overarching plot. By establishing clear tiers of strength and associated rewards, the system encourages characters to grow and adapt, creating a compelling narrative of struggle and triumph. The series effectively explores themes of ambition, competition, and the costs associated with the pursuit of power, making the ranking system an integral aspect of its storytelling.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Similar scoring systems are used in multiple real life scenarios as is in anime. The limits of a limitless system is the most crucial point for the existence of any perpetual system. If we know what’s supposed to be the peak and what’s the rock bottom, we have our range to work with. But often, in society and life, the strongest keeps changing and so does our knowledge of the weakest.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/b0e07abd6772555fc5b6d5062ddc4b85.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;…to be continued.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Designing The Perfect Incentivised System - Part 1</title>
		<link href="https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/"/>
		<updated>2024-10-22T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;As I started writing this, it became apparent as to how deep the rabbit hole really is…&lt;/em&gt; 🐰&lt;/p&gt;
&lt;p&gt;So, I’m breaking up the discovery phase in multiple parts. If you’re just catching up, start at the beginning… 🏆&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Incentive systems are frameworks designed to motivate individuals or groups to achieve specific goals by offering rewards, recognition, or penalties. These systems can be implemented in various contexts, from businesses to governments, and are essential for driving behavior that aligns with desired outcomes.&lt;/p&gt;
&lt;p&gt;A well-structured incentive system does more than offer financial rewards. It considers intrinsic motivation, such as the satisfaction of achievement, recognition, or personal growth. Successful incentive systems balance short-term gains with long-term sustainability, preventing negative behaviors like gaming the system or burnout.&lt;/p&gt;
&lt;p&gt;However, designing effective incentive systems requires understanding our psychology, individual preferences, and the dynamics of the environment. Poorly designed systems can lead to unintended consequences, such as encouraging counterproductive competition or diminishing intrinsic motivation. Therefore, the challenge lies in creating incentives that inspire optimal behavior while maintaining fairness and promoting a culture of continuous improvement.&lt;/p&gt;
&lt;p&gt;Incentive systems are not one-size-fits-all. They must be adaptable, transparent, and aligned with the broader values and goals of the organization or community. When executed well, they can significantly enhance performance, engagement, and innovation. But, don’t take my word for it. Let’s take a trip through time.&lt;/p&gt;
&lt;h1 id=&quot;the-origin-story&quot; tabindex=&quot;-1&quot;&gt;The Origin Story &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#the-origin-story&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;From the earliest days, we understood that offering something desirable—like food, shelter, or status—could motivate individuals or groups to act in certain ways. These foundational ideas evolved over time, shaping how modern societies and organizations drive productivity and success.&lt;/p&gt;
&lt;p&gt;In the workplace, formal use of incentive systems became prominent during the Industrial Revolution in the 18th and 19th centuries. Factories, driven by mass production, started using financial rewards—like piece-rate pay, where workers earned money based on output—as a way to boost efficiency and productivity. This marked one of the earliest structured incentive systems in modern business.&lt;/p&gt;
&lt;p&gt;By the early 20th century, thinkers like Frederick Taylor and his “scientific management” principles influenced how organizations designed these systems. Taylor emphasized optimizing workflows and using incentives to increase output. His work laid the groundwork for performance-based rewards, which many industries adopted to motivate workers while maximizing profits.&lt;/p&gt;
&lt;p&gt;Over time, incentive systems grew beyond financial rewards. By the mid-20th century, companies began incorporating more diverse incentives, like promotions, recognition programs, and professional development opportunities, acknowledging that motivation was about more than just money.&lt;/p&gt;
&lt;p&gt;Today, incentive systems have evolved further, especially in the digital age. Companies leverage everything from flexible work arrangements to social recognition on platforms, understanding that a blend of intrinsic (personal satisfaction, purpose) and extrinsic (monetary rewards, perks) motivators is essential for driving both individual and organizational success.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;📜 The idea of using incentives goes all the way back to ancient Egypt! Pharaohs used a kind of “bonus” system to motivate workers building the pyramids. Workers were sometimes paid in beer—a valuable commodity back then—encouraging them to work harder and stay motivated during massive construction projects.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;nosedive&quot; tabindex=&quot;-1&quot;&gt;Nosedive &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#nosedive&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/ddecc14cccf3977aaec25377b29a0c5a.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In the &lt;em&gt;Black Mirror&lt;/em&gt; episode “Nosedive” (Season 3, Episode 1), the entire society operates on a highly sophisticated &lt;strong&gt;incentive system&lt;/strong&gt; based on a personal rating system that impacts nearly every aspect of people’s lives. This episode provides a dystopian commentary on how a culture driven by social ratings and approval can create incentives that influence behavior in troubling ways.&lt;/p&gt;
&lt;h3 id=&quot;social-rating-as-currency&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Social Rating as Currency&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#social-rating-as-currency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In &lt;em&gt;Nosedive&lt;/em&gt;, each person is constantly rated on a scale of 1 to 5 ⭐️ after every interaction, whether it’s a casual conversation, a service experience, or a social media post. These ratings are given and received through augmented reality (via implants and smart devices), making social validation an omnipresent and quantifiable aspect of life.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Incentive Structure&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;High Ratings = Privilege&lt;/strong&gt;: People with a high rating (closer to 5 ⭐️) have access to better services, exclusive communities, and high social status. For example, they can rent luxury apartments, book first-class flights, and attend elite social events. This creates a strong incentive for individuals to continually strive for positive ratings. ✨&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Low Ratings = Social Exclusion&lt;/strong&gt;: People with low ratings (under 3 ⭐) face social ostracism and exclusion. They are denied access to certain services, treated with disdain, and can lose their jobs, housing, or even friends. This drives a constant fear of dropping in social status. 🚩&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;behavioral-modification-through-ratings&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Behavioral Modification Through Ratings&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#behavioral-modification-through-ratings&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The rating system in &lt;em&gt;Nosedive&lt;/em&gt; creates powerful incentives for people to adjust their behavior, often in artificial or inauthentic ways. People engage in overly polite, agreeable, and upbeat interactions, constantly trying to please others to maintain or improve their ratings. Authenticity and genuine connection takes a backseat to a shroud of perfection.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Politeness and Conformity&lt;/strong&gt;: The system encourages extreme politeness and conformity because even small, everyday interactions (like ordering coffee or meeting a stranger) are rated. People aim to avoid conflict or any behavior that might offend others, leading to shallow and artificial interactions. &lt;em&gt;Do you think future meaning of AI will be Artificial Interactions?&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Social Media Performance&lt;/strong&gt;: People carefully curate their social media profiles and posts to reflect an idealized version of their lives. The system incentivizes creating a false sense of happiness and success to earn positive ratings. On some level this might even feel relatable in our current society.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;cascading-effects-of-low-ratings&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Cascading Effects of Low Ratings&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#cascading-effects-of-low-ratings&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Once someone’s rating starts to fall, the system makes it increasingly difficult for them to recover. This cascading effect mirrors the real-world phenomenon of negative feedback loops, where one small mistake leads to more severe consequences.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Instant Demotion in Social Status&lt;/strong&gt;: In the episode, the protagonist, Lacie, experiences a sudden drop in her rating after a series of negative interactions. As her rating falls, people begin treating her worse, and even minor slip-ups lead to further ratings hits.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Punitive Measures&lt;/strong&gt;: At one point, Lacie is punished for a public outburst by having her rating severely downgraded, making it even harder for her to participate in society. This punishment creates fear among others, incentivizing them to be even more cautious about their behavior.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;economic-and-social-mobility-tied-to-ratings&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Economic and Social Mobility Tied to Ratings&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#economic-and-social-mobility-tied-to-ratings&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The social rating system directly influences economic and social mobility. People with high ratings enjoy better career opportunities, housing, and access to resources, while those with lower ratings are marginalized and often trapped in poverty or undesirable circumstances.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;💼 &lt;strong&gt;Job Opportunities&lt;/strong&gt;: Many jobs in the &lt;em&gt;Nosedive&lt;/em&gt; universe require a minimum rating. For example, Lacie’s dream is to move into an upscale apartment complex, but she needs a rating of 4.5 or higher to qualify for a discount. This incentivizes her to engage in strategic social interactions and build relationships with high-status individuals to boost her rating.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;🏘 &lt;strong&gt;Housing &amp;amp; Services&lt;/strong&gt;: Access to certain housing, transportation, and even healthcare services is based on one’s rating. People with lower ratings find themselves excluded from basic services, motivating them to constantly improve their scores to regain access.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-incentive-trap&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;The Incentive Trap&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#the-incentive-trap&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;While the system is designed to incentivize “good” behavior and social harmony, it ends up encouraging manipulation, superficiality, and emotional suppression. Instead of fostering genuine connections, it pushes people to prioritize their public image over authentic relationships.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Inauthenticity&lt;/strong&gt;: People are incentivized to present an idealized version of themselves, even at the cost of their own well-being. Lacie, for example, suppresses her emotions and thoughts to appear perfect, but this leads to a breakdown when her façade starts to crack.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Social Pressure&lt;/strong&gt;: The constant pressure to perform for others creates a toxic social environment where people are judged solely by their ratings, rather than by their character or contributions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;systemic-breakdown-%26-personal-collapse&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Systemic Breakdown &amp;amp; Personal Collapse&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#systemic-breakdown-%26-personal-collapse&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In the end, the incentive system in &lt;em&gt;Nosedive&lt;/em&gt; proves unsustainable. Lacie’s obsession with improving her rating leads to her mental and emotional unraveling. She spirals into desperation, and her inability to conform to the social norms results in her exile from the high-status world she aspired to join.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;🏃🏻‍♂️ Escape from the System&lt;/strong&gt;&lt;/em&gt;*.* Ironically, Lacie finds freedom after her rating drops to zero and she’s imprisoned. In a critical moment, she exchanges insults and genuine emotions with another prisoner, highlighting that, outside the rating system, people can express themselves freely and honestly without the pressure of constant judgment.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The incentive system in &lt;em&gt;Black Mirror’s&lt;/em&gt; &lt;em&gt;Nosedive&lt;/em&gt; illustrates how an over-reliance on ratings, approval, and superficial metrics can distort our behavior and relationships. While it rewards politeness, success, and conformity, it also suppresses individuality, authenticity, and emotional expression. The episode serves as a cautionary tale about how unchecked incentive systems, driven by external validation, can lead to societal and personal dysfunction.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id=&quot;game-theory&quot; tabindex=&quot;-1&quot;&gt;Game Theory &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#game-theory&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/d4e6e283facf03e0a937ce8da978cbec.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Game theory is the study of strategic interactions between individuals or groups where the outcome for each participant depends not only on their own actions but also on the actions of others. Developed in the mid-20th century by mathematician John von Neumann and economist Oskar Morgenstern, game theory has since become a crucial tool in economics, politics, psychology, and even biology.&lt;/p&gt;
&lt;p&gt;🧩 At its core, game theory seeks to understand how rational players make decisions in situations of conflict or cooperation. A key concept is the &lt;strong&gt;Nash equilibrium&lt;/strong&gt;, introduced by John Nash, where no player has an incentive to change their strategy given what others are doing. Other famous models include the &lt;strong&gt;Prisoner’s Dilemma&lt;/strong&gt;, where two players may not cooperate even if it’s in their best interest, and &lt;strong&gt;Zero-Sum Games&lt;/strong&gt;, where one player’s gain is another’s loss.&lt;/p&gt;
&lt;p&gt;Game theory helps explain real-world scenarios like negotiations, business competition, public policy, and even social behaviors, offering insights into how people can optimize decisions in complex environments. Game theory provides valuable insights for designing effective incentive systems by analyzing strategic interactions among individuals or groups. When creating an incentive system, it’s crucial to understand how participants will respond to various incentives and the potential outcomes of their choices.&lt;/p&gt;
&lt;h3 id=&quot;understanding-strategic-interactions&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Understanding Strategic Interactions&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#understanding-strategic-interactions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Incentive systems often involve multiple stakeholders whose decisions affect one another. Game theory helps predict how individuals will behave in response to different incentives. By modeling these interactions, designers can anticipate possible outcomes and create systems that encourage desired behaviors.&lt;/p&gt;
&lt;h3 id=&quot;identifying-nash-equilibria&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Identifying Nash Equilibria&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#identifying-nash-equilibria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The concept of &lt;strong&gt;Nash equilibrium&lt;/strong&gt; is pivotal in understanding how individuals may settle into stable strategies where no one has an incentive to change their behavior unilaterally. In designing an incentive system, identifying potential Nash equilibria can help ensure that the chosen incentives promote cooperative behavior rather than competitive or counterproductive actions.&lt;/p&gt;
&lt;p&gt;For example, in a workplace scenario, if an incentive system rewards individual performance without considering team dynamics, employees may prioritize personal gains over collaborative efforts. Game theory can help designers find equilibrium strategies that foster both individual and collective performance.&lt;/p&gt;
&lt;h3 id=&quot;addressing-the-prisoner%E2%80%99s-dilemma&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Addressing the Prisoner’s Dilemma&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#addressing-the-prisoner%E2%80%99s-dilemma&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;Prisoner’s Dilemma&lt;/strong&gt; illustrates how rational individuals may not cooperate, even when it’s in their best interest. This dilemma often arises in incentive systems, especially when individual rewards conflict with group goals.&lt;/p&gt;
&lt;p&gt;By understanding this dynamic, designers can create incentive structures that encourage collaboration. For instance, implementing team-based bonuses alongside individual rewards can mitigate the risk of individuals acting solely in their self-interest.&lt;/p&gt;
&lt;h3 id=&quot;incentives-and-information-asymmetry&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Incentives and Information Asymmetry&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#incentives-and-information-asymmetry&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Game theory also addresses situations where players have different levels of information, leading to &lt;strong&gt;information asymmetry&lt;/strong&gt;. In incentive systems, this can manifest when one party knows more about the task or effort than the other, leading to mistrust or exploitation.&lt;/p&gt;
&lt;p&gt;Designers can counteract these issues by ensuring transparency and communication within the incentive system. For example, implementing performance metrics that are visible to all stakeholders can help align interests and build trust, reducing the chances of opportunistic behavior.&lt;/p&gt;
&lt;h3 id=&quot;feedback-loops-and-dynamic-strategies&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Feedback Loops and Dynamic Strategies&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#feedback-loops-and-dynamic-strategies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Incentive systems often operate in dynamic environments where strategies may evolve over time. Game theory helps analyze feedback loops in these systems, allowing designers to understand how participants’ strategies may change in response to the incentives offered.&lt;/p&gt;
&lt;p&gt;By considering potential shifts in behavior, designers can create flexible incentive structures that adapt over time, ensuring they remain effective as circumstances change. For example, introducing periodic reviews or adjusting rewards based on changing goals can maintain participant engagement and motivation.&lt;/p&gt;
&lt;h3 id=&quot;balancing-short-term-and-long-term-goals&quot; tabindex=&quot;-1&quot;&gt;&lt;strong&gt;Balancing Short-Term and Long-Term Goals&lt;/strong&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/designing-the-perfect-incentivised-system-part-1/#balancing-short-term-and-long-term-goals&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Game theory can guide the design of incentive systems that balance short-term and long-term objectives. Participants may focus on immediate rewards at the expense of future benefits, leading to suboptimal outcomes.&lt;/p&gt;
&lt;p&gt;Designers can use game-theoretic principles to create incentives that align short-term actions with long-term goals. For example, structuring bonuses to include both immediate rewards and deferred compensation can encourage sustained effort and commitment to the organization’s vision.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Incorporating game theory into the design of incentive systems provides a robust framework for understanding the strategic interactions of participants. By analyzing these dynamics, designers can create more effective and equitable systems that promote cooperation, align individual and group interests, and ultimately drive desired behaviors. The insights from game theory enable organizations to navigate the complexities of our behavior and foster environments where everyone can thrive.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;…to be continued.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://storage.googleapis.com/papyrus_images/52a5874988206403bfe3dd25a8e184b9.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Reentrancy Attack</title>
		<link href="https://blog.anirudha.dev/reentrancy-attack/"/>
		<updated>2024-07-22T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/reentrancy-attack/</id>
		<content type="html">&lt;p&gt;&lt;strong&gt;Reentrancy attacks&lt;/strong&gt; are one of the common security issues that can occur in Solidity smart contracts. They exploit the fact that &lt;strong&gt;a function can be called multiple times before it finishes execution&lt;/strong&gt;.&lt;br /&gt;
&lt;em&gt;When a contract A calls a function in contract B, contract B can call back into contract A while it is still running. If contract A has not finished executing and is still holding state, contract B can potentially manipulate that state to gain an unfair advantage.&lt;/em&gt;&lt;br /&gt;
This can lead to various issues such as fund loss, unauthorized access, or even complete contract failure.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://media.geeksforgeeks.org/wp-content/uploads/20230130125653/Redesign-blockchain-1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The most famous reentrancy attack occurred in 2016, resulting in the loss of 3.6 million Ether and leading to the Ethereum hard fork, creating Ethereum (ETH) and Ethereum Classic (ETC) also known as, &lt;strong&gt;The DAO Hack&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;WETH Attack: First ever reentrancy attack was &lt;a href=&quot;https://www.reddit.com/r/ethereum/comments/4nmohu/from_the_maker_dao_slack_today_we_discovered_a/?user_id=360657100019&quot;&gt;reported&lt;/a&gt; on Maker DAO Slack. It can tracked on &lt;a href=&quot;https://github.com/pcaversaccio/reentrancy-attacks/issues/1&quot;&gt;github issue&lt;/a&gt;. It was an intentional one and &lt;a href=&quot;https://github.com/blockchainsllc/DAO/pull/242&quot;&gt;a patch&lt;/a&gt; was later merged about it. You can find more details in &lt;a href=&quot;https://web.archive.org/web/20170615055530/http://vessenes.com/more-ethereum-attacks-race-to-empty-is-the-real-deal/&quot;&gt;web archive&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Just in 2021 and 2022 alone, more than a dozen attacks has happened around this. &lt;a href=&quot;https://nipunp.medium.com/5-8-21-rari-capital-exploit-timeline-analysis-8beda31cbc1a&quot;&gt;Rari Capital Expoit&lt;/a&gt;, &lt;a href=&quot;https://inspexco.medium.com/reentrancy-attack-on-cream-finance-incident-analysis-1c629686b6f5&quot;&gt;Cream Finance&lt;/a&gt;, &lt;a href=&quot;https://certik.medium.com/fei-protocol-incident-analysis-8527440696cc&quot;&gt;Fei Protocol&lt;/a&gt;, &lt;a href=&quot;https://www.coindesk.com/tech/2022/03/31/ola-finance-exploited-for-36m-in-re-entrancy-attack/&quot;&gt;Ola Finance&lt;/a&gt;, &lt;a href=&quot;https://blocksecteam.medium.com/when-safemint-becomes-unsafe-lessons-from-the-hypebears-security-incident-2965209bda2a&quot;&gt;Hyperbears&lt;/a&gt;. &lt;a href=&quot;https://x.com/BlockSecTeam/status/1546141457933025280&quot;&gt;BurgerSwap&lt;/a&gt;, &lt;a href=&quot;https://therecord.media/2-million-stolen-from-defi-protocol-revest-finance-platform-unable-to-reimburse-victims&quot;&gt;Revest Finance&lt;/a&gt;, &lt;a href=&quot;https://polydex.medium.com/plx-locker-smart-contract-incident-post-mortem-75342124a3e8&quot;&gt;PolyDex&lt;/a&gt;, and so on…&lt;/p&gt;
&lt;h3 id=&quot;how-does-it-work&quot; tabindex=&quot;-1&quot;&gt;How does it Work &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/reentrancy-attack/#how-does-it-work&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In a typical reentrancy attack, an attacker exploits the way Ethereum handles external calls and the sequence in which state changes and value transfers are performed. Here’s a simplified flow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Attack Contract Initiation&lt;/strong&gt;: The attacker deploys a malicious contract.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Initial Call&lt;/strong&gt;: The attacker triggers a function in the vulnerable contract that sends Ether to the attacker’s contract.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fallback Function&lt;/strong&gt;: The attacker’s contract contains a fallback function that calls the vulnerable contract again before the first function call finishes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Repeated Calls&lt;/strong&gt;: The process repeats, allowing the attacker to drain funds from the vulnerable contract.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;example-of-a-vulnerable-contract&quot; tabindex=&quot;-1&quot;&gt;Example of a Vulnerable Contract &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/reentrancy-attack/#example-of-a-vulnerable-contract&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Here’s a basic example of a vulnerable Solidity contract:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;VulnerableContract&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; balances&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;deposit&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt; sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;call&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Failed to send Ether&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;In this contract, the &lt;code&gt;withdraw&lt;/code&gt; function updates the user’s balance after sending Ether. This sequence creates a window for a reentrancy attack.&lt;/p&gt;
&lt;h3 id=&quot;exploiting-the-vulnerability&quot; tabindex=&quot;-1&quot;&gt;Exploiting the Vulnerability &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/reentrancy-attack/#exploiting-the-vulnerability&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The attacker’s contract might look like this:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;pragma&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;solidity&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;token version number&quot;&gt;0.8.0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./VulnerableContract.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;AttackContract&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    VulnerableContract &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; vulnerableContract&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _vulnerableContractAddress&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        vulnerableContract &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;VulnerableContract&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_vulnerableContractAddress&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;fallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;vulnerableContract&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;balance &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            vulnerableContract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;attack&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        vulnerableContract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;deposit&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        vulnerableContract&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; ether&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;h3 id=&quot;how-to-avoid-reentrancy-attacks&quot; tabindex=&quot;-1&quot;&gt;How to Avoid Reentrancy Attacks &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/reentrancy-attack/#how-to-avoid-reentrancy-attacks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check-Effects-Interactions Pattern&lt;/strong&gt;: Ensure all internal state changes occur before external calls. This pattern involves three steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Checks&lt;/strong&gt;: Validate conditions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Effects&lt;/strong&gt;: Update internal state.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interactions&lt;/strong&gt;: Make external calls.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt; sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;call&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Failed to send Ether&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reentrancy Guards&lt;/strong&gt;: Use the &lt;code&gt;nonReentrant&lt;/code&gt; modifier from OpenZeppelin’s ReentrancyGuard contract to prevent reentrant calls.&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/security/ReentrancyGuard.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SecureContract&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; ReentrancyGuard &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; balances&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; nonReentrant &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;bool&lt;/span&gt; sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;call&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sent&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Failed to send Ether&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Avoid&lt;/strong&gt; &lt;code&gt;call&lt;/code&gt; Method: Prefer using &lt;code&gt;transfer&lt;/code&gt; and &lt;code&gt;send&lt;/code&gt; methods, which have a fixed gas limit and prevent reentrancy attacks. However, be aware of gas limit changes in &lt;a href=&quot;https://eips.ethereum.org/EIPS/eip-1884&quot;&gt;EIP-1884&lt;/a&gt;.&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;withdraw&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    balances&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-=&lt;/span&gt; _amount&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;payable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;transfer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;best-practices&quot; tabindex=&quot;-1&quot;&gt;Best Practices &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/reentrancy-attack/#best-practices&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Audit Regularly&lt;/strong&gt;: Regularly audit smart contracts to identify and mitigate vulnerabilities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Established Libraries&lt;/strong&gt;: Utilize well-known libraries and packages like OpenZeppelin for security functions.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test Thoroughly&lt;/strong&gt;: Conduct extensive testing, including unit tests and fuzz testing, to uncover potential weaknesses.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Limit External Calls&lt;/strong&gt;: Minimize the number of external calls in your contract, especially those involving value transfers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;:)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>On-Chain Shared State</title>
		<link href="https://blog.anirudha.dev/on-chain-shared-state/"/>
		<updated>2024-04-26T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/on-chain-shared-state/</id>
		<content type="html">&lt;p&gt;Communication is a key in any ecosystem. Now with more cross-chain communication getting sorted using bridges, it’s high time to sort on-chain communications as well. Particularly, referencing of composable smart contract functionalities within the same chain.&lt;/p&gt;
&lt;h1 id=&quot;on-chain-immutability&quot; tabindex=&quot;-1&quot;&gt;On-Chain Immutability &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/on-chain-shared-state/#on-chain-immutability&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Blockchains in general are isolated networks. Smart contracts are even further isolated in the network given that they record data that are immutable. Any update to their state records a new transaction cumulatively records the updated state. This is known and also creates a historical trail for later review and audit. There’s no problem is this process expect it’s not possible to update the smart contract code itself.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I’ve always believe learning by example is best.&lt;/em&gt; Let’s take a look at the usage of &lt;code&gt;ownerOf&lt;/code&gt; from &lt;code&gt;IERC721&lt;/code&gt; interface and how it’s used to check token ownership for any NFT.&lt;/p&gt;
&lt;p&gt;First we import via openzepplin package or you can write your own packaged contract &lt;code&gt;import &amp;quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&amp;quot;&lt;/code&gt; . Or if you really want to write your own &lt;code&gt;ERC721&lt;/code&gt; contract, start with importing the interface &lt;code&gt;IERC721&lt;/code&gt; to your contract: &lt;code&gt;import &amp;quot;./IERC721.sol&amp;quot;&lt;/code&gt; .&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;IERC721.sol&lt;/code&gt; contains the function definition:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; owner&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;And in &lt;code&gt;ERC721.sol&lt;/code&gt; you can find the first override for it as such:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; virtual override &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; owner &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;owner &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERC721: invalid token ID&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; owner&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;The function in itself is pretty straightforward. It takes &lt;code&gt;tokenId&lt;/code&gt; as input and returns the owner address.&lt;/p&gt;
&lt;p&gt;To understand this further, it’s all stored in a mapping:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; _owners&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Anyway, regardless of the implementation, this is industry standard at the moment. If in case you’d want to add some conditions or enhance this function in your own contract, you’d need to override this further.&lt;/p&gt;
&lt;h2 id=&quot;overriden&quot; tabindex=&quot;-1&quot;&gt;Overriden &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/on-chain-shared-state/#overriden&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Say we want to check for temporary ownership, like a rental ownership, which is time bound. We can not edit the original mapping of course. There’s 2 ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;We add a separate mapping only for the mapping of &lt;code&gt;tokenId&lt;/code&gt; and &lt;code&gt;owner&lt;/code&gt; to a &lt;code&gt;timestamp&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We ignore &lt;code&gt;_owners&lt;/code&gt; mapping and write our own mapping replacing it. We’ll go with this option cause adding and reading from multiple memory storages will be costlier than having a rogue mapping lying around.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s call our new mapping as &lt;code&gt;_ownership&lt;/code&gt;:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Owner&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;br /&gt;   &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; account&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; expiry&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; Owner&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; _ownership&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now, we can map the ownership in this accordingly. But we also need to override our &lt;code&gt;ownerOf&lt;/code&gt; function:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ownerOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;view&lt;/span&gt; virtual override &lt;span class=&quot;token keyword&quot;&gt;returns&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; expiry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        Owner _owner &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_ownership&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_owner&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;account &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ERC721: invalid token ID&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_owner&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;expiry &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;timestamp&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Ownership Expired. No current owner found.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; _owner&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;account&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Here, we’re doing a few things. First, we’re checking if the owner account exists and expiry is anytime beyond current block timestamp.&lt;/p&gt;
&lt;p&gt;Great, now our existing function &lt;code&gt;ownerOf&lt;/code&gt; can serve as the modified version of the existing owner check. So, all the clients can now call this new function of contract and get timestamp enabled ownership check.&lt;/p&gt;
&lt;p&gt;However, here’s where things get interesting…&lt;/p&gt;
&lt;h1 id=&quot;imported-smart-contracts&quot; tabindex=&quot;-1&quot;&gt;Imported Smart Contracts &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/on-chain-shared-state/#imported-smart-contracts&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The problem in above way is that we would need to burn all tokens from old smart contract and re-mint in new one in order for them to enable &lt;code&gt;expiry&lt;/code&gt; in ownership. Which would lead to losing all history of the said tokens. So, how do we deal with this?&lt;/p&gt;
&lt;p&gt;Solidity supports importing another smart contract and referring to the functions of it as we established above. We usually use it to extend functionality. For example, we want to add a function to our previous contract which checks &lt;code&gt;ownerOf&lt;/code&gt; and rewards a certain amount to them. So, we first need to define it:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@openzeppelin/contracts/token/ERC20/IERC20.sol&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// other code bits&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;IERC20 token&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;token &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;IERC20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;token_address&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now, in above, &lt;code&gt;token&lt;/code&gt; represents our token from previous contract which is imported based on &lt;code&gt;token_address&lt;/code&gt;. So, we should be able to do something like &lt;code&gt;token.ownerOf(tokenId)&lt;/code&gt; to get the owner of &lt;code&gt;tokenId&lt;/code&gt; as shown above. Once we get it, let’s say we want to do something like &lt;code&gt;owner_address.send(value)&lt;/code&gt; where value is in base token of the chain. This is the most commonly used way to use an external contract. But what would happen if you’re to extend an existing function of original contract?&lt;/p&gt;
&lt;p&gt;Let’s take our previous example. We want to add &lt;code&gt;expiry&lt;/code&gt; to &lt;code&gt;ownerOf&lt;/code&gt;. So, we write a new smart contract and a new function to check ownership. Cause we can’t override a function of a different contract. We’ve a new function which can have same name even. But for the sake of sanity, let’s use a different name, &lt;code&gt;newOwner()&lt;/code&gt; and it looks something like:&lt;/p&gt;
&lt;code-block lang=&quot;solidity&quot;&gt;&lt;pre class=&quot;language-solidity&quot;&gt;&lt;code class=&quot;language-solidity&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;contract&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;RentContract&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Owner&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;br /&gt;       &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; account&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; expiry&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;mapping&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; Owner&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;private&lt;/span&gt; _ownership&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;newOwner&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; tokenId&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;address&lt;/span&gt; _to&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;uint256&lt;/span&gt; _expiry&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;external&lt;/span&gt; virtual &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        _ownership&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;account &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _to&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        _ownership&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;tokenId&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;expiry &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _expiry&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;So, what’s happening here is overloading (&lt;em&gt;not really since we’re using a different name for the function. But from a standard perspective, let’s assume it’s the same&lt;/em&gt;) which means we’ve defined a second function and mapping to do the exact same thing which is already been done in previous contract where it’s been imported from. This obviously is a waste of memory on-chain but let’s leave that concern for later. So, now, we’ve a second contract, &lt;code&gt;RentContract&lt;/code&gt; which has temporary ownership function which we can use. However, what about the client apps which is already pointed to the old contract? The token ownership does not show any changes regardless to whoever else it’s rented out via the &lt;code&gt;RentContract&lt;/code&gt; .&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/a3be6cb7-aa15-476d-8a38-ae3f0221cc0b.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h1 id=&quot;shared-state&quot; tabindex=&quot;-1&quot;&gt;Shared State &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/on-chain-shared-state/#shared-state&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Here’s where the concept of Shared State comes in. Here’s to proposing a shared state system which allows to update the state of original contract if the same state is being dealt with on an extended contract.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/bffb53f4-4995-4805-8594-7ba7ef188782.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, once this new system is in place, we should be able to reflect the updated state back to our original state thereby retaining backwards compatibility as well as history.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/ed02d225-3be2-4736-8cf2-03d45f839c88.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This is the next evolution in smart contract standards which will help with better backwards compatible DApps and protocols.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;LFG&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>CyberSpace</title>
		<link href="https://blog.anirudha.dev/cyberspace/"/>
		<updated>2023-12-31T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/cyberspace/</id>
		<content type="html">&lt;p&gt;&lt;em&gt;A world forgotten&lt;br /&gt;
Another awoken&lt;br /&gt;
Some lost&lt;br /&gt;
Some regained&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Doesn’t it feel suffocating at times? Like your life isn’t your own anymore. Like everything you’re doing or about to do is pre-determined. Like you’ve already lost before you began.&lt;/p&gt;
&lt;p&gt;It’s impossible to make a choice and call it really a choice. Society has decided your past, present, and future. The only way to break free is to dream.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;I have a dream” – Martin Luther King&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Freedom doesn’t just have a physical form, but also a mental form. It’s increasingly important to not notice the extent to which the web of media and the internet has bound us to not be able to breathe without an ad popping up offering you a vacation package to clean air. It’s followed by a series of flight ads which specially shows the food you like and the beverage you love. If somehow it detects an inch of interest, you start getting spammed with holiday clothes and even things to do, of course heavily curated to your taste. It’s all great for you. You don’t even have to sit scrolling through search results or ask people around for such things. They already know. Convenience is the new chain to which we’re all bound in by.&lt;/p&gt;
&lt;p&gt;Ownership is of course important. But more than that, the creator within you is crying. Crying for not being able to build, do, go what, how and where you want to. Imagine a future version of the world, without any and all mundane tasks around. You just do the most needed work only. Everything else is done by something, someone, somewhere. You don’t care the how, what, or where, till your tasks are been taken care of. So, let’s imagine a future version of the web, that satisfies the above and more, and we call it The CyberSpace.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/020e4091-9071-4746-b9c5-48f866372c86.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;CyberSpace is a trans-digital world built, governed, and maintained by the collective intelligence of its residents. It’s a space where everything is based on the rules you set. Loosely based on optimistic theory, CyberSpace is what you make of it. It’s not a new world or a virtual world like MetaVerse. CyberSpace is a space where your creations can take shape, form, and act according to how they are programmed.&lt;/p&gt;
&lt;p&gt;Not too different from our current world. We live in a universe governed by certain rules as well. So, what’s different? The difference is consciousness. The way we model CyberSpace is upto us.&lt;/p&gt;
&lt;p&gt;So, the Mission as it were to build towards such a Utopia. Together. I’m starting this as a mission for everything that I’ll work on now on and till I see it come to reality.&lt;br /&gt;
If you want to join me on my journey, reach out to me on &lt;a href=&quot;https://twitter.com/kranirudha&quot;&gt;twitter&lt;/a&gt; or &lt;a href=&quot;https://fosstodon.org/@anirudha&quot;&gt;mastodon&lt;/a&gt;. Let’s build and live in The CyberSpace.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Building a New World</title>
		<link href="https://blog.anirudha.dev/building-a-new-world/"/>
		<updated>2022-06-05T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/building-a-new-world/</id>
		<content type="html">&lt;p&gt;When we think about building anything, the first thought is about the past builders, whichever industry, domain, or land you’re coming from. From the Roman Colosseum, Great Wall of China, and Taj Mahal of India to building Wikipedia, Reddit, and Google of today, we look up to the past great builders and wonder what it’d take to even come close to what they’ve accomplished. Thinking about building a new World altogether sounds even more daunting. Specially, if you think about who, how, what, and so on the million other questions. In this article, we’ll start by trying to figure out what and why and the how. Of course, it’s not going to be completely covered in one article alone. But, it can be a start.&lt;/p&gt;
&lt;h1 id=&quot;introduction&quot; tabindex=&quot;-1&quot;&gt;Introduction &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-new-world/#introduction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;When we think about the end goal, it doesn’t really look a lot different from our current world. With the only differences being in the WHY of our endeavor. What do we want to be different from this world? The negativity, corruption, stealing, terrorism, war are some of the things that comes to mind. We don’t want them in our new world. but how do we get rid of them? That’s in the innate nature of any living being. Left alone in an environment of utter desperation, anybody would succumb to an inch of negativity leading to any number of things from there. How do we remove all need for desperation? Is that even the real answer? Perhaps not. but let’s start there.
I love looking into the past to come on to face the future. Let’s think of what the animal kingdom looks like. There are enough natural resources for everyone to feed on. Someone at some point caught off by feeding on another species and thus came to start the very early carnivores. But even so, there’s enough for all the animals to form a healthy thriving ecosystem or the Circle of Life.
We often put all the demise of this planet to early humans who started capturing lands and fighting with each other to polluting the very land. Of course, that’s a different topic, but it does bring forth an important question. How do we prevent that in our new world?
The answer to me seems either too simple or I’m way off mark. Let’s see where we end up. We know in our heart what’s right. That might not be what others think, but we do believe in something. More often we end up agreeing with others than disagreeing. The smallest number of times we’ve disagreed, it turns out to be a good tussle of learning something new.&lt;/p&gt;
&lt;h1 id=&quot;collective-thinking&quot; tabindex=&quot;-1&quot;&gt;Collective Thinking &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-new-world/#collective-thinking&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;An interesting experiment done was on the collective thinking of the masses. We usually do not want to put faith in others, specially in the crowd, and for good reasons. but a lot of times it’s just because we can’t trust them. We fear that it’d be almost impossible to make anybody make see the way into your mind, your thought process, your likes, and dislikes and have them take a call on what’s done or to be done be right or wrong. Yes, I’m talking about a legal Jury here. Of course, you’ve all been either seeing or are acquainted with any number of Law related TV series or Movies thereby, if not the real ones, more so lately.
An interesting experiment would be that the collective thinking of random strangers can somehow be almost always very right. There are obvious exceptions, but almost always they all point toward what’s right. How does that happen? Very curious indeed. Of course, you need to present them with all the facts to make a sound judgment. Make them see your way into the void and let them come back into the same tunnel that you once emerged out of. If they do, you were right. If they don’t, perhaps you’ve deviated. It’s an interesting theory to test of what’s already passed. But what if we extend this mysterious power of consensus towards what’s about to happen. Let’s ask who everybody the same question and see what they all come up with. On the outside, it might seem like a very random experiment. Too open. Too many answers. Too many possibilities. Too much chaos. But once the dust settles, we’ll find there’s at least 1 answer that more than 1 person has come up with. Very curious!!&lt;/p&gt;
&lt;h2 id=&quot;a-big-brain&quot; tabindex=&quot;-1&quot;&gt;A Big Brain &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/building-a-new-world/#a-big-brain&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Collective thinking doesn’t mean that we need to connect everyone’s brains with wires and they operate like a big brain. It means that the decisions taken by one can or has to be reciprocated by others to a point of executing it. The decision-making process can be time or resource intensive based on what the impact of it’s will be like. So, each consensus can be varied based upon the collective decision-making prowess of the society in its entirety.
This algorithm need not be perfect from the very beginning, but it needs to be ever-evolving according to the need of society and what’s on priority at the moment. Like evolving data, we need our decisions to evolve as well. A great example is music. 300 years earlier, give or take, pretty much everyone were just gasping over Bach and Mozart, amongst the other greats. 50 years earlier, it was the Bettles and Stones and Led Zep to capture all imagination. 20 years earlier, MJ, Nirvana and Chris Cornel and Pearl Jam. Today, it’s someone else. The music as a taste has changed. If you’re from any of the above generations, you’d relate to this. You might not understand of like at all the electronic music of today. Always finding some excuse to go back listening to some classic rock. Of course, if you’re from Mozart era and still alive, I’d be more curious to meet you even with a scared outlook of having my blood or brain dried out. (Just kidding) But of course, you get the idea.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Any governing algorithm needs to be ever evolving.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And that I believe is the first step towards building our new world…&lt;/p&gt;
&lt;p&gt;Stay tuned for more…&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>NFTs in Metaverse</title>
		<link href="https://blog.anirudha.dev/nfts-in-metaverse/"/>
		<updated>2022-04-17T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/nfts-in-metaverse/</id>
		<content type="html">&lt;p&gt;We love NFTs. It’s pretty cool. But we need to look forward to the next step in the evolution of such artefacts. Fine, I’ve a cap NFT or a car NFT. So what? What do I do next with it?&lt;/p&gt;
&lt;p&gt;The answer really is just staring at our face. METAVERSE. Not in the sense Facebook wants you to see it. But in a more useful way, the one image drawn from the OG, Neal Stephenson in his book from 1992, Snow Crash.&lt;/p&gt;
&lt;p&gt;A world open for everybody to create, build, run with no central authority. Nobody controlling you or pushing you to do one thing or the other. True freedom indeed! Must be nice. Feel like a pirate, aye? If you’re reading this by mid 2022, you are in fact well ahead of most of the human race in working on towards a true Metaverse. Let’s start with what we’ve right now and then slowly move towards how it’s going to impact our world and our Metaverse.&lt;/p&gt;
&lt;p&gt;NFTs are non-fungible tokens which are usually tied to some asset, such as an art piece, a user profile, an avatar or a prize. What’s common amongst all of these are that the NFTs are almost always uniquely represented in a single point of truth universal network. Which means, my NFT can NOT be same as yours. I know you’re at this point thinking of 1155s. But even so, they’re collectively representing something unique. We can hold a handful of sand and start separating out the grains or just put them in a bag, and tag them as unique. Coming back to the topic, if we’ve a unique hat as an NFT, then my NFT hat would be very different from yours. I can add some feather on the top or color it white or even tilt it a little to make it as unique as possible. Cause the more rare something is, the more valuable it gets, right? Similarly with any other object, such shirt, tee, trousers, gloves, shoes, and so on…&lt;/p&gt;
&lt;p&gt;So, let’s say now, each of us has a unique-looking shoe. We can put these to some use as well. Let’s say I add a condition that each time you enter my store in the Metaverse, your shoe will get cleaned if you buy something from my store. By clean, any previous data diluting its value will be deleted or overridden in some way, since the data we’re working with is pretty much immutable. That’d be pretty cool for you to come purchase a cheesecake from my bakery. Ah, you also get some health tokens for it. Which later you can exchange at the hospital for some avatar upgradation.&lt;/p&gt;
&lt;p&gt;I think you get the general idea of it. Every activity has an equally incentivized criteria to it. Compelling every user to participate and work for it. It’s what’s building the proof of work within our digital paradigm.&lt;/p&gt;
&lt;p&gt;I’ll be working next on building such a world, a truly free world. If you’re interested in building together, get in touch with me. Help me help us get there…&lt;/p&gt;
&lt;p&gt;Until next time…&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>What is NFT?</title>
		<link href="https://blog.anirudha.dev/what-is-nft/"/>
		<updated>2021-09-27T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/what-is-nft/</id>
		<content type="html">&lt;p&gt;NFT or Non-Fungible Token, is the latest in the long line of jargon that you might be hearing a lot about recently. So, why should you care and what is it even? Let’s try to understand the origin and thereby the hype around it.&lt;/p&gt;
&lt;p&gt;A digital token is just another piece of a smart contract code that’s running somewhere on a particular blockchain. When cryptocurrency came out and everybody started issuing their tokens, we saw a meteoric rise to Digital Tokens or CryptoCurrencies in the form of ICOs (Initial Coin Offerings) that every other project was really into at the time. Most used CryptoCurrencies came on the more popular decentralised networks like Ethereum, in the form of ERC-20s. This gave a widespread knowledge around what cryptocurrencies are and ERC-20 became a common term to be used in analogous to digital tokens wherever specified. However, several improvements on specific use-cases kept happening over time. These improvements are usually referred to as &lt;a href=&quot;https://eips.ethereum.org/erc&quot;&gt;EIPs(Ethereum Improvement Proposals)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One of the most sought after use-cases was ERC-721 or deeds or as more commonly known as Non-Fungible Tokens.
NFTs can represent ownership over digital or physical assets. It’s obviously not a new concept. It’s been around since 2014.
&lt;img src=&quot;https://blog.anirudha.dev/images/posts/6WOxWB5eG.png&quot; alt=&quot;NFT_Icon.png&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Physical property — houses, unique artwork&lt;/li&gt;
&lt;li&gt;Virtual collectables — unique pictures of kittens, collectable cards&lt;/li&gt;
&lt;li&gt;“Negative value” assets — loans, burdens, and other responsibilities
In general, all houses are distinct and no two kittens are alike. NFTs are distinguishable and you must track the ownership of each one separately.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This by itself doesn’t really mean much but when you really think about it, we already have an extremely large scale demand for such unique items. From collectible cards, items, and luxury antiques, our lives revolve around uniqueness. The more unique an item, the more valuable it becomes. It’s the very core of how our economics work and how every valuable item is identified. Now, with ERC-721, we got a way to represent it online and have a very simple way to buy and sell such assets.
Of course, it comes with its own set of problems like enormous gas fees which one has to pay for networks like Ethereum. Makes it almost impossible to acquire one or more of these very special NFTs for normal people. The NFT market value tripled in 2020, reaching more than $250 million. During the first quarter of 2021, NFT sales exceeded $2 billion. Plagiarism is another big concern where a true digital identity solution can very well fix it. We’ll take all the issues and possible solutions in perhaps a separate post of its own. I feel it deserves a more in-depth analysis.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.anirudha.dev/images/posts/QQ8otuHyl.png&quot; alt=&quot;Banner_NFT-marketplace.png&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;marketplaces&quot; tabindex=&quot;-1&quot;&gt;Marketplaces &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#marketplaces&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h4 id=&quot;opensea&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://opensea.io/&quot;&gt;OpenSea&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#opensea&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;As one of the most commonly referred NFT marketplaces, OpenSea has established it’s dominance in the space. You can practically buy or sell any type of NFT here. The process is as simplified as it can be.&lt;/p&gt;
&lt;h4 id=&quot;binance-nft&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://www.binance.com/en/nft/home&quot;&gt;Binance NFT&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#binance-nft&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Binance NFT Marketplace brings together artists, creators, and crypto enthusiasts on a single platform to create and trade top NFTs. The platform features 3 product lines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Events: Buy premium and exclusive NFTs created by global leading artists&lt;/li&gt;
&lt;li&gt;Marketplace: Mint, purchase, and bid on NFTs from creators around the world&lt;/li&gt;
&lt;li&gt;Mystery Box: Stand a chance to win rare NFTs in a box full of surprises&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;crypto.com-nft&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://crypto.com/nft/marketplace&quot;&gt;Crypto.com NFT&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#crypto.com-nft&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;rarible&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://rarible.com/&quot;&gt;Rarible&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#rarible&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;foundation&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://foundation.app/&quot;&gt;Foundation&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#foundation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;superrare&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://superrare.com/&quot;&gt;SuperRare&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#superrare&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;atomic-market&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://wax.atomicmarket.io/&quot;&gt;Atomic Market&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#atomic-market&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;myth-market&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://myth.market/&quot;&gt;Myth Market&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#myth-market&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;bakeryswap&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://www.bakeryswap.org/#/home&quot;&gt;BakerySwap&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#bakeryswap&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;axie-marketplace&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://axieinfinity.com/&quot;&gt;Axie Marketplace&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#axie-marketplace&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;knownorigin&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://knownorigin.io/&quot;&gt;KnownOrigin&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#knownorigin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;makersplace&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://makersplace.com/&quot;&gt;MakersPlace&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#makersplace&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;solana-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://solanart.io/&quot;&gt;Solana Art&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#solana-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;nba-top-shot&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://nbatopshot.com/&quot;&gt;NBA Top Shot&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#nba-top-shot&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;async-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://async.art/&quot;&gt;Async Art&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#async-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;portion&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://portion.io/&quot;&gt;Portion&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#portion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;enjin-marketplace&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://enjin.io/products/marketplace&quot;&gt;Enjin Marketplace&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#enjin-marketplace&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;h4 id=&quot;bakeryswap-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a href=&quot;https://www.bakeryswap.org/#/home&quot;&gt;BakerySwap&lt;/a&gt; &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#bakeryswap-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Even traditional art giants like &lt;a href=&quot;https://www.christies.com/&quot;&gt;Christies&lt;/a&gt; are setting up shop around it can step into the modern age.&lt;/p&gt;
&lt;h2 id=&quot;variations&quot; tabindex=&quot;-1&quot;&gt;Variations &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#variations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Over time, some variations of ERC-721 have emerged as well.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ERC-1155 which offers semi-fungibility and works over a class of assets instead of particular assets.&lt;/li&gt;
&lt;li&gt;FLOW blockchain provides proof-of-stake consensus. Mostly used by NBA Top Shot.&lt;/li&gt;
&lt;li&gt;Tezos also works on a proof-of-stake based NFT.&lt;/li&gt;
&lt;li&gt;Solana has also started supporting NFTs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;create-your-own-nft&quot; tabindex=&quot;-1&quot;&gt;Create your own NFT &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#create-your-own-nft&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A simpler way is to start using one or the platform above mentioned and get started with it. If you want to create your own marketplace or product as such, there’s always a way to do so.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select a DLT network on which you’d like to issue the NFTs on. Preferably one with less transaction fee.&lt;/li&gt;
&lt;li&gt;Write an NFT smart contract or equivalent in that particular network. Here’s a good getting started point are in &lt;a href=&quot;https://docs.openzeppelin.com/contracts/2.x/api/token/erc721&quot;&gt;OpenZepplin Docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make sure there’s an easy interface because mind you, most of your users are really just everyday Joes who just want to purchase as an investment strategy.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;so%2C-what-all-can-you-use-nfts-for%3F&quot; tabindex=&quot;-1&quot;&gt;So, what all can you use NFTs for? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/what-is-nft/#so%2C-what-all-can-you-use-nfts-for%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Art&lt;/li&gt;
&lt;li&gt;GIFs&lt;/li&gt;
&lt;li&gt;Videos and sports highlights&lt;/li&gt;
&lt;li&gt;Collectibles&lt;/li&gt;
&lt;li&gt;Virtual avatars and video game skins&lt;/li&gt;
&lt;li&gt;Designer sneakers&lt;/li&gt;
&lt;li&gt;Music&lt;/li&gt;
&lt;li&gt;Tweets&lt;/li&gt;
&lt;li&gt;Github Commits&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, be wary of where you’re buying these NFTs from. Are they authorised sources or someone broker marketplace who’s just selling via some other marketplace? Are they really the owner or authorised seller of the items. Are they backed by a reputable organisation or foundation? Which blockchain or DLT platform are they using and how much transaction fee is that purchase going to cost you? Also, make sure you’re aware of your country or state’s legalities and taxation procedures. NFTs are also subject to capital gain tax such as any stock you might own.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>To Go with Golang</title>
		<link href="https://blog.anirudha.dev/to-go-with-golang/"/>
		<updated>2021-01-26T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/to-go-with-golang/</id>
		<content type="html">&lt;blockquote&gt;
&lt;p&gt;Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;At least that’s how the website describes itself.
The first time I tried golang was about 3 years ago as a hobby project. However lack of an implementation need and a busy work schedule made my side project obsolete. Of course, you would know what that feels like. Familiar territory. So, when the opportunity rose to write a new service in golang, I absolutely jumped at it.&lt;/p&gt;
&lt;p&gt;I’m supposed to build a small web service accepting http connection and storing some data on mongodb. Returns a certain set of result, and so on. Basic CRUD stuff. If you’re not interested in #webdev, I believe this is your stop. If you’re interested however, read on to know about what I used and why. The entire dev cycle from dev to deploy phase.&lt;/p&gt;
&lt;p&gt;First of all, why I opted for golang anyway? The service I’m supposed to write needs a highly concurrent persistent api service. It needs to be fast and also easily scalable. We could have gone with python fastapi, but at this stage I just wanted to learn golang.&lt;/p&gt;
&lt;h3 id=&quot;setting-up-golang&quot; tabindex=&quot;-1&quot;&gt;Setting up Golang &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#setting-up-golang&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you’ve finally decided to go ahead with this, let’s do this.
Easiest way probably is to just &lt;a href=&quot;https://golang.org/doc/install&quot;&gt;download from the official website&lt;/a&gt; and get going.
&lt;a href=&quot;https://medium.com/golang-learn/quick-go-setup-guide-on-mac-os-x-956b327222b8&quot;&gt;Here&lt;/a&gt;’s another article which very nicely explains the setup process. This is ideally for mac OS. In case you’re looking for other OSes, please follow respective guides.&lt;/p&gt;
&lt;p&gt;Be sure to setup your GOPATH very properly as this will remain as your common ground for any defined packages installed in your system.&lt;/p&gt;
&lt;p&gt;Once done, make sure your console recognises the GOPATH.
&lt;code&gt;echo $GOPATH&lt;/code&gt;&lt;/p&gt;
&lt;h3 id=&quot;http-service&quot; tabindex=&quot;-1&quot;&gt;HTTP Service &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#http-service&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I went with &lt;a href=&quot;https://github.com/valyala/fasthttp&quot;&gt;fasthttp&lt;/a&gt;, which provides high performance, zero memory allocations in hot paths and Up to 10x faster than net/http for a large throughput service. Go provides out of the box http support but for a beginner, it felt much easier to go with a framework, thereby ended up using fiber.&lt;/p&gt;
&lt;h3 id=&quot;api&quot; tabindex=&quot;-1&quot;&gt;API &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#api&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/gofiber/fiber&quot;&gt;Fiber&lt;/a&gt; is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go.
Make sure to use Fiber v2. Fiber V2 has a lot of breaking changes to Fiber v1. I had to spend an extra hour just upgrading these &lt;a href=&quot;https://github.com/gofiber/fiber/issues/736&quot;&gt;breaking changes&lt;/a&gt; cause I started with v1.&lt;/p&gt;
&lt;p&gt;A simple fiber service can be started using just this:&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;package&lt;/span&gt; main&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;github.com/gofiber/fiber/v2&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    app &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; fiber&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;fiber&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Ctx&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; c&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;SendString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello, World 👋!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;:3000&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;You now have a live server running at your &lt;a href=&quot;http://localhost:3000/&quot;&gt;http://localhost:3000&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;connect-to-a-database&quot; tabindex=&quot;-1&quot;&gt;Connect to a DataBase &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#connect-to-a-database&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Next, we need our web service to talk to our web-service. There are quite a few ODM(Object Document Mapper) out there. But given my initial requirement was pretty straightforward, I went the default &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver&quot;&gt;mongodb golang driver&lt;/a&gt;.
It’s pretty straightforward to connect an mongodb client:&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; err &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; mongo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ctx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; options&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;ApplyURI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mongodb://localhost:27017&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;So, now we got an active db connection going.
Ideally, that’s all we would need to create the smallest possible POC(Proof Of Concept) of any web-service you can think of.
Obviously, do go through the proper documentation as there are many pitfalls at every stage. Might as well address a few of those on a separate post.&lt;/p&gt;
&lt;p&gt;However, to make a production level POC, we need a few more stuff. So, let’s discover a few add-ons to our service:&lt;/p&gt;
&lt;h3 id=&quot;logging&quot; tabindex=&quot;-1&quot;&gt;Logging &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#logging&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Logging is one of the most important aspects in any programming. To see what’s working and where has been the crux of any development really. We sometimes debug using our logs. Specially in production.
The easiest and in-built way of printing/logging can be done using &lt;a href=&quot;https://golang.org/pkg/fmt/&quot;&gt;fmt&lt;/a&gt; or &lt;a href=&quot;https://golang.org/pkg/log/&quot;&gt;log&lt;/a&gt; packages.
A small example:&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;fmt&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Print&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Printing with fmt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;buf    bytes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Buffer&lt;br /&gt;logger &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; log&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;buf&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;logger: &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; log&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Lshortfile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Printf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Logging with log&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;The use log is highly encouraged as compared to fmt. Log is thread safe where as fmt is not. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;log&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Fatalf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Fatal err happened:&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;You can also add fatal logs if in case you would want to flag certain types of logs which might be critical to the application.&lt;/p&gt;
&lt;p&gt;Some added advantages of using Fiber is it’s logging module. If you’re on v1, you would need to install the &lt;a href=&quot;https://github.com/gofiber/logger&quot;&gt;logger package&lt;/a&gt; separately, but in v2 it has been made available within v2 itself: &lt;code&gt;&amp;quot;github.com/gofiber/fiber/v2/middleware/logger&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you need to log each request as and when it comes in, you can add something like this:&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Use&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;requestid&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;​app​&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;​Use​&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;​logger​&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;​New​&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;​Config​&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;	&lt;span class=&quot;token comment&quot;&gt;// For more options, see the Config section&lt;/span&gt;&lt;br /&gt;  Format​&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;${pid} ${locals:requestid} ${status} - ${method} ${path}​&#92;n​&quot;&lt;/span&gt;​&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;Now, each route visited will come up on your console.&lt;/p&gt;
&lt;h3 id=&quot;hot-reloading&quot; tabindex=&quot;-1&quot;&gt;Hot Reloading &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#hot-reloading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Golang is a compiled language, which means unlike Python or NodeJS which are interpreted languages, we need to build it everytime we would want to run it.
Ideally we build the project as such: &lt;code&gt;go build .&lt;/code&gt;
And then we run it like: &lt;code&gt;./app-name&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, we can still run the dev version as: &lt;code&gt;go run main.go&lt;/code&gt;
Or if there’s more than one file: &lt;code&gt;go run *.go&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;But while development process, we often make changes and would want to check the output without having to restart the go server manually.
You can obviously write your own small shell script to detect any file changes on the entire directory and restart &lt;code&gt;go run&lt;/code&gt; everytime.
If you’re using docker, you can also write the entire &lt;code&gt;go build .&lt;/code&gt; and &lt;code&gt;./app-name&lt;/code&gt; process inside the container.&lt;/p&gt;
&lt;p&gt;Needed a more robust way, which is provided by this package called fresh.
&lt;a href=&quot;https://github.com/gravityblast/fresh&quot;&gt;Fresh&lt;/a&gt; is a command line tool that builds and (re)starts your web application everytime you save a Go or template file.
You can also customise the log color that comes with the default fresh setup. It requires a default &lt;code&gt;runner.conf&lt;/code&gt; file. If you want to go with the default options, you don’t even need this file on your project root.&lt;/p&gt;
&lt;terminal-block&gt;root:              .
tmp_path:          ./tmp
build_name:        runner-build
build_log:         runner-build-errors.log
valid_ext:         .go, .tpl, .tmpl, .html
no_rebuild_ext:    .tpl, .tmpl, .html
ignored:           assets, tmp
build_delay:       600
colors:            1
log_color_main:    cyan
log_color_build:   yellow
log_color_runner:  green
log_color_watcher: magenta
log_color_app:     blue&lt;/terminal-block&gt;&lt;p&gt;Now we’ve a complete dev setup done and dusted.&lt;/p&gt;
&lt;h3 id=&quot;routing&quot; tabindex=&quot;-1&quot;&gt;Routing &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#routing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I’m obsessed with structured code. Everything can be written in a single file and ran but a structured codebase, makes it all the more easier to document, read and later manage it.
Thereby, routing is a crucial part of adopting a new framework.
Fiber comes with inbuilt route grouping&lt;/p&gt;
&lt;code-block lang=&quot;go&quot;&gt;&lt;pre class=&quot;language-go&quot;&gt;&lt;code class=&quot;language-go&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;func&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    app &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; fiber&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;New&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    api &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/api&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; middleware&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// /api&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    v1 &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; api&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/v1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; middleware&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;// /api/v1&lt;/span&gt;&lt;br /&gt;    v1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;token comment&quot;&gt;// /api/v1/list&lt;/span&gt;&lt;br /&gt;    v1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;token comment&quot;&gt;// /api/v1/user&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    v2 &lt;span class=&quot;token operator&quot;&gt;:=&lt;/span&gt; api&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; middleware&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;// /api/v2&lt;/span&gt;&lt;br /&gt;    v2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;token comment&quot;&gt;// /api/v2/list&lt;/span&gt;&lt;br /&gt;    v2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/user&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handler&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;             &lt;span class=&quot;token comment&quot;&gt;// /api/v2/user&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Listen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;:3000&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;This can help you in writing a more structured app as such you might need to authenticate only a particular group or log a particular route and so on.&lt;/p&gt;
&lt;h3 id=&quot;deployment&quot; tabindex=&quot;-1&quot;&gt;Deployment &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/to-go-with-golang/#deployment&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Probably best to go with a containerised deployment. We have deployed on &lt;a href=&quot;https://cloud.google.com/kubernetes-engine&quot;&gt;Kubernetes - Google Kubernetes Engine (GKE)&lt;/a&gt; which only needs an additional &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It’s better to go with a multi-stage docker setup:&lt;/p&gt;
&lt;code-block lang=&quot;dockerfile&quot;&gt;&lt;pre class=&quot;language-dockerfile&quot;&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;FROM&lt;/span&gt; golang:1.12-alpine &lt;span class=&quot;token keyword&quot;&gt;AS&lt;/span&gt; build_base&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; apk add --no-cache git&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Set the Current Working Directory inside the container&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;WORKDIR&lt;/span&gt; /tmp/go-sample-app&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# We want to populate the module cache based on the go.{mod,sum} files.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;COPY&lt;/span&gt; go.mod .&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;COPY&lt;/span&gt; go.sum .&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; go mod download&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;COPY&lt;/span&gt; . .&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Unit tests&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; CGO_ENABLED=0 go test -v&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Build the Go app&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; go build -o ./out/go-sample-app .&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Start fresh from a smaller image&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;FROM&lt;/span&gt; alpine:3.9&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; apk add ca-certificates&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;COPY&lt;/span&gt; &lt;span class=&quot;token options&quot;&gt;&lt;span class=&quot;token property&quot;&gt;--from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;build_base&lt;/span&gt;&lt;/span&gt; /tmp/go-sample-app/out/go-sample-app /app/go-sample-app&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# This container exposes port 8080 to the outside world&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;EXPOSE&lt;/span&gt; 8080&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;# Run the binary program produced by `go install`&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;CMD&lt;/span&gt; [&lt;span class=&quot;token string&quot;&gt;&quot;/app/go-sample-app&quot;&lt;/span&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/code-block&gt;&lt;p&gt;A complete guide on dockerising your golang app can be found &lt;a href=&quot;https://codefresh.io/docs/docs/learn-by-example/golang/golang-hello-world/&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://www.docker.com/blog/containerize-your-go-developer-environment-part-1/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With this we’ve now a deployed version of our golang app. Connect that gke ip to your preferred DNS provider and share the link. Feel free to leave a link of you first golang app in the comments. Would love to see what everyone is working on.&lt;/p&gt;
&lt;p&gt;If you have a different view on some of the stack used or talked here, feel free to add your thoughts. We’re all learning and would love to see the more popular frameworks and best practices in use.&lt;/p&gt;
&lt;p&gt;Cheers and until next time…&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The Code of Libraries</title>
		<link href="https://blog.anirudha.dev/the-code-of-libraries/"/>
		<updated>2020-08-04T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/the-code-of-libraries/</id>
		<content type="html">&lt;p&gt;How many times have you found yourself in the middle of your project, had to stop and switch to a different library, all because it didn’t support a simple feature? How many of those times you wondered if you knew which library to use to get going? You did nothing wrong. You chose the first result that came up on google or your package manager’s recommended website. It obviously showed a very download rate and popular usage. But even so, more times than less, we tend to miss a key factor or two which can lead us to go back and check out a different package. Sometimes it leads you to lose interest in the working project, or find yourself trying to fix the library which might increase your development time.&lt;/p&gt;
&lt;p&gt;It really is frustrating at times, isn’t it? Considering being in a similar situation more times than I would care to admit, I tried to devise a few guidelines to follow while selecting the right library to use, which let’s call as &lt;em&gt;The Code of Libraries&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;source-code&quot; tabindex=&quot;-1&quot;&gt;Source Code &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#source-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This should be pretty obvious. Find that source code of your library and go through the code. No need to get overwhelmed and no need to obviously go through the entire source code. Just enough to make to sure that there’s at least some code written on it. It might just be a fully updated package every few months and has no code whatsoever written inside. Even better if the library has tests written which you can run preferably in interactive or verbose mode to go through the output as it happens.&lt;/p&gt;
&lt;h2 id=&quot;stars%2Fforks%2Fwatchers&quot; tabindex=&quot;-1&quot;&gt;Stars/Forks/Watchers &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#stars%2Fforks%2Fwatchers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/pgEFiOz.png&quot; alt=&quot;Github Watchers, Stars, Forks&quot; title=&quot;Github Watchers, Stars, Forks&quot; /&gt;&lt;/p&gt;
&lt;p&gt;A quick look at the stars any project has got can provide a good idea of the popularity and validation for the project. Forks would showcase of how many people are interested in contributing or working on the project, which would also mean it’ll be that easier to get support for the project.&lt;/p&gt;
&lt;h2 id=&quot;version&quot; tabindex=&quot;-1&quot;&gt;Version &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#version&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Trust in experience. Always take into consideration going for libraries with releases before their own v1.0.0. They’re probably still testing it out themselves. Obviously, they would put up a flag on their readme file as to Under Development or something similar, but they also might not have. So, it’s obviously upto you to cross-check. Make sure to also check previous versions. It might so happen that someone’s first release is starting from v1.0.0. On the other hand check the versions previous to it. A very good possibility that on every spelling fix, the maintainers were pushing a separate release and now the poor library is left with v24.12.142 and really it’s just printing Hello World on the console.&lt;/p&gt;
&lt;h2 id=&quot;downloads&quot; tabindex=&quot;-1&quot;&gt;Downloads &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#downloads&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/OVniMSO.png&quot; alt=&quot;Downloads&quot; title=&quot;Downloads&quot; /&gt;
Pretty obvious when you think about it. Always check the number of downloads the library is getting on a weekly or monthly basis. Often times than more, the libraries get downloaded by thousands of mirroring bots to private data centres for analysis and storage. So, although most of those numbers might be way higher than actual users downloading that particular library. But also the mirroring bots are active more frequent on the more user downloaded libraries.
&lt;img src=&quot;https://i.imgur.com/gge1ydG.png&quot; alt=&quot;Download count&quot; title=&quot;Download count&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;used-by&quot; tabindex=&quot;-1&quot;&gt;Used By &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#used-by&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/KPomAcb.png&quot; alt=&quot;Used By&quot; title=&quot;Used By&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This is one of the best features Github rolled up recently. Touchdown Github! This particular feature provides a pretty comprehensive list on how many people are using the project. Check out the dependants of python flask project. If the codebase is on GitHub, definitely this adds more credibility to the project than anything else. To be sure, just browse through randomly some of those projects to get an idea what they are being used for and how’s their work going along. It might so happen that the library was popular before and used a lot by a lot of projects but now not so much, due to either a better updated library available or the technology itself being outdated.&lt;/p&gt;
&lt;h2 id=&quot;last-updated&quot; tabindex=&quot;-1&quot;&gt;Last Updated &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#last-updated&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Find the repo link. Check for when the last push to the codebase was. It’s a statistically safe bet if the library had code pushes in anywhere within last 2–4 months. Anything more than 6 months is not to be trusted. Specially for languages like nodejs and gaoling where the language releases are very often within months. For languages which doesn’t have that fast releases like python or ruby, upto 6 months still is okay. We’ve used packages from 3 years ago and still works great. And also packages that went on update last month is still some vulnerable dependencies.
&lt;img src=&quot;https://i.imgur.com/gnrQN7Q.png&quot; alt=&quot;Contributions Graph&quot; title=&quot;Contributions Graph&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;release-cycle&quot; tabindex=&quot;-1&quot;&gt;Release Cycle &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#release-cycle&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Alongside last updated, release cycles are very important. You might find this a vague criteria, but for packages which are being released every week, if they suddenly stop releases, it’s either the maintainers have dumped this project or have some issues that they can’t fix yet. An instance might be when last updated date is 3 months ago but it used to have steady releases every week. By their own timeline, they would have missed close to 14 cycles. That never looks good. Trust us.&lt;/p&gt;
&lt;h2 id=&quot;issue%2Fbug-list&quot; tabindex=&quot;-1&quot;&gt;Issue/Bug List &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#issue%2Fbug-list&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/49fKg3S.png&quot; alt=&quot;Issue Page&quot; title=&quot;Issue Page&quot; /&gt;
A very important criteria to meet is to check for open issues on the repo. And if any of those issues are very old pending. Look more closely as to when were last updated in comments as such. Also, if there’s any critical bug pending in open issues. Sometimes this might be a make or break moment. A package might be not maintained as much but the maintainers might still be answering questions on issues raised and closing them or redirecting to another working library. While you’re at it, take a quick peek on closed issues as well to make sure the project maintainers aren’t just closing issues so they won’t stay on the open issues and make themselves look bad.&lt;/p&gt;
&lt;h2 id=&quot;dependencies&quot; tabindex=&quot;-1&quot;&gt;Dependencies &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#dependencies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/VYboD2e.png&quot; alt=&quot;Dependencies&quot; title=&quot;Dependencies&quot; /&gt;
Check the codebase and go through it thoroughly for all dependency that your desired package is facing up. Even better if the project has integrated code coverage, dependency checker or other such tools. They’re free to use and you should definitely use them to your advantage. Your library might be very well maintained but some dependency that it’s relying on might have been outdated and not-maintained anymore. It’s a big disaster in that case. Switch to some other library immediately.&lt;/p&gt;
&lt;h2 id=&quot;community-response&quot; tabindex=&quot;-1&quot;&gt;Community Response &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#community-response&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Finally, check for the official communitcation channel or q/a forums used by the respective community. It might be on irc, gitter, slack, discord, rocketchat or some equivalent communication channel but this will give a great idea of the typeof discussions happening at the project level and if the project is inherently active.
&lt;img src=&quot;https://i.imgur.com/vcbWuIG.jpg&quot; alt=&quot;Community Support&quot; title=&quot;Community Support&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, there you have it. Now, repeat: &lt;em&gt;I solemly swear to abide by &lt;strong&gt;The Code of Libraries&lt;/strong&gt; for my all future projects.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;some-popular-tools&quot; tabindex=&quot;-1&quot;&gt;Some Popular Tools &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/the-code-of-libraries/#some-popular-tools&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The Ruby community came up with an online tool to compare projects called &lt;a href=&quot;https://www.ruby-toolbox.com/&quot;&gt;Ruby Toolbox&lt;/a&gt;. It’s brilliant and provides a pretty comprehensive comparision to make your job easier.
&lt;img src=&quot;https://i.imgur.com/3cG2Z03.png&quot; alt=&quot;Ruby Toolbox&quot; title=&quot;Ruby Toolbox&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://libraries.io/&quot;&gt;Libraries.io&lt;/a&gt; helps you find new open source packages, modules and frameworks and keep track of ones you depend upon.
&lt;img src=&quot;https://i.imgur.com/Ssgf2Q1.png&quot; alt=&quot;Libraries.io&quot; title=&quot;Libraries.io&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now, sometimes even after following Polyglot’s Code of the Libraries, you might get stuck into such scenarios where you need to take care of a dependency of a dependency of your project. You might imagine yourself spending too much time fixing up the library. Polyglot is a community of developers driving an open source software agency to help you get out of such a mess. Get in touch with Polyglot Network at &lt;a href=&quot;mailto:team@polyglot.network&quot;&gt;team@polyglot.network&lt;/a&gt; and let them take care of that open source library for you.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Data Currency and Technology</title>
		<link href="https://blog.anirudha.dev/data-currency-and-technology/"/>
		<updated>2018-04-22T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/data-currency-and-technology/</id>
		<content type="html">&lt;p&gt;Three words that is in everything and everywhere. The very essence of an object, be it physical or digital is encompassed within the realms of these 3 words. However, there is such distinction amongst the words that we often do not relate to them as the one single entity or even closely linked to each other. Today, we’ll try to find out if that’s true.&lt;/p&gt;
&lt;p&gt;A most widely generic definition can be:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Any piece of information, however small or intricate, vague or clear, story or not, if given a proper structure and category that be meaningful in one way or other to oneself, can be termed as data.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, in a way any piece of information can be termed as data. Interesting! I never knew that me, eating an apple instead of banana can be a meaningful piece of information to be classified as data. But it actually is. To the right person, in the right hands, any piece of information that they can monetise on is actually data. How, do you ask? Well, if an apple selling store knew about this, they would know that I prefer apple over banana and they would then try to sell more apples or other product of apples, perhaps Apple Juice or something. On the contrary if a banana store came around it, they would probably ask me what’s wrong and try to fix it so as to not lose a potential customer.&lt;/p&gt;
&lt;p&gt;Of course, for as small a data set as a single person, nobody would bother. But say that data isn’t just of mine. It’s of thousands of people in the same neighbourhood. Then, it might catch their eye and they would react. Cause then they would need this data to get their business running. And they would be willing to pay to get such data. Maybe pay 1% of their rest 99% in profit from targeted marketing and sales. Believe me, it is already a thing. Which links to my next point: Currency.&lt;/p&gt;
&lt;p&gt;Who doesn’t know what currency is? But do we really understand it? We take a dollar or rupee bill, and think it holds some value when actually, it doesn’t. If it’s unregistered, somewhere or other it’s not a legal form of currency note. Some bank or institution has to maintain a clear ledger of data as to where that particular note went through to reach your hands. If they do, that note is valid. Otherwise, it becomes something we term as black money and liable to get yourself a heavy charge for carrying illegal money. But, banking ledgers being controlled at a particular location or set defined books became easy to access or manipulate. One could copy all of the books and in process, insert their data in between the rest, which could eventually make their money legal. Eventually, the banks got smarter. They moved from books to storage devices and softwares. But now, it became even easier to randomly insert data. And copy data into new data. Now, the struggle only remained as a tug of war between who knew more technology to get ahead of the other.&lt;/p&gt;
&lt;p&gt;Technology really just means the science of craft. But we’ve taken it so closely to gadgets, that for us, technology merely means catching a Pokemon with a ball by swiping up, in our phone. Well, technically, it ain’t wrong. Just incomplete. We live in a world surrounded by gadgets and apps. Alexa, Uber, Instagram, WhatsApp, Facebook, Twitter, Google Home, even cars now, Tesla. How can the meaning not change. Technological advancements has been tremendous in the last few years. Technology has influenced every part of our lives. From managing data to transferring currency. We don’t go to the banks anymore to fill out a form and transfer money. We just use Paypal or Paytm. Excel sheets have paved ways to databases, and then distributed databases to enhance the further security and accessibility of data. Yes, the social websites that we visit to do give us a lot of exposure. But they also clearly sell out your data to potential buyers. Data encourages currency. But technology really is the one that supports it. But the more important question is, do you really care? If you did, you would lived a monk life so far. But you don’t. You want people to show you ads of that camera, that you viewed a hundred times but can’t afford. If there’s ever an offer or better price somewhere else or newer bran, you’ll come to know about it. Isn’t that great? Of course it is. You may cower that you might not want to know about some other related item which even might get inappropriate sometime and I totally agree to it. But how will the systems learn and adapt to your needs and requirements if they are fed in with huge amounts of data on the same. Are they really breaching our privacy? Do we really need to shut them down. After-all, it’s our inability to read through the lengthy agreements of usage. We are in so hurry to get on-board the show, that we are ready to give it all up.&lt;/p&gt;
&lt;p&gt;Being said that, obviously we would want a control over own data. Not all of us want to know the nearest restaurant or asked to check-in every time we are near one. And I totally am on the same page with that as well. We must have control over our data. But at the same time be aware of the advantages that data can bring to us.
Technology as helped us use our data in the form of currency today. There are various data marketplaces even, where companies buy and sell data legally. You can also utilise such marketplaces to monetise your data, the way you would want it to be used.&lt;/p&gt;
&lt;p&gt;Put up your thoughts as to what you think the world should move on to the next phase of data privacy and sharing. Is it ok to come up on WikiLeaks and not on google or do we really want the control and are willing to spend time and give up the online social life to get free of that.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://medium.com/@anistark/data-currency-and-technology-6b708e3f622a&quot;&gt;Originally posted on Medium&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Intro To Blockchain</title>
		<link href="https://blog.anirudha.dev/intro-to-blockchain/"/>
		<updated>2017-04-16T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/intro-to-blockchain/</id>
		<content type="html">&lt;p&gt;The first time I heard of blockchain was by being the distributed ledger that bitcoin uses. And I’m sure so have many of you, maybe still you believe the same. So, let’s take a trip down the years of how blockchain came to be and what it can be potentially.&lt;/p&gt;
&lt;h2 id=&quot;origin&quot; tabindex=&quot;-1&quot;&gt;Origin &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/intro-to-blockchain/#origin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Satoshi Nakamoto was the inventor of the bitcoin protocol, publishing a &lt;a href=&quot;https://bitcoin.org/bitcoin.pdf&quot;&gt;paper&lt;/a&gt; via the &lt;a href=&quot;https://www.metzdowd.com/mailman/listinfo/cryptography&quot;&gt;Cryptography Mailing List&lt;/a&gt; in November 2008.
He then released the first version of the bitcoin software client in 2009, and participated with others on the project via mailing lists, until he finally began to fade from the community toward the end of 2010.
Nakamoto worked with people on the open-source team, but took care never to reveal anything personal about himself, and the last anyone heard from him was in the spring of 2011, when he said that he had “moved on to other things”. As of 2 February 2017, Nakamoto is believed to own up to roughly one million bitcoins,&lt;a href=&quot;https://www.weforum.org/&quot;&gt;3&lt;/a&gt; with a value estimated at over US$1.1 billion.&lt;/p&gt;
&lt;h2 id=&quot;bitcoin&quot; tabindex=&quot;-1&quot;&gt;Bitcoin &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/intro-to-blockchain/#bitcoin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Bitcoin is a digital currency and a public ledger. Often the ledger is itself mistook to be what blockchain is. That’s not entirely true. Bitcoin as a ledger is a type of blockchain. Blockchain as a whole is the technology underlying bitcoin.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“[Blockchain] is to Bitcoin, what the internet is to email. A big electronic system, on top of which you can build applications. Currency is just one.”
— Sally Davies, FT Technology Reporter&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, let’s move on to what blockchain is.&lt;/p&gt;
&lt;h2 id=&quot;blockchain&quot; tabindex=&quot;-1&quot;&gt;Blockchain &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/intro-to-blockchain/#blockchain&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Blockchain by definition is &lt;em&gt;an open transparent distributed ledger&lt;/em&gt;. That’s it. Nothing more. Nothing less. But you still feel confused. Let me explain what that definition means.&lt;/p&gt;
&lt;p&gt;Here’s what &lt;a href=&quot;https://en.wikipedia.org/wiki/Vitalik_Buterin&quot;&gt;Vitalik Buterin&lt;/a&gt;, the co-founder of &lt;a href=&quot;https://www.ethereum.org/&quot;&gt;Ethereum&lt;/a&gt;(An open-source, public, blockchain-based distributed computing platform featuring smart contract (scripting) functionality) and the co-founder of &lt;a href=&quot;https://bitcoinmagazine.com/&quot;&gt;Bitcoin Magazine&lt;/a&gt; says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“A blockchain is a magic computer that anyone can upload programs to and leave the programs to self-execute, where the current and all previous states of every program are always publicly visible, and which carries a very strong crypto economically secured guarantee that programs running on the chain will continue to execute in exactly the way that the blockchain protocol specifies.”
— Vitalik Buterin&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Still not too clear? How about we take a look at how the &lt;a href=&quot;https://www.weforum.org/&quot;&gt;World Economic Forum&lt;/a&gt; describes it with this video right here:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=6WG7D47tGb0&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/6WG7D47tGb0/0.jpg&quot; alt=&quot;Alt text&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Makes a little more sense. Deloitte explains blockchain something like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You (a “node”) have a file of transactions on your computer (a “ledger”). Two government accountants (let’s call them “miners”) have the same file on theirs (so it’s “distributed”). As you make a transaction, your computer sends an e-mail to each accountant to inform them.
Each accountant rushes to be the first to check whether you can afford it (and be paid their salary “Bitcoins”). The first to check and validate hits “REPLY ALL”, attaching their logic for verifying the transaction (“Proof of Work”). If the other accountant agrees, everyone updates their file…
This concept is enabled by “&lt;strong&gt;Blockchain&lt;/strong&gt;” technology.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A pretty decent overview of the system. You must by now have a clear picture of what the blockchain is and can be turned into.&lt;/p&gt;
&lt;h2 id=&quot;applicaitons&quot; tabindex=&quot;-1&quot;&gt;Applicaitons &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/intro-to-blockchain/#applicaitons&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The world has already started reacting to this massive revolution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Honduras government&lt;/strong&gt; has put all land records on a public ledger - the blockchain. The minute there is a change in ownership, it gets recorded publicly.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Australian Securities Exchange (ASX)&lt;/strong&gt; announced that it would move Australia’s equities clearing and settlement system on to blockchain.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.nasdaq.com/&quot;&gt;Nasdaq&lt;/a&gt; unveiled &lt;a href=&quot;https://ir.nasdaq.com/releasedetail.cfm?releaseid=948326&quot;&gt;Linq&lt;/a&gt;, a solution enabling private companies to digitally represent share ownership using blockchain-based technology.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ICICI Bank&lt;/strong&gt; executes India’s first banking transactions on blockchain in partnership with Emirates NBD. Undertakes pilot transactions in international trade finance and remittance on blockchain.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.ascribe.io/&quot;&gt;Ascribe&lt;/a&gt; lets artist themselves upload digital art, watermark it as the definitive version, and transfer it.&lt;/p&gt;
&lt;p&gt;And these are just a few examples of the many applications and areas blockchain is expanding it’s reach to.&lt;/p&gt;
&lt;h2 id=&quot;future&quot; tabindex=&quot;-1&quot;&gt;Future &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/intro-to-blockchain/#future&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Blockchain is creating a biggest shift in paradigm the world has seen yet, since the days of world wide web. And it’s here to create the revolution that will blow your mind.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://dontapscott.com/&quot;&gt;Don Tapscott&lt;/a&gt;, the author of many business and economics books and also the lead author of &lt;a href=&quot;https://blockchain-revolution.com/&quot;&gt;Blockchain Revolution&lt;/a&gt;, says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“The technology likely to have the greatest impact on the next few decades has arrived. And it’s not social media. It’s not big data. It’s not robotics. It’s not even AI. You’ll be surprised to learn that it’s the underlying technology of digital currencies like Bitcoin. It’s called the blockchain.”
— Don Tapscott&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Needless to say what the future holds for blockchain and the huge potential blockchain can bring in to the current world.
We get not just to witness a revolution, but also be a part of it.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Consensus Decision Making</title>
		<link href="https://blog.anirudha.dev/consensus-decision-making/"/>
		<updated>2017-02-18T00:00:00Z</updated>
		<id>https://blog.anirudha.dev/consensus-decision-making/</id>
		<content type="html">&lt;h3 id=&quot;introduction-to-decision-making&quot; tabindex=&quot;-1&quot;&gt;Introduction to Decision Making &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#introduction-to-decision-making&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In psychology, decision-making is regarded as the cognitive process resulting in the selection of a belief or a course of action among several alternative possibilities.
Human performance with regard to decisions has been the subject of active research from several perspectives:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Psychological&lt;/strong&gt;: examining individual decisions in the context of a set of needs, preferences and values the individual has or seeks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cognitive&lt;/strong&gt;: the decision-making process regarded as a continuous process integrated in the interaction with the
environment.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Normative&lt;/strong&gt;: the analysis of individual decisions concerned with the logic of decision-making, or communicative rationality, and the invariant choice it leads to.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;decision-making-techniques&quot; tabindex=&quot;-1&quot;&gt;Decision-making techniques &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#decision-making-techniques&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Decision-making techniques can be separated into two broad categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Group decision&lt;/strong&gt;-making techniques and individual decision-making techniques.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Individual decision&lt;/strong&gt;-making techniques can also often be applied by a group.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;consensus-decision-making&quot; tabindex=&quot;-1&quot;&gt;Consensus decision-making &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#consensus-decision-making&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Consensus decision-making is a group decision-making process in which group members develop, and agree to support a decision in the best interest of the whole. Consensus may be defined professionally as an acceptable resolution, one that can be supported, even if not the “favourite” of each individual. It is a creative and dynamic way of reaching agreement between all members of a group. Instead of simply voting for an item and having the majority of the group getting their way, a group using consensus is committed to finding solutions that everyone actively supports, or at least can live with. The input and ideas of all participants are gathered and synthesised to arrive at a final decision acceptable to all. Through consensus, we are not only working to achieve better solutions, but also to promote the growth of community and trust.&lt;/p&gt;
&lt;h3 id=&quot;consent&quot; tabindex=&quot;-1&quot;&gt;Consent &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#consent&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Giving consent does not necessarily mean that the proposal being considered is one’s first choice. Group members can vote their consent to a proposal because they choose to cooperate with the direction of the group, rather than insist on their personal preference. Sometimes the vote on a proposal is framed, “Is this proposal something you can live with?” This relaxed threshold for a yes vote can achieve full consent. This full consent, however, does not mean that everyone is in full agreement. Consent must be &#39;genuine and cannot be obtained by force, duress or fraud. The values of consensus are also not realized if “consent” is given because participants are frustrated with the process and wanting to move on.&lt;/p&gt;
&lt;h3 id=&quot;sociocracy&quot; tabindex=&quot;-1&quot;&gt;Sociocracy &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#sociocracy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It furthermore paved way to a system of governance using consent decision making and an organisational structure based on cybernetic principles, i.e. a transdisciplinary approach for exploring regulatory systems—their structures, constraints, and possibilities… It was called Sociocracy.
Sociocracy makes a distinction between “consent” and “consensus” in order to emphasize that circle decisions are not expected to produce “a consensus”. It doesn’t mean agreement or solidarity. In sociocracy consent is defined as “no objections,” and objections are based on one’s ability to work toward the aims of the organisation.
Sociocratisch Centrum co-founder Reijmer has summarised the difference as follows: &lt;em&gt;&amp;quot;By consensus, I must convince you that I am in the right; by consent, you ask whether you can live with the decision.”&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;consensus-decision-making-in-making-of-a-start-up&quot; tabindex=&quot;-1&quot;&gt;Consensus Decision Making in Making of a Start-Up &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#consensus-decision-making-in-making-of-a-start-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;By now, you must have had a pretty decent understanding on the clarity that consensus decision making can provide us and the advantages of it in a small company or a startup where a few people have to sit-tight in a room and decide over what business model they should go with.
Let’s go over a model from the emergence of a startup:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Introduce and clarify the issue to be decided.&lt;/li&gt;
&lt;li&gt;Explore the issue with your group and look for ideas amongst peers or partners or close friends.&lt;/li&gt;
&lt;li&gt;Look for emerging proposal. Sometimes this phase also results in a completely different idea than what was to be decided at all, which is turn deviates a startup from one business model to the next also known as pivot of idea.&lt;/li&gt;
&lt;li&gt;Discuss, clarify and amend your proposal.&lt;/li&gt;
&lt;li&gt;Test for agreements. Check for blocks, reservations, resolve them if needed and then it’s all good to proceed.&lt;/li&gt;
&lt;li&gt;Finally, implement the decision.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;quick-decision-making&quot; tabindex=&quot;-1&quot;&gt;Quick Decision Making &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#quick-decision-making&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;However, consensus decision making process can be sometimes slower and we are in a cut throat world where multiple issues require our quick attention. In quick consensus we are cutting short the discussion part and paring it down to just one workable proposal with amendments. This is because you are aiming to make the best decision in the time you have. However, this model of decision making needs lots of practice in advance.
If you want to use this process, you’ll need to discuss in advance the situations when you’ll use it, and take time to explore the issues involved. That way you’ll already know what people’s concerns and reactions might be when confronted with the situation. In effect, this is like having the discussion stage of the consensus process in advance, which will allow you to jump straight to the proposal stage in an urgent situation.&lt;/p&gt;
&lt;h3 id=&quot;what-about-on-scale%3F&quot; tabindex=&quot;-1&quot;&gt;What about on scale? &lt;a class=&quot;header-anchor&quot; href=&quot;https://blog.anirudha.dev/consensus-decision-making/#what-about-on-scale%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We have by now come across multiple models to facilitate consensus decision making in small team or group. But what larger groups? Do we fall back to our democracy system and rely on voting? Well, not really. It’s more challenging to get an unanimous decision in such large group but nonetheless if and when achieved is inspiring in it’s own self.
The six steps for reaching consensus are the same as for small groups, but some steps may happen with everyone together and other steps may happen in small groups to enable in-depth discussion and participation.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Delegation&lt;/strong&gt;: Avoiding micro-management is the key while delegating decisions, where the whole group decides in fine detail what needs to be done.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Large plenaries&lt;/strong&gt;: The whole group comes together in one place, can be used to share information, to make proposals and for final decision making.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Working in small groups&lt;/strong&gt;: People will be much more comfortable talking openly in a small group of 6-15 people. Working in small groups and teams also saves time. In every organisation the teams are formed for the same reason.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The spokes-council&lt;/strong&gt;: Obviously after all that, given the huge size of group, someone has to sit and pass on the judgement and decide over convincing a team to another and make everyone reach one decision.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Consensus is about co-operating to find solutions and not competing. An extremely effective decision making process which has advantages beyond expectations and I personally feel every organisation should adhere part of it or completely to it.&lt;/p&gt;
</content>
	</entry>
</feed>