Brett Banfe hosted the first Code–a-long session on the 23rd of April 2024, with Ty Everett from Project Babbage, presenting the newly released BSV Typescript SDK. The release of this library is part of an overall initiative from BSV Blockchain to standardise, complete, maintain and test the most used BSV libraries while clarifying open-source guidelines and contribution.
The participants included:
- Ty Everett (Project Babbage)
- Darren Kellenschwiler (BSV Blockchain)
- Damian Orzepowski (4chain)
- Jake Jones (BSV Blockchain)
- Brett Banfe (Head of Community, BSV Blockchain)
The Code-a-long session demonstrated the new TypeScript library. Everett demonstrated practical implementations, such as setting up a React project, building and broadcasting transactions, and creating script templates for transactions.
Purpose of the TypeScript SDK and overview of components
Everett explained that the TypeScript SDK is built from scratch with zero dependencies and is designed to be a solid tool for building on the BSV blockchain. It replaces outdated and unmaintained libraries. Project Babbage, Everett’s own company, will use this SDK together with BSV Blockchain overlay services reference implementation (release planned in Q3), facilitating specialised overlay networks for applications like supply chain tracking and distributed identity solutions.
The library supports key derivation for various functionalities such as secure signatures and encryption, and includes standard cryptographic tools like private/public keys, symmetric encryption, digital signatures, hashes, and elliptic curve operations. He highlighted how the library improves interoperability and scalability.
Everett explained the library’s script component, which supports network-compliant scripts and the Genesis update of the BSV network, emphasising the necessity of constraints in BSV transactions to prevent unauthorised spending.
The transaction construction and signing features were highlighted for their comprehensive capabilities, including transaction verification, serialisation, fee computation, change output generation, transaction broadcasting, and fee modelling. The library also supports Merkle proofs for blockchain anchoring and simplified payment verification (SPV).
Everett directed viewers to the GitHub repository for documentation, organised into folders: “docs” for API and code-level details, “low level docs” for fundamental concepts, “examples” for tutorials on various use cases, and “concepts” for high-level concepts. He recommended migrating to Type 42 for BSV wallet management while still supporting Bit32.
Project setup using React
Everett then delved into the more practical part of the session and demonstrated how to set up a new code project using a simple React application. He guided the audience through cloning the repository, installing dependencies, and integrating the new SDK. Then, Everett showed how to create a basic functionality in React for generating a private key and address using the SDK.
He explained each step and demonstrated how to handle state changes and user interactions. Finally, Everett confirmed that the demonstration works by generating a private key and address in the web browser.
Using the transaction builder
The next step in the session focused on building and broadcasting a transaction using the library. He outlined prerequisites such as having funds in a UTXO, knowing the source transaction, and having the private key. After deciding to demonstrate the process with actual transactions, Everett shared code snippets and explained generating funds and preparing for transaction creation and broadcasting.
The participants discussed using the Arc API and setting up a proxy to resolve cross-origin issues. After encountering and resolving challenges with cross-origin errors, they succeeded in broadcasting transactions by adjusting the URL.
Introduction to scripts and script templates
Everett introduced script templates for BSV transactions, emphasising their role in creating and spending UTXOs using locking and unlocking scripts. The discussion covered the structure of a script template interface, the importance of estimating script lengths, and the implementation of a pay-to-public-key-hash (P2PKH) script template.
Next, Everett proposed a practical example: a number multiplication script template, where the locking script states “X times Y equals Z,” and the unlocking script provided the correct answer. Despite encountering challenges with the implementation, they proceeded with defining lock and unlock functions, demonstrating the script template’s use within a transaction.
Simplified Payment Verification
Everett transitioned to discussing Simplified Payment Verification (SPV) and transaction verification at a high level. He explained that SPV involves checking transaction scripts and verifying their inclusion in the blockchain using Merkle proofs. He elaborated on how SPV allows verification without the need for processing the entire blockchain, thereby facilitating independent verification tailored to specific use cases. He contrasted this with other chains that require the entire blockchain for verification.
HD and Type 42 Keys in the SDK
Another focus topic towards the end was the implementation of keys in the SDK. Everett discussed the benefits and implementation of HD (Hierarchical Deterministic) and Type 42 keys in the library, emphasising Type 42 keys for their enhanced privacy, flexibility, and auditability. He provided example code for both key types and explained the process of transitioning to Type 42 keys by generating new private keys and moving UTXOs.
Everett also introduced a new protocol for message signing using Type 42 keys, demonstrating both private and public message signing. Additionally, he discussed message encryption using AES with Galois Counter mode 256 based on Type 42 derived keys.
More core BSV libraries will be standardised following BSV blockchain open-source guidelines
The presentation closed with statements on how the library provides a foundational layer for building blockchain applications and enabling various types of transactions.
The library supports the creation of interoperable digital identities that work with BSV blockchain and smart contracts, ensuring secure interactions. Its encryption features facilitate secure communication and secure digital asset management.
Anyone who is further interested in the topic or has questions about the SDK can reach out by opening an issue on GitHub. BSV Blockchain has clarified the open-source guidelines to foster contribution from developers while ensuring a neutral foundation for core open-source components. Additional BSV libraries such as Go-lang and Python will be standardised and maintained by BSV Blockchain leveraging skills from talented BSV developer teams.
If you are interested in future Code-a-long sessions or would even like to participate in the future, you can join the official BSV Blockchain Discord channel here or contribute to the Github repository.
Learn more about BSV Blockchain’s Library revamp
Updating BSV blockchain’s libraries – get involved!
BSV Blockchain launches TypeScript SDK – with more languages planned in the future
Fostering innovation through standardisation: the future of BSV development
Updating BSV blockchain’s libraries – An interview with Project Babbage