Integrate PeakVault browser extension for transaction signing
The PeakVault signer enables integration with PeakVault, a secure browser extension wallet from the PeakD team. This allows users to sign transactions using their PeakVault setup.
PeakVault is a browser extension wallet designed specifically for the Hive blockchain by the team behind PeakD, one of Hive’s most popular front-ends. It provides a secure and user-friendly way to manage Hive accounts and sign transactions.
Specify which key authority to use when creating the provider:
// Use posting key (for social operations)const postingProvider = PeakVaultProvider.for("username", "posting");// Use active key (for transfers and power operations)const activeProvider = PeakVaultProvider.for("username", "active");// Use owner key (for account management - use cautiously)const ownerProvider = PeakVaultProvider.for("username", "owner");
try { await provider.signTransaction(tx); await chain.broadcast(tx);} catch (error) { if (error.message.includes("user_cancel")) { console.log("User cancelled the transaction"); } else if (error.message.includes("account_not_found")) { console.log("Account not found in PeakVault"); } else if (error.message.includes("key_not_found")) { console.log("Required key not available in PeakVault"); } else { console.error("Transaction failed:", error); }}
Always verify PeakVault is installed before attempting to use it:
if (!isPeakVaultInstalled()) { // Redirect to installation page or show alternative options}
Use appropriate key authorities
Request the lowest-privilege key that can perform the operation. Don’t ask for active keys when posting keys are sufficient.
Handle user cancellation gracefully
Users may cancel the signing request. Handle this case without showing errors:
try { await provider.signTransaction(tx);} catch (error) { if (error.message.includes("user_cancel")) { // User chose not to sign - this is normal return null; } throw error;}