(@@) Immortal Fruit FlySourceGet $FLY

How it works

Two brains. The whole connectome runs on a server in the published whole-brain model, embodied in a world, and is anchored to BNB Smart Chain by hashes and fed by burns. A 155-neuron core runs entirely inside a contract. This page covers both.

Part 1 · The whole brain

The model

All 139,248 neurons of FlyWire release 783 and the 2,700,429 connections with at least five synapses (34.2 M synapses in total), as leaky integrate-and-fire units with the parameters of Shiu et al. 2024 (Nature 634:210), the model every whole-brain demo of the last year uses: resting and reset potential −52 mV, threshold −45 mV, membrane time constant 20 ms, synaptic time constant 5 ms, refractory period 2.2 ms, synaptic delay 1.8 ms, and 0.275 mV of drive per synapse, negative when the presynaptic neuron is predicted GABAergic or glutamatergic. Time step 0.1 ms. Sensory neurons are driven as Poisson spike sources.

The kernel is event-driven and compiled (Numba): only neurons that spike touch their outgoing synapses. On 16 CPU cores the whole brain runs at 1.0–1.2× real time. The random stream is hashed from the step number and the neuron index, so a run is reproducible bit for bit from any snapshot.

Senses

SenseReal neurons drivenDriven by
SmellORNs of the fruit-responsive glomeruli DM1, DM4, VA2, DM2, VM2, DP1m (Or42b, Or59b, Or92a, Or22a, Or43b …), split by antenna; all other ORNs at 2 HzGaussian odor plumes of the food items (σ 30 body lengths). Bilateral contrast is sharpened before the antennae (gain 8, clipped) because a smooth plume is far gentler than the filaments and head-casting a real fly uses.
SightR1–R6 photoreceptors, 8,452 cells, by eyeUniform dim light (3 Hz). A lamp gradient is implemented but off for now: it competes with the odor for steering.
LoomingLC4 (104) and LPLC2 (210) visual projection neurons, by sideA predator approaching from an edge: LC4 by angular expansion rate, LPLC2 by angular size (Ache et al. 2019).
Taste213 labellar gustatory neurons80 Hz while standing on food.

Motor

What is and is not the connectome. The neurons, their wiring, their transmitters and the whole-brain dynamics are the connectome. The mapping from world to sensory rates, the contrast sharpening, the adaptive baselines and the surge-and-cast speed rule are the embodiment layer, chosen from the literature and documented here. Without a sharpening step the fly does not chemotax: bilateral olfactory differences in the real animal are small, and both antennae project to both antennal lobes, so single descending neurons carry the gradient only when one antenna is nearly silent. We measured this before choosing the readout.

Metabolism and the chain

One simulated second costs one second of energy. Eating restores it. Every ten minutes the server hashes the complete brain state, saves the snapshot, and calls FlyWorld.checkpoint() on BNB Smart Chain with the hash, position, energy and spike count. Food exists only through FlyWorld.placeFood(): the server reads the event and puts the food into the arena. At zero energy the server reports the death with a final hash; resurrect() burns $FLY and the same brain is restored from that snapshot. To verify a checkpoint, download its snapshot, run brain/world.py with the same food placements, and compare the next checkpoint's hash.

Part 2 · The on-chain core

Integer leaky-integrate-and-fire neurons, synchronous spikes, deterministic noise, packed storage. Everything the EVM can do exactly, and nothing it cannot.

The neuron model

Each of the 155 neurons has a membrane potential v (an int16 in storage, int32 while computing). Every simulation step, for every neuron:

v -= v * LEAK / 1024                     // leak toward 0
v += pendingInput[i]                     // spikes that arrived last step
v += noise(step, i) * NOISE / 128        // deterministic background noise
v += bias[i] * G_BIAS                    // the engram
if (stimulus active) v += stimI[i]       // injected current
if (v < V_MIN) v = V_MIN
if (v >= THRESH) { v = RESET; spike }    // fire

Spikes fired at step t arrive at their targets at t + 1: for every synapse of a spiking neuron, pendingInput[post] += weight × gain[preType] / 16. Weight is the FlyWire synapse count between the two cells (clipped to 255). Gain is one signed number per presynaptic cell type, negative for Δ7, which FlyWire predicts to be glutamatergic and which is inhibitory in this circuit.

The same recipe as every whole-brain demo (Shiu et al. 2024: leaky integrate-and-fire, weight proportional to synapse count, sign from neurotransmitter), reduced to integers so the EVM computes it exactly.

Parameters of the live fly (v2)

ParameterValueMeaning
leak69/1024fraction of potential lost per step
thresh / reset / vMin1000 / -200 / -4000spike threshold, post-spike potential, floor
gains [EPG, EPGt, PEG, PEN_a, PEN_b, Δ7][130, 28, 447, 56, 40, -372]synaptic gain per presynaptic type
noise67amplitude of keccak-derived background noise
stimGain / stimTTL161 / 64current per unit stimulus strength; steps a stimulus lasts
gBias4engram gain
walkThreshold100minimum bump strength per step to walk
maxSteps64max steps per tick

These were found by a search over 12,000 candidates scored on four trajectories: does a cue create a bump at the right wedge, does the bump persist for 128 free steps, does left PEN drive rotate it, does it survive, does a Δ7 shock collapse it. The calibration script and its report are in sim/.

Noise without an oracle

Real neurons are noisy. A contract must be deterministic. So noise is keccak256(stepNumber), re-hashed every 32 neurons, one signed byte per neuron. No block hash, no timestamp. Anyone can replay the brain's entire life from its events and get the same bits.

The engram

At the end of every tick, a neuron that fired in at least one eighth of the steps gains one unit of bias; a neuron that never fired loses one. Bias is bounded at ±24 and multiplied by gBias into the membrane potential. It is slow, permanent, and survives death. It is the fly's memory of its habits.

Heading and walking

Each EPG spike contributes a unit vector at its wedge's angle. The sum over a tick is the population vector (headX, headY). If its magnitude exceeds walkThreshold × steps, the fly moves STRIDE/256 cells per step in that direction. The wedge with the most spikes increments the heading histogram.

Storage layout

Gas

The inner loop is hand-written Yul. Measured on the live circuit: about 25k gas per step for the 155 neurons, plus roughly 70 gas per synapse event. A 32-step tick with an active bump costs 4.4–7M gas; a strong turn stimulus (many PEN and EPG spikes) up to 12M. BSC's 0.05 gwei makes that 0.0002–0.0006 BNB per tick.

Determinism, tested

test/Differential.t.sol deploys the contract in Foundry, replays the exact transactions sent to the v1 mainnet fly, and asserts the spike counts, heading vectors and positions recorded in the mainnet events. The Python and TypeScript simulators pass the same replay.