This 4-step workshop is intended to showcase how you can register and show Doichain names and how to create and sign NameOp transactions via PSBT-QR-Codes and PSBT-Files. PSBTs can be scanned and broadcasted by DoiWallet or via file import into the ElectrumDOI wallet. No private key necessary in the browser.
See: ipfs://bafybeifj5jp3m3bhpjkls4smy34i4hxvbpasql7dbtkpcr65bawrs2js3u/
- Clone this repo and run
npm i
- Connect to ElectrumX in src/routes/+layout.js
- Validate name to be registered in src/lib/components/pricing.svelte
- is name already registered?
- if yes - which address?
- Build project and add to local ipfs node
npm run build
mv public lesson01
ipfs add lesson01/
- Run Brave browser and open ipfs url: ipfs://{cid of your ipfs add command} or see our version: ipfs://QmZmvtgcxNof3QvKgC73SmbDawHCwxTnkMpWukTLokcgHS/
- Checkout branch lesson02)
-
How to connect to Electrumx via secure websocket (wss) a) src/lib/doichain/connectElectrum.js b) understanding the Electrum API https://electrum.readthedocs.io/en/latest/protocol.html c) (optionally) setting up a Doichain Node and an ElectrumX Node with SSL
-
NameOps, NameId, NameValue, Recipient (owner) a) src/lib/doichain/nameShow.js b) what is a UTXO (unspent transaction output) c) what are inputs and outputs of a transaction b) response of a nameShow command (tx history of the nameOp)
- Add an address input below the name input
- src/lib/components/pricing.svelte
- Gather UTXOs and NameOps of this address (show name and expiration)
- src/lib/doichain/utxoHelpers.js
- Add an QR-Code scanner to scan an address
- use src/lib/doichain/ScanModal.svelte
- Show registered NameOps with expiration block
- src/lib/components/pricing.svelte
- Build project and add to local ipfs node
npm run build
mv public lesson02
ipfs add -r lesson02
- Run Brave browser and open ipfs url: ipfs://{cid of your ipfs add command} (or: ipfs://QmWnDdeb1oWgYZKuyfJm49Bp9G7FwjCTkYiCXoD2Skfsz9)
- Checkout branch lesson03)
- Understanding UTXOS
- Scanning address-QR-Codes from DoiWallet
- Understanding expiration
- Adding a feature box
- src/lib/components/pricing.svelte
- Adding a transaction calculation box (storage fee, mining fee, change amount, total amount)
- src/lib/components/pricing.svelte
- Generating a PSBT (partially signed Bitcoin transaction)
- src/lib/components/pricing.svelte
- Implementing QR code generation for PSBTs
- src/lib/components/pricing.svelte
- Adding support for BBQR and BCUR formats
- src/lib/components/pricing.svelte
- Creating an animated QR code display
- src/lib/components/pricing.svelte
- Handling transaction signing and error cases
- src/lib/doichain/signTransaction.js
- Updating the UI to display transaction details and QR codes
- src/lib/components/pricing.svelte
- Understanding different QR code formats for cryptocurrency transactions (BBQR and BCUR)
- Implementing animated QR codes for improved user experience
- Handling and displaying transaction details in the UI
- Error handling in transaction creation and QR code generation
- Add QR code generation logic using BBQR and BCUR formats
- Create functions for animating QR codes (
displayQrCodes
andanimateQrCodes
) - Update the reactive block to handle transaction signing and QR code generation
- Modify the UI to display transaction details and the generated QR code
- Implement error handling for transaction creation and QR code generation
- Test the functionality with various inputs and edge cases
- PSBT (Partially Signed Bitcoin Transactions)
- QR code formats for cryptocurrency transactions (BBQR and BCUR)
- Animated QR codes for multi-part data
- Reactive programming in Svelte
- Error handling in asynchronous operations
The marketplace allows users to buy and sell Doichain names in a decentralized way using atomic transactions. This trading approach was first introduced by Namecoin's atomic name trading protocol, which Doichain has extended to use modern PSBT (Partially Signed Bitcoin Transaction) files and QR codes for improved usability. This ensures that trades are executed safely without requiring trust between parties.
For the implementation, we forked the open-source BlueWallet project to create DoiWallet, leveraging its robust PSBT scanning capabilities. We then extended both DoiWallet and the underlying bitcoinjs-lib library to support Namecoin-style NameOp transactions, enabling seamless atomic name trading through a mobile-first interface.
- Trading names using atomic transactions
- Creating sell offers
- Creating buy offers
- Completing trades
- Understanding PSBT (Partially Signed Bitcoin Transactions)
-
Atomic Name Trading
- Atomic transactions ensure that either both parties get what they want, or neither does
- Uses PSBT (Partially Signed Bitcoin Transaction) format
- No intermediaries or escrow required
-
Sell Offers
- Current name owner creates Part 1 of PSBT
- Sets desired price in DOI
- Signs their name input
- Shares PSBT with potential buyers
-
Buy Offers
- Buyer receives Part 1 of PSBT
- Adds funding inputs and outputs
- Signs their inputs
- Returns completed PSBT to seller
-
Trade Completion
- Seller verifies and signs completed PSBT
- Transaction is broadcast to network
- Name ownership transfers when transaction confirms
-
Create a sell offer for a name you own:
- Set a reasonable price
- Generate and share the PSBT
- Verify the PSBT contains your signed name input
-
Create a buy offer for someone else's name:
- Get their sell offer PSBT
- Add your funding inputs
- Sign your inputs
- Return the completed PSBT
-
Complete a trade:
- As the seller, verify the completed PSBT
- Sign any remaining inputs
- Broadcast the transaction
- Monitor for confirmation
- Atomic transactions provide trustless trading of names
- PSBTs enable multi-step transaction construction
- Both parties must sign their respective inputs
- Transaction only completes when fully signed