@watchee/wallet-adapter-plugin
v1.0.0
Published
Watchee Wallet Adapter Plugin for Aptos dApps — AIP-62 Wallet Standard compliant
Maintainers
Readme
@watchee/wallet-adapter-plugin
AIP-62 Wallet Standard plugin for Watchee on the Aptos blockchain.
This package lets any Aptos dApp connect to the Watchee wallet through the standard Aptos Wallet Adapter. When your dApp runs inside the Watchee app (as a mini-app), the plugin communicates directly with the native bridge. When your dApp runs in a regular browser, the plugin falls back to deep linking into the Watchee mobile app.
Installation
npm install @watchee/wallet-adapter-pluginPeer Dependencies
The plugin requires @aptos-labs/ts-sdk (>= 1.33.0). If you are already using the Aptos Wallet Adapter, you most likely have this installed.
Quick Start
1. Add the plugin to the Wallet Adapter Provider
import { AptosWalletAdapterProvider } from "@aptos-labs/wallet-adapter-react";
import { WatcheeWallet } from "@watchee/wallet-adapter-plugin";
import { Network } from "@aptos-labs/ts-sdk";
function App() {
const wallets = [
new WatcheeWallet({ network: Network.MAINNET }),
];
return (
<AptosWalletAdapterProvider
plugins={wallets}
autoConnect={true}
dappConfig={{ network: Network.MAINNET }}
>
{/* Your app */}
</AptosWalletAdapterProvider>
);
}2. Use the standard useWallet hook
import { useWallet } from "@aptos-labs/wallet-adapter-react";
function ConnectButton() {
const { connect, disconnect, account, connected, wallet } = useWallet();
if (connected) {
return (
<div>
<p>Connected: {account?.address}</p>
<button onClick={disconnect}>Disconnect</button>
</div>
);
}
return <button onClick={() => connect("Watchee")}>Connect Watchee</button>;
}3. Sign transactions
import { useWallet } from "@aptos-labs/wallet-adapter-react";
function SignTx() {
const { signTransaction, signMessage } = useWallet();
const handleSignTransaction = async () => {
const result = await signTransaction({
data: {
function: "0x1::coin::transfer",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [recipientAddress, amount],
},
});
console.log("Signed:", result);
};
const handleSignMessage = async () => {
const result = await signMessage({
message: "Hello from my dApp!",
nonce: Date.now().toString(),
});
console.log("Signature:", result);
};
return (
<div>
<button onClick={handleSignTransaction}>Sign Transaction</button>
<button onClick={handleSignMessage}>Sign Message</button>
</div>
);
}How It Works
Inside Watchee (Mini-Apps)
When your dApp runs inside the Watchee mobile app as a mini-app, the plugin detects window.WatcheeSDK (injected by the native bridge) and uses it directly. The user is already authenticated, so connect() resolves immediately with the active account.
Outside Watchee (Standalone dApps)
When your dApp runs in a regular mobile browser, clicking "Connect Watchee" opens the Watchee app via deep link (watcheetv://wallet/connect). If the Watchee app is not installed, the user is redirected to the Watchee download page.
Configuration
interface WatcheeWalletConfig {
/** Target Aptos network. Defaults to Network.MAINNET. */
network?: Network;
}AIP-62 Features
The plugin implements all required AIP-62 Wallet Standard features:
| Feature | Version | Description |
| ------------------------- | ------- | ------------------------------ |
| aptos:connect | 1.0.0 | Connect wallet |
| aptos:disconnect | 1.0.0 | Disconnect wallet |
| aptos:account | 1.0.0 | Get connected account info |
| aptos:network | 1.0.0 | Get current network |
| aptos:signTransaction | 1.0.0 | Sign a raw transaction |
| aptos:signMessage | 1.0.0 | Sign an arbitrary message |
| aptos:onAccountChange | 1.0.0 | Listen for account changes |
| aptos:onNetworkChange | 1.0.0 | Listen for network changes |
For Mini-App Developers
If you are building a mini-app for the Watchee ecosystem, you can use the @watchee/minikit package which provides a higher-level API. The wallet adapter plugin is useful when you want your dApp to work both inside and outside Watchee.
Exports
// Main wallet class — pass to the Wallet Adapter
export class WatcheeWallet implements AptosWallet { ... }
// Configuration options
export interface WatcheeWalletConfig { ... }
// Account representation
export class WatcheeWalletAccount implements AptosWalletAccount { ... }License
MIT - Watchee
