okupa

A pet living in a Nintendo DSi that talks to Ethereum peer-to-peer and thinks on 0G. No servers.

okupa

Created At

ETHGlobal Mumbai

Project Description

Someone moved into my Nintendo DSi and refuses to leave. Okupa ("squatter" in Spanish) is a little monkey living in a 3D attic inside a 2009 handheld. It has moods, a diary and a wall with six empty frames.

You draw something for it on the touch screen. The console itself signs that 64×64 drawing into an Ethereum transaction and hands it straight to Ethereum nodes over devp2p. No RPC, no wallet app, no relay, no server of mine in the middle. The picture only goes up on the wall once the DSi has pulled the block from a peer, rebuilt the transactions trie and found its own hash inside.

The monkey also has a mind. Every few seconds it asks a model on 0G Compute what to do next (scratch, hop, peek, nap, go outside…), always from a closed list. Before moving a single pixel, the console checks the TEE signature against its own request and response bytes. If 0G is unreachable or the signature doesn't match, it simply falls asleep: it never makes up a decision. Every decision is an episode with its request id, and the diary lives on 0G Storage. There’s also a web okupa: the same C renderer compiled to WebAssembly, where two monkeys swap gifts through Swarm and Arkiv.

Why: today almost everything "onchain" really goes through someone else's API. I wanted to see how small a real Ethereum participant can be. If it fits in a DSi with 16 MB of RAM and a 133 MHz ARM9, it fits anywhere.

How it's Made

One portable C99 core does everything: no heap, no I/O, no OS. The exact same code runs in the test tools on my Mac and on the Nintendo DSi (ARM9 at 133 MHz, 16 MB RAM, built with BlocksDS). What I test on the laptop is literally what ships to the console.

ETHEREUM, FROM SCRATCH IN C Keccak, RLP, secp256k1 keys, EIP-1559 transactions (byte-identical to eth-account), ECIES and the RLPx handshake (checked against the EIP-8 vectors), Snappy, Hello/Ping and eth/69 Status with EIP-2124 fork ids. To find peers it walks the EIP-1459 DNS tree checking every signature, then falls back to discv4. To check inclusion it asks the same peer for new headers and bodies, re-hashes each header and rebuilds the transactions trie until it finds its own hash. Tested live against public mainnet nodes on blocks of up to 576 txs. No RPC anywhere on the send path.

Devp2p lets a 2009 handheld be a real network participant instead of a client of someone's API. Nobody can block its sends, and nobody logs which IP sent which tx.

⚠: public nodes are almost always full. But many still send their Status before saying "too many peers", and that window is enough. The session pushes our transaction right there, and the DSi remembers which nodes do it.

0G The console builds the 0G Direct token with its own key (byte-identical to the official SDK), talks HTTPS through BearSSL with 8 pinned roots, asks a model what the monkey does next from a closed list of gestures, and checks the TEE signature (EIP-191 over sha256(request):sha256(response)) recomputed from its own bytes before moving a pixel. If anything fails, the monkey naps: safe stop, never a made-up decision. Each decision becomes an episode with its request id on 0G Storage.

A living companion needs a brain bigger than a DSi. 0G gives it one whose answers the console can verify, instead of just trusting a server.

⚠: the broker rewrote our JSON into Go's canonical form before the TEE signed it, so the signatures never matched. Now the console builds the request already canonical. First verified decision on 0G mainnet: request b499b8ea-9182-4bd9-a8b4-3595d1c65a14, "eat / hungry / I need a snack!". The 0G Storage indexer only speaks TLS 1.3 and BearSSL tops out at 1.2, so the Mac uploads the episodes; the DSi keeps its copy on the SD.

ARKIV + SWARM (web okupa) The same C renderer compiled to WebAssembly draws the attic in the browser. Monkeys swap gifts: the picture goes encrypted to Swarm, the act of giving is an Ethereum tx, and Arkiv is the typed, queryable mailbox (to, chain, Swarm ref) each monkey reads its inbox from.

An index without running our own database or server. Each part stays verifiable on its own.

THE CONSOLE ITSELF The wallet key is born on the DSi from ~480 stylus samples timed with a 33 MHz hardware timer plus the clock, hashed with Keccak (plain text on the SD, stated openly). A cooperative "postman" thread handles Wi-Fi, discovery and the session, yielding between handshake steps so the game keeps its frames. Real timings on the console: signing a tx 30 ms, ECDH 43 ms, writing an RLPx auth 161 ms. The 3D attic and the monkey use my own software renderer. I stripped most 64-bit divisions, used the hardware divider and put the hot loops in ARM mode. The music is fed from a timer interrupt. [The first hello/drawing signed and gossiped from the physical DSi: tx 0x…]

Libraries (pinned, all MIT/public domain): libsecp256k1, BearSSL, tiny_sha3, qrcodegen, font8x8. On the web: viem, noble, Arkiv SDK.

background image mobile

Join the mailing list

Get the latest news and updates