Learn how to use Reown AppKit for essential wallet functionalities such as signing messages, getting the balance and sending transactions.
In this recipe, you will learn how to:
- Sign a message using a connected wallet.
- Send a transaction to the Bitcoin blockchain.
- Get the balance from an Address.
- Get the Public Key.
This guide will take approximately 20 minutes to complete.
Let's dive in!
Prerequisites#
- A fundamental understanding of JavaScript and React.
- A minimal installation of AppKit in React.
- Obtain a new project Id on Reown Dashboard at https://dashboard.reown.com
Final project#
Clone this Github repo to try it out locally.
AppKit Minimal Installation#
You can start a small project following the guidelines from our installation React docs using Bitcoin
Start building#
In this guide we are going to use AppKit to make the calls to the Bitcoin blockchain and interact with the wallet.
- Start by importing the
useAppKitProvideranduseAppKitAccounthooks.
- Extract the
walletProviderfunction from theuseAppKitProviderhook. This function allows you to prompt the connected wallet to sign a specific message. Also, we are usinguseAppKitAccountto get the address and isConnected as explained before.
Sign a message#
In order to raise the modal to sign a message with your wallet continue with the following steps:
- Create a function to prompt the modal for signing the message.
- Finally, to call the function:
Send a transaction in Bitcoin#
- Create a function to raise the modal to send the transaction
- Finally, to call the function:
Get Balance#
- Create the function to get the balance
- Finally, to call the function:
Get the Public Key#
- Create the function to get the public key
- Finally, to call the function:
Conclusion#
By following this guide, you've learned how to integrate Reown AppKit and Bitcoin into your React application to perform essential wallet operations. You can now sign messages, get the balance, get the public key and send transactions in the Bitcoin blockchain.
Keep exploring AppKit to enhance your dApp functionality and user experience!