selfhold

SELFHOLD / FOR DEVELOPERS Guide pages ↓

How Selfhold works

Selfhold is a wallet for Lattice ↗. Your site asks it for things; the person approves them in Selfhold; your site gets the answer. This page explains the parts, so you know what to expect and what to tell people.

Two wallets, one library

selfhold() gives you one wallet object. Behind it is one of two wallets:

Selfhold's windowSelfhold for Chrome
What it isA page at wallet.selfhold.app that opens over yours, as a payment window does. On iPhone it opens as a tab.A Chrome extension the person installed.
Where it worksAny current browser with passkeys, phones included.Desktop Chrome.
The accountDerived from a passkey. The person's password manager keeps it and syncs it to their other devices.Kept in the extension, protected by its password and recovery phrase.
Used whenSelfhold for Chrome isn't installed, or you pass use: "window".It's installed, or you pass use: "extension".

The two keep separate accounts. Someone with both has two addresses, so say on your page which one is connected: wallet.kind tells you.

What happens in a write

A write through Selfhold's window Your page opens the window in a click and sends the write. The person approves with a passkey. The window signs, sends the transaction to a node, and answers your page, which then watches the chain until it lands. Your page Selfhold's window Lattice node 1. writeRecords(): opens the window, in the click 2. ready 3. the write, the hosts and the sponsor 4. the person reviews, approves with a passkey 5. signed transaction 6. Sent: its CID and nonce 7. sent.wait(): reads the account until the write lands The key exists only inside the window, only for the request.
  1. Your page calls writeRecords() in a click, which opens Selfhold's window.
  2. The window says it's ready.
  3. Your page sends the write, and the hosts and fee sponsor to use.
  4. The window shows the person what the write does and costs. They approve with their passkey.
  5. The window derives the key from the passkey, signs, and sends the transaction to a node.
  6. The window answers your page with the transaction's ID and nonce, then closes.
  7. sent.wait() reads the account at the node until the write lands.

Selfhold for Chrome is similar, with differences: its own window asks, a site it's connected to isn't asked again to connect, it sends through the node the person chose in it (not your hosts), and it pays fees from coins (no sponsor).

The account

What your site can and can't do

Your site canYour site can't
Ask to connect, and learn the account's address once the person agrees.See or use the key, the passkey or the recovery details.
Propose a write: records to change, payments, a fee sponsor and hosts.Send anything without the person's approval. Every write and every signature asks.
Hear progress, and get the sent transaction's ID and nonce.Get the signed transaction's bytes, to send again later.
Ask for a signature on text.Sign as another site: the signed bytes include your origin, as "lattice-message:" + origin + "\n" + text.
Suggest a fee sponsor.Let the sponsor change the write: the window checks that the sponsor added only its own fee, and refuses otherwise.

The window shows the person your site's origin on every request: the host in bold, and the scheme when it isn't https. A page on localhost is marked "a site on this computer". It answers only the page that opened it, and only to that page's origin.

The Lattice you need to know

Chains and chainPath
Lattice has a main chain, Nexus, and child chains under it. A write names its chain by path, such as ["Nexus", "your-chain"]. Each chain may have its own rules for the records it accepts.
Records
A chain holds records: keys with string values. A write changes some of them, all at once or not at all.
Nodes and hosts
A node holds a chain and takes transactions for it. Selfhold's window sends a write to the hosts you give selfhold(), or else the ones Nexus lists for the chain.
Fees
Each transaction pays a fee to the miner who records it. It comes from the account's coins, or from a fee sponsor, paid with work: see Pay fees with work.
Nonce
Each account's transactions are numbered. A write has landed once the account's next number has passed it.
Blocks
A block every 10 seconds or so records the transactions waiting. That's why a write usually lands within seconds of being sent.

For more on chains, nodes and mining, see lattice.build ↗.

Something wrong or missing here? Report it on GitHub ↗