We tried to sell brainwaves on a blockchain in eight weeks. Here is what the data layer needed.
In the autumn of 2024 a team of four of us built Brainwave Marketplace for the [REDACTED] Hackathon (yes, that is its real name), an online NEAR Protocol event that ran from 5 September to 31 October 2024 under the theme of a user-owned internet (Devpost). The idea: you wear a consumer EEG headset, you record a session, and you sell that recording to researchers on your own terms, with the sale settled on chain.
I started the project and owned the data path: capture, hashing, the IPFS uploader and the earlier proof-of-concept that minted a token from a recording. Teammates built most of the final marketplace interface. We submitted on the last day (project page), and the project did not win a prize.
This post is the review I would write for a client. It says what worked, what was a mock, and what the data layer needs before anyone should trust it with a single recording. Hackathon code is allowed to be rough. The useful part is knowing exactly where.
The device and the data
We built on the Neurosity Crown. Per Neurosity's documentation, it records 8 channels at 256 Hz and streams them in epochs of 16 samples (about 62.5 ms each). It offers two raw streams:
raw, with a 50/60 Hz notch filter and a 2–45 Hz bandpass applied on the device.rawUnfiltered, with no filtering at all.
That is 2,048 samples a second, or about 61,000 samples in a 30-second session. It is a small amount of data per person and a lot across many people. Remember the two streams. They come back later as a provenance bug.
What we built, in three steps
The project grew in three steps over the summer.
1. Toy apps (June). Two small apps on Neurosity's starter kits: a ball that moves with the device's focus score, and one that hops when the headset detects an imagined foot movement. They taught us the SDK. They taught us nothing about data.
2. A "proof of humanity" prototype (August). A Node service that captured 30 seconds of EEG, wrote it to CSV, took a SHA-256 hash of the file and minted an ERC-721 token on Polygon whose metadata was that hash. This part worked end to end.
3. The marketplace (October). A Next.js front end with NEAR wallet connection, a Python service that pinned recordings to IPFS through Pinata, and a listing and purchase flow.
The architecture we designed looked like this:
Crown (8 ch @ 256 Hz)
│ 16-sample epochs
▼
SDK capture ──► 30 s buffer ──► CSV ──► SHA-256 ──► NFT on Polygon (worked)
│
├──► FFT features ──► JSON blob ──► IPFS pin (CID) (partly wired)
│ │
│ ▼
│ NEAR contract: CID + metadata (never written)
▼
Next.js marketplace ──► buy for 0.25 NEAR (testnet) (mock listings)
What was real and what was a mock
Honest accounting, from rereading the code two years later:
| Part | State |
|---|---|
| Capture 30 s of EEG, hash it, mint a token with the hash | Worked |
| NEAR wallet connection in the front end | Worked |
| Pin a recording to IPFS | Written, but the service had bugs that would stop it at run time |
| "Connect Neurosity" in the marketplace | A mock: it checked that the form fields were not empty |
| Listings | Stored in the browser's local storage |
| Price | A constant, 0.25 NEAR, for every recording |
| The NEAR contract that records listings | Called by the front end, never written |
| A failed purchase | Showed "Purchase successful!" |
None of this is unusual for a hackathon. The last row is the one I would point at in a code review. An error path that reports success is worse than a missing feature, because it hides the problem from everyone who uses the system.
Seven things the data layer got wrong, or right
1. Hash on chain, data off chain: right
The best decision in the project came early. The prototype put only a hash on chain, never the recording. Chains are public, permanent and expensive per byte. A hash proves that a specific file existed at a specific time, and the file can live somewhere you control.
The marketplace kept the idea but weakened it: it pinned the recording to IPFS without encryption. IPFS is public. A recording pinned in clear text has been published, not sold. Any buyer, or anyone else, can fetch it by its content ID.
2. Encryption without key custody is not encryption
The prototype encrypted the CSV with AES-256, and then wrote the key into the same file as the ciphertext. That protects nothing.
The real design question is key custody: who holds the key, and when do they get it. For a data marketplace the minimum is a key per recording, held by the seller's side, and released to a buyer only after the payment settles and the buyer's use is recorded. The chain can record the sale. It cannot hold the secret.
3. "Proof of humanity" proved less than it claimed
Hashing 30 seconds of EEG proves that some bytes existed. It does not prove that a living person made them, or which person. There was no liveness check, no signal-quality gate, and no attestation that the bytes came from a real device. The prototype also minted every token to the same wallet.
If you want a recording to stand as proof of anything, the proof has to cover the capture itself: a signed reading from the device, a quality check, and a link to a consenting person that does not reveal who they are.
4. Write the schema before the feature code
The feature code passed an FFT size where it needed the sample rate, and treated each 8 × 16 epoch as if it were one signal. Both mistakes come from the same cause: no one wrote the schema first.
For EEG, the schema is not optional. It is what makes a recording usable by someone else:
| Field | Why a buyer needs it |
|---|---|
| Sample rate, channel count, channel montage | To read the signal at all |
Units and filter state (raw or rawUnfiltered) | To know what was already removed |
| Device model and firmware | To compare across recordings |
| Start time and duration | To align with labels |
| Task label (resting, focus, meditation) | It is what makes a recording worth paying for |
| Quality flags per epoch, with gaps kept explicit | To filter bad data before analysis |
| Consent scope and expiry | To know what the buyer may do |
5. Filter state is provenance
The prototype captured the filtered raw stream. The marketplace design used rawUnfiltered. Neither recorded which one a file contained. A researcher who buys a recording must know whether a 2–45 Hz bandpass has already been applied, because it changes every analysis downstream. This is the EEG version of a pipeline that does not record which transform produced a table: the numbers look fine and mean something different.
6. A flat price ignores everything that makes data valuable
Every listing cost 0.25 NEAR. In a real marketplace, price is where the data work shows: duration, channel count, signal quality, labels, and the scope of consent. A labelled, clean, 20-minute session with broad research consent is worth far more than 30 unlabelled seconds with motion artefacts. You cannot price what you do not measure, so pricing depends on points 4 and 5.
7. The documents promised more than the code
Our whitepaper said the platform met health and privacy regulations "by anonymizing the data". Nothing in the code anonymized anything. This is the lesson I take most seriously, because it is the one that turns a rough prototype into a liability. A claim of compliance has to point at a control in the code, or it should not be written.
Neural data became regulated while we built
The legal ground moved during the project. Colorado's HB24-1058, signed in April 2024 and in effect from August 2024, added biological data, including neural data, to the "sensitive data" in the Colorado Privacy Act. California followed in September 2024 with SB 1223, which added neural data to the CCPA's sensitive personal information (Hunton summary).
I am not a lawyer, and this is not legal advice. The engineering consequence is clear anyway: consent is data. It needs a scope, a purpose, an expiry and a way to revoke it, and it must travel with the recording. That is also where blockchains bite. A token transfer can record that consent was given. Nothing on chain can revoke a file that was pinned to a public network.
The architecture I would build now
device ──► signed capture (device key) ──► quality gate ──► Parquet per session
│
manifest: schema, filter state, labels,
quality, consent scope + expiry, file hash
│
encrypted object store (key per session) ◄───┤
▼
chain: manifest hash, listing, sale record
│
buyer pays ──► key service checks consent + payment ──► releases key
consent revoked ──► key service stops releasing; object deleted
What changes, in order of importance:
- Recordings are encrypted at rest with a key per session, in storage the platform controls. Nothing sensitive is ever pinned in clear text.
- A manifest describes each recording: schema, filter state, labels, quality and consent. The chain holds the manifest's hash, not the data.
- A key service releases keys only when payment and consent both check out. Revoking consent stops new releases and deletes the object.
- A quality gate runs before listing. Bad epochs are flagged, and recordings below a threshold are not sold.
- Price is a function of the manifest, not a constant.
- Columnar storage (Parquet), not JSON in CSV cells, so a buyer can read one channel or one time range without downloading everything.
None of this is exotic. It is the same thing a regulated data platform at a health or finance company needs: provenance, access control tied to purpose, and an audit trail. The chain is the least interesting part of it.
What I took from it
- Put hashes on chain and keep data off it. Then encrypt the data, because "off chain" is not "private".
- Key custody is the design. Encryption without it is decoration.
- Write the schema before the feature code, and make filter state part of it.
- An error path that reports success is the worst bug in a demo.
- Consent is a column with an expiry, not a checkbox.
- Do not write a compliance claim that no control in the code backs up.
If you are building a platform that holds sensitive data, whether it is neural data, health claims or trades, these are the questions I would start with. Book a call and we can go through yours.