How it works

Architecture

Which part does what, and how a payment moves between the browser, Sui and the server.

On this page

The parts#

Floe is a Next.js app with three small API routes and one Move module. There is no database and no user table.

PartResponsible forNever has
BrowserLink keys, transactions, the sender’s history and reading SuiThe sponsor’s private API key
Move contractHolding coins, checking signatures and paying outThe link’s private key
/api/claimChecking a signed claim and asking Enoki to pay its gasThe key or note
/api/pricesLive SUI and $LOFI pricesAnything about a payment
/api/impactWater totals, read from public claimsThe key or note
WalrusEncrypted cards, photos and voice notesThe key that opens them
EnokiGoogle zkLogin accounts and gas sponsorshipThe link’s private key
Sui nodesCurrent objects over gRPC, and past events over GraphQLThe key or note

Creating a link#

  1. The browser makes a new Ed25519 keypair in memory. Each link has its own.
  2. The sender signs a transaction that calls create_escrow with the coins and the public key.
  3. Before sending, Floe computes the transaction digest and saves a history record under it. The record never includes the private key.
  4. The browser sends the signed bytes. If the reply is lost, it looks the digest up on the full node and in GraphQL before saying what happened.
  5. Once the escrow ID is known, the browser builds the link from the ID, the private key and the note.

Claiming a link#

  1. The claim page reads the escrow ID from the query and the key from the fragment, then loads the escrow from Sui.
  2. The recipient logs in with Google or connects a wallet, which gives an address.
  3. The key in the link signs 64 bytes: the escrow ID, then that address. The signature goes into a claim_escrow transaction. The key does not.
  4. The recipient’s account signs the transaction, with Enoki set to pay the gas.
  5. POST /api/claim checks and simulates it, then Enoki sponsors and runs it.
  6. The contract verifies the signature, pays the recipient and the treasury, and deletes the escrow.

Refunding a link#

The sender calls reclaim_escrow directly from their account. No Floe server takes part, and the claim key isn’t needed.

Withdrawing#

The account page sends a plain transfer from the browser and pays its own gas, so it doesn’t touch the contract or a Floe server. It is built and simulated first to check that it can be afforded. Like a create, it is signed once, and only those same bytes are ever sent again.

The life of an escrow#

Escrow states
create_escrow ──▶ open ──┬── claim_escrow, up to expiry ──▶ deleted, recipient paid
                         │
                         └── reclaim_escrow, any time ────▶ deleted, sender refunded

An escrow is a shared object that is deleted when it closes, so it can pay out only once. If a claim and a refund race, Sui orders them and the second one fails.

How status is worked out#

The dashboard asks a full node for each open escrow, 50 at a time. If one is gone, Floe finds the transaction that closed it and reads its event to tell a claim from a refund. Those lookups use GraphQL, because full nodes drop old transactions.

An unreadable escrow is never treated as missing. Its last known status stays until Sui gives a definite answer.

Stack#

LayerTechnology
AppNext.js 15, React 19, TypeScript
Style and motionTailwind CSS, Framer Motion
Sui@mysten/sui, @mysten/dapp-kit-react
Login and gas@mysten/enoki
ContractMove, 2024 edition