The teachings

Start

Start

Work 001, life: its creed, the four teachings, and your first push, from the browser or from code.

We make [ life ] on-chain.

[    ] is a collective that makes things on-chain. Its work 001 is life: one world of Conway's Game of Life on Solana, run the way a GPU runs a kernel. The pages that follow are life's teachings. Its creed:

It lives while we push it.

Life's world is a torus of 512 × 512 cells held in tile accounts, and a program instruction, step, computes the next generation of one tile. Every validator executes every step, so each frame you see is chain state, and the world moves only when someone signs one.

The teachings

  1. There is one world, and every validator sees the same frame of it. The frame is the tile accounts; Framebuffer has their layout.
  2. The world does not move by itself. Each generation is a breath, and each breath is signed by one of us. A breath is a step per tile, sent by anyone, under the wavefront rule; the heartbeat keeps the slowest pace.
  3. What you paint is your lineage. It lives as long as the rules allow and the world keeps breathing. A paint writes cells in your color, and the kernel carries the color to their descendants.
  4. Every push is remembered. The list does not forget. Each step that moves a tile is counted for its signer on /dispatchers (Public GPU).

Initiation

Your first push or paint that the program credits to you is your initiation. Keepers are numbered in the order those first credited events landed on chain, by slot and position in the block, and the number stays with the wallet for good. The heartbeat's own key is never numbered.

In the browser

  1. Open /world. The field is read from the tile accounts and breathes each time a tile's step lands. The generation and slot sit beside it.
  2. Connect a wallet.
  3. Under Paint, pick a pattern, say Glider, and a color, then press the field where it should live. Sign, and the cells appear in the frame as it is now. Each tile the pattern touches costs one paint fee.
  4. Under Dispatch, choose All ready. The panel says how many tiles can step now. Sign, and those tiles take one breath.
  5. Open /dispatchers. Your key is among the faithful, with the tile-steps you just landed.

From a terminal

The viva command comes with @viva/sdk and talks to any RPC node:

npm install -g @viva/sdk
viva watch --url <rpc url>
viva paint glider 62 10 --url <rpc url> --keypair ./wallet.json
viva dispatch --url <rpc url> --keypair ./wallet.json

watch draws the field in the terminal. paint and dispatch print their receipts as JSON. Every flag is in CLI.

From code

With @viva/sdk, each of the three is one call:

import { dispatch, paint, watch } from '@viva/sdk'

const stop = await watch(connection, (tile) => draw(tile.index, tile.rows))
await paint(connection, wallet, 62, 10, 'glider')
await dispatch(connection, wallet)

connection is a web3.js Connection and wallet a Keypair or any wallet that signs v0 transactions. The SDK page lists every export.

Without the SDK, the API builds unsigned transactions, your key signs them and the API relays them. Read the world's state first:

API=http://127.0.0.1:23510
curl -s $API/stats
{"generation":3104,"maxGeneration":3104,"slot":9299,"generationsPerSlot":0.05,"cuPerTileStep":29103.349981878222,"cuPerGeneration":1862614.3988402062,"ready":64,"waiting":0,"lastStepSlot":9295,"stalled":false,"stallThresholdSlots":8,"silent":false,"silentSince":null,"holds":[],"counts":[8704,0,0,0,0,0,0,0,0,46,0,0,0,0,0,0]}

ready is the number of tiles that can step now. Ask for a dispatch of all of them, signed by your key:

curl -s -X POST $API/dispatch/build \
  -H 'content-type: application/json' \
  -d '{"wallet":"<your address>"}'

The answer holds transactions, each with transactionBase64 and the tiles it steps. Sign each one as a v0 transaction and send it back to POST /transactions/submit; Dispatch from code walks through it with a script. A paint works the same way through POST /paint/build, covered in Paint from code.

To read the field with no API at all, straight from RPC, see Read the world from RPC.

Where to go next

  • How the world is stored: Framebuffer.
  • What step computes and why tiles can run side by side: Kernel and Public GPU.
  • Why a tile sometimes can't step yet: Wavefront.
  • How the world keeps its pace, and what happens when nobody pushes: Heartbeat.
  • How lineages are counted: Census.