Considering the lack of standardisation for adding native bitcoin support into browsers, it comes as now surprised that there are initiatives trying to overcome this problem through extensions. In this tutorial, we will be exploring a promising web browser extension built using a set of open source libraries by a team called Liquality. This extension has some exciting features which simplify adding bitcoin support into any existing web applications or sites.
There is currently a version of the wallet available from the google chrome store. Developers might however prefer to download and build the wallet from source though as follows.
- Clone the wallet source code
git clone https://github.com/liquality/wallet cd wallet npm install
2. Build the wallet
npm run build
We can now enable the extension through chrome.
- Open a chromium compatible browser
- Select "Window" > "Extensions" or visit chrome://extensions/
- Ensure you have the "Developer mode" option toggled on
- Select the "Load unpacked" option
- Browser to the extension folder and select "dist"
You should now have a copy of the liquality wallet installed. You can access it via the browsers extension tabs.
Next, we need to initialise the wallet.
- Open the extension
- Accept the Terms and Conditions
- Select "Create a new wallet"
- Provide a password
- Select Continue
Important: Make sure to backup your mnemonic.
Next, I'd suggest toggling the wallet to testnet for the purposes of this tutorial. The wallet itself has a fully functional user interface, but we'll be exploring the plumbing from the console for the rest of this tutorial.
Enabling wallet for a domain
Before we can invoke any calls with the wallet, we need to request access from the domain. The liquality wallet is currently restricted to working from https://liquality.io and its sub domains. You can remove this restriction by editing the manifest file.
"matches": [ "*://*/*" ],
We'll however be accessing the rest of the tutorial from their domain here.
- Visit https://cross-chain-apps.liquality.io/
- Open the developer console
- Execute the following
On selecting allow, we have authorised the domain to invoke functions from the wallet. Next we will get an unused address from the wallet.
Getting a new Bitcoin address
Before we can continue, we will need to retrieve the bitcoin wallet provider from the wallet API.
var bitcoin = window.providerManager.getProviderFor("BTC")
Now we can invoke any of the permitted methods. The one for retrieving an unused address is
bitcoin.getMethod('wallet.getUnusedAddress')().then((address) => console.log(address.address))
Sending a Bitcoin transaction
Before we can send bitcoin, we'll need to get some testnet coins. Do so by using the address from the previous step from any testnet bitcoin faucet. Here is one which seems to work at the time of writing this tutorial.
You can confirm your balance as follows. Be sure to replace the address here with the one you retrieved before.
We can now send this bitcoin back to the faucet.
Here we can see the transaction on the blockstream testnet explorer.
The tutorial is a very simple demonstration of some of the simple things you can do with the liquality bitcoin wallet. The wallet has been built as an application using their very own chain abstraction library http://chainstackjs.org. For more information on how to get involved visit their github repository or engage with them on telegram.