The Walnut App

A fun mini-game that shows all of Seismic's privacy features in action.

The Idea

The Walnut App is Seismic's official tutorial — a simple game that teaches you the key concepts:

  1. A secret number (the kernel) is hidden inside a walnut (the shell)
  2. Players shake the walnut to change the hidden number — this is a private write (the number stays hidden)
  3. Players hit the walnut to crack the shell — this is a normal action
  4. Once cracked, contributors can look inside — this requires proving your identity (signed read)

One simple game, three key Seismic concepts. Let's see how it works.

The Code (Simplified)

contract Walnut {
    suint256 kernel;     // The hidden number (shielded — nobody can see it)
    uint256  shell;      // Shell strength (public — everyone can see)
    mapping(address => bool) contributors;

    // Shake: change the hidden number (private write)
    function shake(suint256 value) external {
        kernel += value;
        contributors[msg.sender] = true;
    }

    // Hit: reduce the shell (public action)
    function hit() external {
        require(shell > 0, "Already cracked");
        shell -= 1;
        contributors[msg.sender] = true;
    }

    // Look: see the hidden number (needs signed read)
    function look() external view returns (uint256) {
        require(shell == 0, "Not cracked yet");
        require(contributors[msg.sender], "You didn't contribute");
        return uint256(kernel);
    }
}

Notice how suint256 makes the kernel invisible, and look() checks that you actually contributed before revealing anything. Simple but powerful.

Try It Yourself

Want to try it? Here's how:

  1. Test it locally:
sforge test --via-ir
  1. Deploy to testnet:
sforge create --rpc-url https://gcp-2.seismictest.net/rpc   --private-key YOUR_KEY   src/Walnut.sol:Walnut --via-ir

Then build a frontend with seismic-viem to let people shake, hit, and look at your walnut!

This is the best way to get hands-on with Seismic's privacy features.

Quiz — Test Your Knowledge

4 questions — 25 points each — 100 points max