Any wallet developer can integrate trustless Liquid Bitcoin peg-in features in their own application, even in the browser!
npm install --save pegin# or with yarnyarn add pegin
import ElementsPegin from 'pegin'; // initialize the moduleconst peginModule = new ElementsPegin( await ElementsPegin.withGoElements(), await ElementsPegin.withLibwally(),); // get a pegin address to deposit Bitcoinconst peginAddress = await peginModule.getMainchainAddress( claimScript // Liquid scriptpubkey); // deposit funds to the Bitcoin addressconsole.log(peginAddress); // retrieve the raw bitcoin transaction hex encoded and the merkle block proof, pass them along the Liquid script used to generate the pegin addresslet claimTx = await peginModule.claimTx( btcTxHex, btcTxOutProof, claimScript); // Now you can broadcast the transaction to the Liquid Network
Liquid Network allows anyone to "convert" BTC into L-BTC, the sidechain native asset, with a process called peg-in: it consists in sending Bitcoin to the Liquid federation multisignature script tweaked with the user's Liquid script.
After 102 Bitcoin mainchain blocks, the user can claim his Liquid bitcoins creating a special Liquid transaction and broadcast it to the Liquid Network.
At the moment the process is quite cumbersome and requires the user to use an Elements node via command line interface. This basically forced the majority of users to use centralized exchanges, involving a custodial process and counterparty risks.
TDEX allows anyone to trade Liquid assets freely without being custodian of funds and the major road block to increase TDEX and Liquid Network usage is to let people to get Liquid Bitcoin with their mainchain Bitcoin.
Browsers and mobile apps built with web technologies such as React Native or Cordova can now use the npm pegin module and integrate this in few lines of code.
Try the pegin feature, now live in the TDEX mobile app!