Skip to main content

Early development · Feedback welcome

Labs · HTML-native bitcoin

A coin is an element

Two custom elements and one script. <bsv-coin> names an output and draws it from the chain, like <img>. <coin-slot> takes coins and belongs to its form, like <input type=file>. What happens comes out as DOM events; how it looks is this page's CSS. The page can ask for a spend, but only your wallet can make one.

Coins

Drag one onto a slot, copy and paste it, or click it and then click a slot. The keyboard works too: Tab to a coin, Enter to pick it up, Tab to a slot, Enter to drop.

<bsv-coin outpoint="000b16…4a55.0"></bsv-coin>

In a form

The slot submits one outpoint per coin and validates like any field: it's required, holds two, and takes images only.

<form>
  <label>
    Title
    <input name="title" value="Three postcards">
  </label>
  <coin-slot name="coins" accept="image/*" max="2" required>
    Drop up to two image coins
  </coin-slot>
  <button>Create listing</button>
</form>
Drop up to two image coins

Asking for a spend

A slot with action="pay" turns an accepted coin into a spendrequest event. It stops there: a listener would hand the draft to a wallet, which shows you what moves where and signs, or doesn't.

<coin-slot action="pay" to="1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH">
  Pay with a coin
</coin-slot>
Pay with a coin

The same coin cards, as objects on a desk: the coin tray.