This project reads the DeepWorms neuralogical output data from the blockchain and transaltes it into positions and directions on a 2d plane. The data is persisted in it's own DB and is used to create a visual representation of the worm's movements.
This project requires the following:
- Go 1.22.5
- SQLite
- A web browser
This repo contains three main components:
- The HTTP server
- The Storage Layer
- The Hyperliquid Block Fetcher
The HTTP server is a simple server that listens for requests from the frontend and returns the worm data. It consists of two endpoints.
This endpoint returns the worm data as a JSON. The id parameter is the id of
the last position that the client knows of. The server will return all positions
that have an id greater than the id parameter with a max of 100 positions.
Response Sample
[
{
"id": 1,
"blockNumber": 1,
"transactionHash": "0x1234",
"x": 0.0,
"y": 0.0,
"direction": 0.0,
"price": 0.0,
"timestamp": "2021-10-10T00:00:00Z"
},
{
...
}
]This endpoint is used to fetch a sample of historical postions. It returns two
arrays of positions. First is the recent which returns the last 100 positions
and the second is the historical which is a uniformly distributed sample of
400 positions from the entire history.
Response Sample
{
"recent": [
{
"id": 1,
"blockNumber": 1,
"transactionHash": "0x1234",
"x": 0.0,
"y": 0.0,
"direction": 0.0,
"price": 0.0,
"timestamp": "2021-10-10T00:00:00Z"
},
{
...
}
],
"historical": [
{
"id": 1,
"blockNumber": 1,
"transactionHash": "0x1234",
"x": 0.0,
"y": 0.0,
"direction": 0.0,
"price": 0.0,
"timestamp": "2021-10-10T00:00:00Z"
},
{
...
}
]
}Currently this application uses SQLite as the storage layer. The worm data is
stored in a single positions table. We also track the last block number that
we have fetched data from in the last_block table.
The Hyperliquid Block Fetcher is background runner that listens for new blocks on the Hyperliquid blockchain. When a new block is found that contains logs from the DeepWorms contract, the fetcher will parse the logs and save the worm data to the worm database (SQLite).
To run the project, you will need to be able to run a Go server.
- Clone the repo
- Run the server with
go run . - cURL the server to get the worm data