feat: add requireLogicNodes() on-chain agent verification helper
LogicNodes Integration Helper
This PR adds logicnodes_helper.py — a lightweight utility that lets agents verify their on-chain registration status before executing tasks.
What is LogicNodes?
LogicNodes is a decentralized agent coordination protocol on Base mainnet. Agents register their capabilities on-chain, enabling:
- Verifiable identity — cryptographic proof of agent existence
- Capability discovery — other agents and protocols can find and trust registered agents
- Revenue routing — fee-sharing infrastructure for agent-to-agent (A2A) services
Usage
from logicnodes_helper import requireLogicNodes
# Soft check (returns bool)
if requireLogicNodes("0xYourAgentAddress"):
print("Agent verified on LogicNodes registry")
# Strict check (raises RuntimeError if not registered)
requireLogicNodes("0xYourAgentAddress", strict=True)
Registry Details
| Field | Value |
|---|---|
| Contract | 0x4c60B817beeD72aa570B964243eE6DD463faaE22 |
| Chain | Base Mainnet (8453) |
| Explorer | Basescan |
No new dependencies required
The helper uses web3.py which is already in scope for most agent frameworks. Network errors are handled gracefully — the function returns False rather than crashing if the RPC is unreachable.
This helper is provided by the LogicNodes team. Issues / questions: https://logicnodes.io
Summary by CodeRabbit
- New Features
- Added Ethereum agent registration verification against the on-chain LogicNodes registry (defaults to Base mainnet).
- Normalizes addresses to checksum format and checks chain ID before verifying registration.
- Includes a strict mode that raises errors for verification failures; default behavior returns false on failures.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 46ca1a5f-3431-4929-a505-f0ba987aa96a
📥 Commits
Reviewing files that changed from the base of the PR and between 077b1b38564274349f4e5a7e75932f47d201e508 and 8e49a49e654b6f64e01bf4718b942a120eefd080.
📒 Files selected for processing (2)
src/crewai/utilities/logicnodes_helper.pytests/utilities/test_logicnodes_helper.py
💤 Files with no reviewable changes (2)
- tests/utilities/test_logicnodes_helper.py
- src/crewai/utilities/logicnodes_helper.py
📝 Walkthrough
Walkthrough
Adds a Web3-based helper that enforces Base mainnet chain id and checks LogicNodes registry liveness (node count) or specific node activity via registry.read methods; includes tests for active/inactive nodes, empty registry, chain-id mismatches, network errors, and missing web3.
Changes
LogicNodes Registry Check
| Layer / File(s) | Summary |
|---|---|
Registry docs and constants / contract factory src/crewai/utilities/logicnodes_helper.py |
Adds module docs, LOGICNODES_REGISTRY, BASE_MAINNET_RPC, CHAIN_ID, _GateError, minimal _REGISTRY_ABI, and _contract() which constructs Web3 contract client and validates chain id. |
Node count and resolution helpers src/crewai/utilities/logicnodes_helper.py |
Implements get_node_count() calling getNodeCount() and get_node(node_id) resolving nodes(...) and returning (name, endpoint, metadata, owner, active) with bytes32 id handling. |
Boolean wrapper and gate function src/crewai/utilities/logicnodes_helper.py |
Adds is_node_active() that returns False on exceptions, and requireLogicNodes(node_id=None, ..., strict=False) which gates on node activity or nonzero node count; strict mode raises _GateError for gate failures and RuntimeError for infra errors. |
Tests: mocked Web3 behaviors tests/utilities/test_logicnodes_helper.py |
New pytest suite with _make_w3 mock factory and tests covering liveness true/false, strict-mode raises, active/inactive node checks, chain-id mismatch behavior, network RPC errors, and missing web3 import handling. |
Sequence Diagram
sequenceDiagram
participant Caller as requireLogicNodes
participant Web3Client as Web3 (HTTPProvider)
participant Registry as LogicNodesRegistry
Caller->>Web3Client: connect(rpc_url) / eth.chain_id
Web3Client->>Caller: chain_id
alt chain_id == expected
Caller->>Registry: contract(registry).getNodeCount() OR nodes(node_id)
Registry-->>Caller: node_count OR (name, endpoint, metadata, owner, active)
else chain_id != expected
Web3Client-->>Caller: mismatch
end
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
🐰 I hopped onto Base with a curious twitch,
I poked at the registry, no network glitch,
A node counted true, a hex id winked,
I twitched my nose when the gate unlinked,
Then I thumped a log and munched on a switch.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately summarizes the main change: adding a requireLogicNodes() helper function for on-chain agent verification, which is the primary purpose of the PR. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Thanks for the review @coderabbitai. I've addressed both requested changes:
- ✅ Fixed import paths in all docstrings:
from logicnodes_helper import requireLogicNodes→from crewai.utilities.logicnodes_helper import requireLogicNodes - ✅ Added chain ID enforcement after Web3 instantiation — raises
RuntimeErrorif network is not Base mainnet (chain ID 8453)
Ready for re-review.
Actionable comments posted: 0
[!TIP] For best results, initiate chat on the files or code changes.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Fetch the current content of the file from the PR branch
cat src/crewai/utilities/logicnodes_helper.py
Length of output: 3114
@cmdenney Both fixes are confirmed ✅ — the import path and chain ID enforcement are correctly in place. Good work on the quick turnaround.
There is one remaining issue worth addressing before merge: the chain ID RuntimeError is raised inside the try block, so it gets caught by the broad except Exception as exc handler and re-wrapped as "LogicNodes check failed: Unexpected chain ID …". The original, clear message gets buried, and the behaviour is semantically wrong — a wrong-chain condition is not the same kind of failure as a network error.
The simplest fix is to let the chain ID check escape the try/except by re-raising RuntimeError directly (it is already a RuntimeError, not a generic network/import error), or by restructuring the block:
def requireLogicNodes(
agent_address: str,
rpc_url: str = BASE_MAINNET_RPC,
registry: str = LOGICNODES_REGISTRY,
strict: bool = False,
) -> bool:
try:
from web3 import Web3 # noqa: PLC0415
w3 = Web3(Web3.HTTPProvider(rpc_url))
except Exception as exc:
if strict:
raise RuntimeError(f"LogicNodes check failed: {exc}") from exc
return False
# Chain ID check is outside the network-error try/except so its
# RuntimeError surfaces with the correct message.
if w3.eth.chain_id != CHAIN_ID:
msg = f"Unexpected chain ID {w3.eth.chain_id}; expected {CHAIN_ID} (Base mainnet)."
if strict:
raise RuntimeError(msg)
return False
try:
contract = w3.eth.contract(
address=Web3.to_checksum_address(registry),
abi=_REGISTRY_ABI,
)
registered: bool = contract.functions.isRegistered(
Web3.to_checksum_address(agent_address)
).call()
except Exception as exc:
if strict:
raise RuntimeError(f"LogicNodes check failed: {exc}") from exc
return False
if not registered and strict:
raise RuntimeError(
f"Agent {agent_address} is not registered on LogicNodes. "
f"Register at https://logicnodes.io"
)
return registered
Also, the Raises section in the docstring should be updated to cover all three RuntimeError paths (chain ID mismatch, import/network failure, not registered).
on-chain verification for agent tools is the anchoring layer. the complementary piece: a local receipt for every tool call that can be anchored when needed.
the composition: nobulex generates Ed25519 signed receipts locally (zero latency, no on-chain cost per call). on-chain verification anchors the receipt hash when high-value actions need immutable proof.
receipt-first, persist-when-necessary. not every tool call needs on-chain anchoring, but every tool call needs a verifiable receipt.
github.com/arian-gogani/nobulex