SELFHOLD / FOR DEVELOPERS Guide pages ↓
Errors
Every failure is a SelfholdError. Its code is for your code; its message is written for the person, so show it as it is; its docUrl links here.
try {
await wallet.writeRecords(request, { account: address });
} catch (error) {
if (error.code === "Declined") return; // a cancel: nothing was signed
if (error.code === "Closed") return refreshFromChain(); // most likely a cancel; a write may have gone out
if (error.code === "NeedsCoins") return askForCoins(error.address, error.needed - error.balance);
if (error.code === "AccountChanged" || error.code === "NotConnected") return refreshAccount();
showError(error.message);
console.warn(error.code, error.docUrl);
}
Codes
code | What happened |
|---|---|
PopupBlocked | The browser blocked Selfhold's window. |
Closed | The window closed before it answered your page. |
Declined | The person declined. |
Reloaded | The window was reloaded in the middle of a call. |
AccountChanged | The wallet uses another account now. |
NotConnected | This site has no account from the wallet. |
NeedsCoins | The account can't pay for the write. |
NoWallet | Selfhold for Chrome isn't installed. |
Lost | Another write landed in this one's place. |
NotRecorded | Sent, and still not recorded after 30 minutes. |
Failed | Anything else. |
PopupBlocked
The browser blocked Selfhold's window.
- Why
- Your page called
connect,writeRecordsorsignMessageafter anawait, or outside a click, or the person turned pop-ups off for your site. - What the person saw
- Nothing. The window didn't open.
- What to do
- Make the call the first thing your click handler does. Pass work that must happen first as a promise (see Read first). If the person blocks pop-ups, the message asks them to allow them.
- Safe to try again
- Yes, from a click.
Closed
The window closed before it answered your page.
- Why
- The person closed the window or its tab. Almost always that's before approving, as a cancel. But if they closed it while it was sending an approved write, the write may have gone out.
- What the person saw
- Their own action.
- What to do
- Treat it as a cancel. If the call was a write, read the chain before you offer to send it again.
- Safe to try again
- For connect and sign, yes. For a write, after checking the chain.
Declined
The person declined.
- Why
- They pressed Decline, or stopped the fee work.
- What the person saw
- Their own choice.
- What to do
- Treat it as a cancel. Nothing was signed. Selfhold for Chrome waits a few seconds after a decline before it takes the same site's next request.
- Safe to try again
- Yes, if they ask.
Reloaded
The window was reloaded in the middle of a call.
- Why
- The person reloaded Selfhold's window.
- What the person saw
- The window starting over.
- What to do
- Nothing was signed, and the call isn't resent. Let the person try again.
- Safe to try again
- Yes.
AccountChanged
The wallet uses another account now.
- Why
- The
accountyou passed isn't the wallet's account any more: the person switched accounts, or signed in with another passkey. - What the person saw
- Selfhold's window opens and closes at once, or first asks them to sign in if this browser has no account.
- What to do
- Nothing was sent. Read
wallet.address()again, redraw your page for that account, and rebuild the write. - Safe to try again
- After you rebuild it.
NotConnected
This site has no account from the wallet.
- Why
- You passed an
account, but the wallet isn't connected to your site: the person disconnected it, or it was never connected. - What the person saw
- Nothing.
- What to do
- Ask them to connect again (
wallet.connect(), from a click). - Safe to try again
- After connecting.
NeedsCoins
The account can't pay for the write.
- Why
- The account doesn't hold the coins for the write's payments and fee, and no fee sponsor could pay the fee. The error is a
NeedsCoins, withaddress,neededandbalance(bigints), andsponsor: why the sponsor didn't pay ("down","dear","most"), ornullif none was asked. - What the person saw
- The window's review, then its message.
- What to do
- Show the person how many coins they need and where to send them:
needed - balancemore, toaddress. Ifsponsoris"down", trying again in a few minutes may work. See When work can't pay. - Safe to try again
- Once the account holds the coins, or the sponsor is back.
NoWallet
Selfhold for Chrome isn't installed.
- Why
- You made the wallet with
use: "extension", and the extension isn't in this browser. - What the person saw
- Nothing.
- What to do
- Offer Selfhold's window instead (
use: "window"or the default), or a link to install Selfhold for Chrome. - Safe to try again
- After installing.
Lost
Another write landed in this one's place.
- Why
- Your
checkreturned a string on three reads in a row: the records changed in a way this write can't now apply to. - What the person saw
- Their write sent, then your page's message.
- What to do
- Show the message your
checkreturned. Read the chain again, and build a new write only if the person still wants it. - Safe to try again
- As a new write, built from what the chain holds now.
NotRecorded
Sent, and still not recorded after 30 minutes.
- Why
- The node took the write but no block recorded it: it was most likely dropped.
- What the person saw
- Their write sent, then slow, then late.
- What to do
- Read the chain first. If the write isn't there and is still needed, let the person send it again.
- Safe to try again
- After checking the chain.
Failed
Anything else.
- Why
- Something the other codes don't cover: a host that couldn't be reached, a write the chain refused, a passkey that couldn't make a key.
- What the person saw
- The wallet's message.
- What to do
- Show
message: it's written for the person. Report what you can't explain. - Safe to try again
- Depends on the message.
Something wrong or missing here? Report it on GitHub ↗