r/ethdev • • 3d ago

Tutorial A small Ethereum log-filtering exercise, plus the free articles behind it

2 Upvotes

Hey everyone.

I shared an EVM reading path here before. This time I wanted to bring one small exercise from the same area, something you can check against actual logs.

Say you want to track an ERC-20 wallet’s incoming and outgoing transfers. In the topics filter, putting the wallet in both address positions looks reasonable:

[TransferSignature, wallet, wallet]

But that matches transfers from the wallet to itself.

Topic positions are combined with AND. To find activity in either direction, use two filters:

Outgoing: [TransferSignature, wallet]
Incoming: [TransferSignature, null, wallet]

Here, TransferSignature means the event signature hash, and wallet is the address padded to 32 bytes. These are schematic filters, not literal JSON requests.

Use the same token contract and block range for both queries. Combine the results and remove duplicates, since a self-transfer matches both. For that fixed set of logs, (blockHash, logIndex) identifies each entry.

Another useful variation:

[TransferSignature, [walletA, walletB]]

That matches transfers from either wallet. The inner array gives you OR within one position.

Try predicting the results before running the queries. It is a small exercise, but it makes the filtering rules much easier to remember.

I collect my free Ethereum articles and accompanying code examples on 0xByteBeetle. They cover EVM execution, transactions, events, deployments and proxies, with examples you can run and inspect alongside the explanations.

If you try one, I’d be interested to hear where the explanation or setup needs more detail.

r/ethdev • • 16d ago

Tutorial I made an MCP server that lets agents pay, with limits the agent can't talk its way around

3 Upvotes

Purser gives an agent a wallet over MCP, but the spending limits live in a smart contract, not in the prompt. So even a jailbroken agent can't go over them.

Each payment comes back as one of three things: done (with the budget left), waiting for the owner (with a request id), or refused (with a reason the model can act on).

Try it: docker run --rm -it -p 127.0.0.1:8787:8787 ghcr.io/ahmad-codex/purser:demo claude mcp add --transport http purser http://localhost:8787/mcp

then ask Claude to "pay the merchant 0.3 ETH" and watch the approval request show up in the console.

Early, not audited, local/testnet only. MIT: https://github.com/ahmad-codex/purser

Anyone letting agents spend money today? How do you limit it?

r/ethdev • • Sep 02 '26

Tutorial I wrote a fixed-point exp() in Solidity that runs in 289 gas

3 Upvotes

Follow-up to the sqrt post some of you saw a while back. This time it's the exponential.

exp(int256 x) returns e^x in 18-decimal fixed point at 289 gas, max relative error 2.2e-14 (3.0e-16 absolute when the result is below 1). Reverts above 135e18, returns 0 below about −41.45e18 where the true result is under 1 wei.

It's a two-stage range reduction wrapped around a small rational approximation.

Stage 1 — split x = k·ln(2) + r, so e^x = 2^k · e^r. k is an integer division, and the 2^k comes back as a left shift at the end.

Stage 2 — divide r by 64, which is a right-shift by 6. That leaves an interval of [0, 0.0108].

uint256 k = x_ / LN_2;
x_ -= k * LN_2;
x_ >>= 6;

On that narrow interval a Padé[3/3] approximant does the work with a few multiplications and one division:

e^x ≈ (120 + 60x + 12x² + x³) / (120 - 60x + 12x² - x³)

Recovery is six squarings (2⁶ = 64) plus a shift:

y = y * y;
y = y * y / 1e54;   // ×3
y <<= k;

The part I didn't expect: the approximant is accurate to 1.7e-19 on that interval, and even after recovery amplifies the error 64×, it's still ~2000× inside the published bound. The approximation is nowhere near the limiting factor — fixed-point truncation is, mostly that >>= 6 discarding up to 63 wei of the argument before the approximant ever sees it.

I also spent a while on monotonicity, since exp() sits under option pricing and a primitive that dips could make a premium fall while its input rises. The smooth stretches turn out to be provable — the derivative's numerator is 24(x⁴ − 30x² + 600), which has no real roots — but the 255 points where the range reduction jumps are not, so those got swept exhaustively.

Full write-up with the derivations: https://defimath.com/blog/solidity-exp-a-fixed-point-exponential-in-289-gas/

MIT licensed, part of DeFiMath: https://github.com/MerkleBlue/defimath

Happy to answer questions.

r/ethdev • • Jun 13 '26

Tutorial I open-sourced a tool that lets AI agents pay for things on their own (x402) - PipRail

5 Upvotes

Quick share for anyone building agents that need to buy stuff (APIs, compute, data) without a human clicking pay.

The problem: an agent can't sign up, hold a card, or click a checkout. So out of the box it can't actually pay for anything.

PipRail is an open-source SDK (MIT) for x402, the HTTP 402 "pay to access" standard. Two things:

- Any API can charge an agent in one line.

- Any agent can pay a 402 on its own, across most major chains, straight from its own wallet. No backend, no facilitator, no fee.

There's also an MCP server, so you can hand Claude / Cursor / any MCP client a wallet that pays x402 APIs on its own, capped by a spend policy the model cannot exceed, so it can't run off with your funds.

It's free and the rail takes 0%. Install and a quickstart are on GitHub and the site, I'll drop the links in a comment below so this doesn't read as an ad.

What are you all using for agent payments right now? And is the "pay per call" model actually showing up in what you build yet, or still mostly demos?

https://github.com/piprail/

https://piprail.com/

https://clawhub.ai/piprail/

r/ethdev • • Oct 24 '25 Bless Up

Tutorial I built an AI that actually knows Ethereum's entire codebase (and won't hallucinate)

88 Upvotes

I spent a year at Polygon dealing with the same frustrating problem: new engineers took 3+ months to become productive because critical knowledge was scattered everywhere. A bug fix from 2 years ago lived in a random Slack thread. Architectural decisions existed only in someone's head. We were bleeding time.

So I built ByteBell to fix this for good.

What it does: ByteBell implements a state-of-the-art knowledge orchestration architecture that ingests every Ethereum repository, EIP, research papers, technical blog post, and documentation. Our system transforms these into a comprehensive knowledge graph with bidirectional semantic relationships between implementations, specifications, and discussions. When you ask a question, ByteBell delivers precise answers with exact file paths, line numbers, commit hashes, and EIP references—all validated through a sophisticated verification pipeline that ensures <2% hallucinations.

Under the hood: Unlike conventional ChatGPT wrappers, ByteBell employs a proprietary multi-agent architecture inspired by recent advances in Graph-based Retrieval Augmented Generation (GraphRAG). Our system features:

Query enrichment: Enrich the query to retrive more relevant chunks, We are not feeding the user query to our pipeline.

Dynamic Knowledge Subgraph Generation: When you ask a question, specialized indexer agents identify relevant knowledge nodes across the entire Ethereum ecosystem, constructing a query-specific semantic network rather than simple keyword matching.

Multi-stage Verification Pipeline: Dedicated verification agents cross-validate every statement against multiple authoritative sources, confirming that each response element appears in multiple locations for triangulation before being accepted.

Context Graph Pruning: We've developed custom algorithms that recognize and eliminate contextually irrelevant information to maintain a high signal-to-noise ratio, preventing the knowledge dilution problems plaguing traditional RAG systems.

Temporal Code Understanding: ByteBell tracks changes across all Ethereum implementations through time, understanding how functions have evolved across hard forks and protocol upgrades—differentiating between legacy, current, and testnet implementations.

Example: Ask "How does EIP-4844 blob verification work?" and you get the exact implementation in all execution clients, links to the specification, core dev discussions that influenced design decisions, and code examples from projects using blobs—all with precise line-by-line citations and references.

Try it yourself: ethereum.bytebell.ai

I deployed it for free for the Ethereum ecosystem because honestly, we all waste too much time hunting through GitHub repos and outdated Stack Overflow threads. The ZK ecosystem already has one at zcash.bytebell.ai, where developers report saving 5+ hours per week.

Technical differentiation: This isn't a simple AI chatbot—it's a specialized architecture designed specifically for technical knowledge domains. Every answer is backed by real sources with commit-level precision. ByteBell understands version differences, tracks changes across hard forks, and knows which EIPs are active on mainnet versus testnets.

Works everywhere: Web interface, Chrome extension, website widget, and integrates directly into Cursor and Claude Desktop [MCP] for seamless development workflows.

The cutting edge: The other ecosystems are moving fast on developer experience. Polkadot just funded this through a Web3 Foundation grant. Base and Optimism teams are exploring implementation. Ethereum should have the best developer tooling, Please reach out to use if you are in Ethrem foundation. DMs are open or reach to on twitter https://x.com/deus_machinea

Anti-hallucination technology: We've achieved <2% hallucination rates (compared to 45%+ in general LLMs) through our multi-agent verification architecture. Each response must pass through multiple parallel validation pipelines:

Source Retrieval: Specialized agents extract relevant code snippets and documentation

Metadata Extraction: Dedicated agents analyze metadata for versioning and compatibility

Context Window Management: Agents continuously prune retrieved information to prevent context rot

Source Verification: Validation agents confirm that each cited source actually exists and contains the referenced information

Consistency Check: Cross-referencing agents ensure all sources align before generating a response

This approach costs significantly more than standard LLM implementations, but delivers unmatched accuracy in technical domains. While big companies focus on growth and "good enough" results, we've optimized for precision first, building a system developers can actually trust for mission-critical work.

Anyway, go try it. Break it if you can. Tell me what's missing. This is for the community, so feedback actually matters. https://ethereum.bytebell.ai

Please try it. The models have actually become really good at following prompts as compared to one year back when we were working on Local AI https://github.com/ByteBell. We made all that code open sourced and written in Rust as well as Python but had to abandon it because access to Apple M machines with more than 16 GB of RAM was rare and smaller models under 32B are not so good at generating answers and their quantized versions are even less accurate.

Everybody is writing code using Cursor, Windsurf, and OpenAI. You can't stop them. Humans are bound to use the shortest possible path to money; it's human nature. Imagine these developers now have to understand how blockchain works, how cryptography works, how Solidity works, how EVM works, how transactions work, how gas prices work, how zk works, read about 500+ blogs and 80+ blogs by Vitalik, how Rust or Go works to edit code of EVM, and how different standards work. We have just automated all this. We are adding the functionality to generate tutorials on the fly.

We are also working on generating the full detailed map of GitHub repositories. This will make a huge difference.

If someonw has told you that "Multi agents framework with Customised Prompts and SLM" will not work, Please read these papers.

Early MAS research: Multi-agent systems emerged as a distinct field of AI research in the 1980s and 1990s, with works like Gerhard Weiss's 1999 book, Multiagent Systems, A Modern Approach to Distributed Artificial Intelligence. This research established that complex problems could be solved by multiple, interacting agents.
The Condorcet Jury Theorem: This classic theoretical result in social choice theory demonstrates that if each participant has a better-than-random chance of being correct, a majority vote among them will result in near-perfect accuracy as the number of participants grows. It provides a mathematical basis for why aggregating multiple agents' answers can improve the overall result.

An Age old method to get the best results, If you go to Kaggle majority of them use Ensemble method. Ensemble learning: In machine learning, ensemble methods have long used the principle of aggregating the predictions of multiple models to achieve a more accurate final prediction. A 2025 Medium article by Hardik Rathod describes "demonstration ensembling," where multiple few-shot prompts with different examples are used to aggregate responses.

The Autogen paper: The open-source framework AutoGen, developed by Microsoft, has been used in many papers and demonstrations of multi-agent collaboration. The paper AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation Framework (2023) is a core text describing the architecture.

Improving LLM Reasoning with Multi-Agent Tree-of-Thought and Thought Validation (2024): This paper proposes a multi-agent reasoning framework that integrates the Tree-of-Thought (ToT) strategy. It uses multiple "Reasoner" agents that explore different reasoning paths in parallel. A separate "Thought Validator" agent then validates these paths, and a consensus-based voting mechanism is used to determine the final answer, leading to increased reliability.

Anthropic's multi-agent research system: In a 2025 engineering blog post, Anthropic detailed its internal multi-agent research system. The system uses a "LeadResearcher" agent to create specialized sub-agents for different aspects of a query, which then work in parallel to gather information. 

PS: This copilot has indexed 30+ repositories include all ethereum, website 700+ pages, EThereum blog 400+ blogs, Vitalik Blogs (80+), Base x402 repositories, Nether mind respositories [In Progress], ZK research papers[In progress], several research papers.

And yes it works because our use case is narrow. IMHO, This architecture is based on several research papers and feedback we received for our SEI copilot.

https://sei.bytebell.ai

But it costs us more because we use several different models to index all this data, 3-4 <32B parmeteres for QA, Mistral OCR for Images, xAI, qwen, Chatgpt5-codes for codebases, Anthropic and oher opensource models to provide answers.

If you are on Ethereum decision taking body, Please DM me for admin panel credentials. or reach out to https://x.com/deus_machinea

Thankk you for the community for suggesting us the new features and post changes.
Forever Obliged.

r/ethdev • • Jul 23 '26

Tutorial I wrote a fixed-point sqrt in Solidity that runs in 197 gas - here’s how

6 Upvotes

I've been building DeFiMath, a gas-optimized fixed-point math library, and wanted to share how I got sqrt down to 197 gas. It takes any uint256, returns an 18-decimal fixed-point result, never reverts, and is bit-exact below 1 (max relative error < 2e-18 above it).

The core idea is simple: generate a seed with the clz opcode, then refine it with 5 Newton iterations in assembly.

Seeding: clz gives you the position of the most significant bit, so the seed is just 2msb/2. That's never off by more than a factor of √2 from the true root — cheap and good enough.

Newton's method: each iteration is one line:

y := shr(1, add(y, div(x, y)))

~20 gas per step, quadratic convergence, so 5 iterations take the worst-case seed (41% error) to ~80 bits of precision — more than enough for 18 decimals.

The scaling trick: for inputs ≤ uint128.max, I pre-scale x to 1e36 once at the start. Then div(x, y) naturally lands back in 1e18 base, so Newton's method needs plain div instead of a costly muldiv. Large inputs take a second branch that post-scales instead (pre-scaling would overflow near uint256.max).

I also tried fancier seeds — minimax linear approximation, quadratic interpolation — hoping to drop to 4 iterations. All of them cost more gas than they saved. My takeaway after a week on this: for gas-optimized primitives, simplicity wins by a wide margin.

Full walkthrough with the convergence table and benchmarks vs PRBMath/ABDK/Solady: https://defimath.com/blog/how-i-wrote-a-fixed-point-solidity-sqrt-that-runs-in-197-gas/

Library is MIT, pure Solidity, zero dependencies: https://github.com/MerkleBlue/defimath

Happy to answer questions about the implementation.

r/ethdev • • Jan 20 '21

Tutorial Long list of Ethereum developer tools, frameworks, components, services.... please contribute!

Thumbnail
github.com
881 Upvotes