The Pi Network JS SDK exposes wallet-related operations and blockchain
interactions via the window.Pi.Wallet module. These methods enable
your app to create, submit, and inspect Pi blockchain transactions for
authenticated users, only within the Pi Browser.
This guide demonstrates how to integrate the Pi SDK into many application frameworks. This example shows how to initialize the Pi SDK, authenticate a Pioneer, and create a payment request inside a Pi app.
The pi-sdk-js
package
is part of the “Ten Minutes to Transactions” effort described in this
video.
If you, or your GenAI agent, are planning to use the Pi SDK modules in this documentation for your app, it is highly suggested that you use this package rather than implement transaction processing by hand with the core Pi SDK. The three way handshake between client, server, and the Pi servers required is provded for you.
Note: Pi SDK authentication and payment features require the application to run inside the Pi Browser.
window.Pi.Wallet.submitTransaction(xdr)
window.Pi.Wallet.getUserMigratedWalletAddresses()window.Pi.Wallet Methods.submitTransaction(xdr)xdr (string): Base64-encoded Stellar XDR representing the transactionPromise<object>: Resolved with the blockchain transaction result if success, or rejects on error (user cancel, auth problem, RPC failure, etc.).Pi.Wallet.submitTransaction(xdr).then(function(result) {
// Transaction submitted! Process result or notify user
}).catch(function(error) {
// Submission failed; handle error
});Pi.Wallet.getUserMigratedWalletAddresses()Promise<object>: An object with a wallets array, each containing { publicKey: string }.Pi.Wallet.getUserMigratedWalletAddresses().then(function(data) {
data.wallets.forEach(function(wallet) {
console.log('Wallet address:', wallet.publicKey);
});
});// Submit an existing signed transaction
const signedXDR = "AAAA...";
Pi.Wallet.submitTransaction(signedXDR)
.then(txResult => { console.log("Tx Success!", txResult); })
.catch(err => { alert("Tx failed: " + err.message); });
// Get user's wallet addresses
Pi.Wallet.getUserMigratedWalletAddresses()
.then(data => {
// [{ publicKey: "G..." } ...]
doSomething(data.wallets);
});Pi.authenticate(...))..getUserMigratedWalletAddresses() to display or confirm available wallet addresses for advanced flows.