Quick Start
Get started with the SDK in under 5 minutes!
Import the SDK
Connect to the Solana Network
Connect to Default RPC Endpoint:
Connect to Custom RPC Endpoint:
Connect Wallet
Wallet Adapters:
SOL Pay supports six wallets:
Phantom (
SOLPay.adapters.PHANTOM
)Solflare (
SOLPay.adapters.SOLFLARE
)Slope (
SOLPay.adapters.SLOPE
)Glow (
SOLPay.adapters.GLOW
)Exodus (
SOLPay.adapters.EXODUS
)Brave (
SOLPay.adapters.BRAVE
)
You can also use SOLPay.adapters.CURRENT_ADAPTER
or leave the adapter field blank to use the current adapter.
Send Transaction
Send Solana Lamports
Send Solana
Verify Transaction
Important:
It is vital to verify that a transaction is valid on your backend. If you only trust the payment details on the front-end, hackers can easily forge fake transactions. However, verifying the transaction on your backend resolves this issue. The backend is also where you would complete the transaction by logging the signature to a database (so that it cannot be used twice) and then providing the user with the product.
Our API does not check whether you have already verified a transaction. You need to make sure on your backend that you are storing the transaction signatures so that they cannot be used to buy the same product twice.
Verifies the details of a transaction made through SOL Pay
GET
https://solpay.togatech.org/transaction.php
The transaction endpoint takes in two parameters: to and txid. The to parameter is for the recipient address, and the txid is for the signature (which can be obtained through the payment details above). The endpoint returns the sender address and the number of lamports sent.
Query Parameters
Example Verification URL
Example
Frontend
Backend
Important:
The above example is for reference only and lacks a few features recommended for more robust apps, including a preconfirm handler (sendSolanaLamports) and, if the app immediately returns the purchased item back to the client directly, a user signature (signMessage).
Last updated