Browser Wallets
Browser Wallets supports the following wallets:
Connecting to Browser Wallets
You may interface with the wallets above by importing the API as follows:
- Unisat
- Xverse
import {
isInstalled,
getAddresses,
signPsbt,
signMessage,
} from "@ordzaar/ordit-sdk/browser-wallets/unisat";
import {
isInstalled,
getAddresses,
signPsbt,
signMessage,
} from "@ordzaar/ordit-sdk/browser-wallets/xverse";
tip
Importing the functions individually ensures that tree-shaking is applied when bundling your application.
Example
The following snippet checks if the browser wallet is installed and returns a list of addresses, if authorized by the wallet.
async function connectToWallet() {
if (!isInstalled()) {
throw new Error("Wallet is not installed");
}
const addresses = await getAddresses("mainnet"); // mainnet or testnet
console.log(addresses);
// Example output of addresses:
//
// [{
// publicKey:
// "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
// address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
// format: "segwit",
// }]
//
// or an error is thrown by the wallet provider.
}
connectToWallet();
API Reference
isInstalled
isInstalled()
Indicates whether the browser wallet extension is installed.
Returns: boolean
Output Example: true | false
getAddresses
getAddresses(network)
Gets a list of addresses for the browser wallet if authorized.
Returns: Promise<WalletAddress[]>
Output Example:
[
{
publicKey:
"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
format: "segwit",
},
];
Parameters:
network
:"mainnet" | "testnet"