Development Guide
Learn how to build solutions on top of Stablepay
Introduction
Stablepay is a solution for handling on-chain transactions for fintech wallets. This guide will walk you through the process of integrating Stablepay into your application, from installation to sending transactions.
Prerequisites
Before you begin, ensure you have the following:
- Node.js (version 18.10.0 or higher)
- npm or yarn package manager
- Basic knowledge of TypeScript and Solana blockchain
Installation
Step 1: Install the Stablepay transaction handler in your project.
Using npm:
Using yarn:
Understanding the QR code UI Builder
The @stable-pay/ui-builder
package provides a TypeScript function that helps Merchants build a QR code destop solution for their checkout.
Key Features
- Handles Stablepay transactions
- Supports custom references for merchant tracking
- Allows optional sponsor for transaction fees
Using the Transaction Handler
The main function provided by the package is handleTransferRequest
. Here’s its signature:
Parameters
connection
: AConnection
object to interact with the Solana networksender
: ThePublicKey
orKeypair
of the transaction senderCreateTransferFields
: An object containing:recipient
: The receiving address (PublicKey)amount
: The amount to transferreference
: A unique identifier for the transactioncustomReference
: A custom reference (e.g., for merchant tracking)
commitment
: (Optional) The desired commitment level for the transactionsponsor
: (Optional) AKeypair
object for a sponsor to pay transaction fees
Return Value
The function returns a Promise
that resolves to a Transaction
object.
Sending a Stablepay Transaction
Here’s an example of how to use the handleTransferRequest
function to create and send a Stablepay transaction:
Best Practices
- Error Handling: Always wrap your Stablepay transactions in try-catch blocks to handle potential errors gracefully.
- Transaction Confirmation: Use the appropriate commitment level for your use case. ‘Confirmed’ is a good balance between speed and security.
- Custom References: Utilize the
customReference
field for internal tracking and reconciliation purposes. - Sponsorship: Consider using a sponsor for transaction fees to improve user experience, especially for new users who might not have SOL.
Conclusion
This guide provides a foundational understanding of how to integrate and use Stablepay in your application. As you develop, refer to the official Stablepay documentation for more advanced features and up-to-date information.
For further assistance or to report issues, please contact the Stable Pay support team or visit our GitHub repository.
Happy coding with Stablepay!