Last updated
Was this helpful?
Last updated
Was this helpful?
Welcome to the guide! This guide is designed for developers working in a React environment using TypeScript. We'll walk through the installation process and show you how to create and broadcast a Bitcoin SV transaction using the BSV SDK. Whether you're freshly starting on BSV or transitioning an existing project to use the SDK, this would be your go-to guide.
Ensure that you have Node.js installed on your system. You can download and install Node.js from . Basic knowledge of JavaScript, React and TypeScript is recommended for this guide.
Begin by creating a new project using Create React App with the TypeScript template:
Next, install the BSV SDK package in your project:
Let's now create a Button component that builds and broadcasts a transaction when clicked.
Create a new file in your project, such as src/components/BsvButton.tsx
.
At the top of your component file, import the necessary modules from the BSV SDK:
Define a new component function, BsvButton
, that handles the creation and broadcast of a transaction upon a button click:
Finally, export the BsvButton
component:
Now, let's integrate our BsvButton
component into our app:
Open src/App.tsx
.
Delete all of its content and replace it with the following:
To run your application, just type the following command in your terminal:
Now when you click the button, a transaction will be created, signed, and broadcast to the BSV network.
Congratulations! You've successfully integrated the BSV SDK into your TypeScript & React application and created a button which broadcasts a bitcoin transaction on click. This guide covered the basic steps needed to get you started, but the BSV SDK can do a lot more. Explore the SDK documentation to dive deep into all the features and functionalities available to build scalable applications on the BSV blockchain.