Why
Two questions this catalogue has not asked yet. First, the operational one: every agent demo here hand-rolls the dullest and most failure-prone part of on-chain work — nonce management, gas strategy, retries — and OpenZeppelin Relayer is that exact layer, extracted and hardened. Second, and larger: Defender was a managed SaaS that stopped taking sign-ups in June 2025 and shut down on 2026-07-01, handing its functionality to open source on the way out. That makes it a case study in a criterion missing from most infrastructure decisions — not "what does it do" or "what does it cost", but "what remains when the vendor leaves". Defender left well: a year's notice, a migration guide, a production-ready open-source successor. Most vendors will not.
How it works
Relayer keeps the plumbing: it accepts a transaction over a REST API, signs it, and owns nonce sequencing, gas pricing, and retry — EVM multi-chain plus Solana and Stellar, with keys in HashiCorp Vault or AWS KMS rather than an env var. Monitor watches the other direction: declarative JSON rules over events, function calls, and transaction patterns, firing Slack or webhook alerts. The concrete scenario is verex, which already wrote this by hand. Its ChainJob worker executes strictly serially, and its own header explains why: “all txs are sent by the operator or a server-held demo key, so a single lane doubles as nonce management.” Around that sit exponential backoff (5s → 25s → 125s), an atomic PENDING→RUNNING claim, and stuck-job recovery after two minutes — a small relayer, built to make settlement work at all. Adopting the real one deletes the nonce lane, the gas strategy, and the retry ladder, but not onFailed: reversing DB fills after a terminal failure is business logic wearing plumbing's clothes, and no relayer can know that a failed SETTLE_MATCH means two users' balances must be un-credited. The interesting question is the third one. The single lane was serializing business logic as a side effect, not just nonces; widen it and you find out whether that mattered — and this codebase has already produced one bug of exactly that family, a ladder sized from a pre-settlement balanceOf. Monitor addresses the mirror image: that bug was invisible off-chain until it produced a wrong quote, while on-chain it was observable the entire time.
Related code
"""OpenZeppelin Relayer PoC -- nonce-managed transaction queue.
Illustrates the core mechanism: the relayer assigns strictly increasing nonces, retries
failed sends with backoff, and never re-uses a nonce even across retries/failures.
"""
from dataclasses import dataclass, field
@dataclass
class TxRequest:
id: str
payload: str
should_fail_times: int = 0 # simulate transient failures before success
@dataclass
class Relayer:
next_nonce: int = 0
sent: list[tuple[int, str]] = field(default_factory=list) # (nonce, tx id)
def submit(self, req: TxRequest) -> None:
nonce = self.next_nonce
self.next_nonce += 1 # nonce is consumed here, permanently -- never reused
attempts = 0
backoff = [5, 25, 125]
while True:
attempts += 1
ok = attempts > req.should_fail_times
print(f" nonce={nonce} tx={req.id} attempt={attempts} -> {'CONFIRMED' if ok else 'fails, retry'}")
if ok:
self.sent.append((nonce, req.id))
return
if attempts > len(backoff):
print(f" nonce={nonce} tx={req.id} -> exhausted retries, giving up (nonce still not reused)")
self.sent.append((nonce, f"{req.id} (FAILED)"))
return
print(f" backing off {backoff[attempts - 1]}s before retry")
if __name__ == "__main__":
relayer = Relayer()
queue = [
TxRequest("settle-match-1", "transfer(A,B,10)", should_fail_times=0),
TxRequest("settle-match-2", "transfer(C,D,5)", should_fail_times=2),
TxRequest("settle-match-3", "transfer(E,F,7)", should_fail_times=0),
]
print("processing queue, one lane, strictly increasing nonces:")
for req in queue:
relayer.submit(req)
print("\nfinal nonce -> tx mapping (no nonce ever reused):")
for nonce, tx_id in relayer.sent:
print(f" nonce {nonce}: {tx_id}")
Where it lands in Jayverse
- Verex: evaluate adopting OpenZeppelin Relayer for ChainJob's nonce/gas lane. Relayer would delete the hand-rolled nonce sequencing, gas pricing, and retry ladder in ChainJob, but the onFailed DB-reversal logic has to stay, since no relayer can know a failed SETTLE_MATCH means two balances must be un-credited.
- Verex: test whether widening ChainJob's single serial lane breaks business-logic ordering. The lane was quietly serializing more than nonces; before parallelizing it, check for another balanceOf-timing bug like the one already found in the settlement ladder.
- Auditor/gitboard: add Monitor-style on-chain alerting as a vendor-independence check. OpenZeppelin Defender shutting down with a working open-source successor is the "what remains when the vendor leaves" test — apply it to any other managed service Jayverse depends on.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| plumbing | (비유) 배관·기반 배선 작업 · 눈에 안 띄지만 꼭 필요한 인프라성 작업을 가리킬 때. "Self-hosted transaction plumbing and on-chain alerting" |
| hand-roll | 직접 손으로 만들다·자체 구현하다 · 기성 도구 대신 처음부터 스스로 만드는 것. "every agent demo here hand-rolls the dullest" |
| extracted and hardened | (기존 코드에서) 뽑아내어 견고하게 다듬은 · 사내 코드였던 것을 독립적이고 튼튼한 모듈로 분리한 상태. "that exact layer, extracted and hardened" |
| wearing ...'s clothes | ~인 척하는·~의 탈을 쓴 · 겉보기엔 배관(인프라)이지만 실제론 비즈니스 로직인 것을 비유. "business logic wearing plumbing's clothes" |
| doubles as | ~의 역할도 겸하다 · 하나의 장치가 원래 목적 외에 다른 기능도 대신할 때. "a single lane doubles as nonce management" |
| un-credit | (지급된 것을) 취소해 되돌리다·차감 처리하다 · 실패한 거래 때문에 이미 준 잔액을 되돌려야 할 때. "two users' balances must be un-credited" |
| sized from | ~을 기준으로 크기가 정해진 · 어떤 값이 특정 데이터를 근거로 산정되었을 때. "a ladder sized from a pre-settlement balanceOf" |
| what remains when the vendor leaves | 공급업체가 떠난 뒤 남는 것 · 서비스 종료 후에도 살아남는 자산이 무엇인지 따지는 기준. "what remains when the vendor leaves" |
| HashiCorp Vault | 하시코프 볼트 · 비밀키·시크릿을 안전하게 보관하는 대표적 키 관리 소프트웨어. "keys in HashiCorp Vault or AWS KMS" |
| KMS | 키 관리 서비스(Key Management Service) · AWS가 제공하는 암호화 키 관리 서비스, env var 대신 키를 보관하는 방식으로 언급. "or AWS KMS rather than an env var" |
| Defender | OpenZeppelin Defender · 2026년 7월 종료된 OpenZeppelin의 관리형 온체인 운영 서비스, Relayer/Monitor의 전신. "Defender was a managed SaaS that stopped taking sign-ups" |
← All Knowledge Notes · Workspace Index · Top ↑ · Open on jaylabs.xyz →