Core functionality for the Aptos Wallet Adapter. This package provides the foundation for wallet management, state handling, and interaction with AIP-62 compatible wallets on the Aptos blockchain.
The wallet-adapter-core package handles:
- Wallet Detection: Automatically detects AIP-62 standard compatible wallets installed in the browser
- Connection Management: Connect, disconnect, and manage wallet sessions
- Transaction Signing: Sign messages, transactions, and submit transactions to the network
- Network Management: Handle network changes and multi-network support
- Event System: Subscribe to wallet, account, and network change events
- State Management: Centralized state for connected wallet, account, and network information
npm install @aptos-labs/wallet-adapter-core
# or
pnpm add @aptos-labs/wallet-adapter-core
# or
yarn add @aptos-labs/wallet-adapter-corePeer Dependencies:
npm install @aptos-labs/ts-sdkimport { WalletCore } from "@aptos-labs/wallet-adapter-core";
import { Network } from "@aptos-labs/ts-sdk";
// Create wallet core instance
const walletCore = new WalletCore(
[], // Optional: array of wallet names to opt-in (empty = all wallets)
{ network: Network.MAINNET }, // Optional: dapp configuration
false, // Optional: disable telemetry (default: false)
["Petra Web"] // Optional: wallets to hide from display
);
// Get available wallets
const wallets = walletCore.wallets;
const notDetectedWallets = walletCore.notDetectedWallets;// Connect to a wallet by name
await walletCore.connect("Petra");
// Check connection status
if (walletCore.isConnected()) {
console.log("Connected account:", walletCore.account);
console.log("Connected network:", walletCore.network);
}const signedMessage = await walletCore.signMessage({
message: "Hello, Aptos!",
nonce: "random-nonce-123",
});
console.log("Signature:", signedMessage.signature);
console.log("Full message:", signedMessage.fullMessage);const result = await walletCore.signAndSubmitTransaction({
data: {
function: "0x1::aptos_account::transfer",
typeArguments: [],
functionArguments: [recipientAddress, amount],
},
});
console.log("Transaction hash:", result.hash);// Account change event
walletCore.on("accountChange", (account) => {
console.log("Account changed:", account);
});
// Network change event
walletCore.on("networkChange", (network) => {
console.log("Network changed:", network);
});
// Disconnect event
walletCore.on("disconnect", () => {
console.log("Wallet disconnected");
});await walletCore.disconnect();The main class that manages wallet state and interactions.
new WalletCore(
optInWallets?: ReadonlyArray<AvailableWallets>,
dappConfig?: DappConfig,
disableTelemetry?: boolean,
hideWallets?: ReadonlyArray<AvailableWallets>
)| Property | Type | Description |
|---|---|---|
wallet |
AptosWallet | null |
Currently connected wallet |
account |
AccountInfo | null |
Currently connected account |
network |
NetworkInfo | null |
Currently connected network |
wallets |
ReadonlyArray<AptosWallet> |
List of detected wallets |
hiddenWallets |
ReadonlyArray<AdapterWallet> |
List of hidden wallets |
notDetectedWallets |
ReadonlyArray<AdapterNotDetectedWallet> |
List of not-detected wallets |
| Method | Description |
|---|---|
connect(walletName) |
Connect to a wallet |
disconnect() |
Disconnect from current wallet |
signMessage(input) |
Sign a message |
signTransaction(args) |
Sign a transaction |
signAndSubmitTransaction(input) |
Sign and submit a transaction |
changeNetwork(network) |
Request network change |
signIn(args) |
Sign in with SIWA (Sign In With Aptos) |
isConnected() |
Check if wallet is connected |
| Event | Payload | Description |
|---|---|---|
connect |
AccountInfo |
Emitted when wallet connects |
disconnect |
- | Emitted when wallet disconnects |
accountChange |
AccountInfo |
Emitted when account changes |
networkChange |
NetworkInfo |
Emitted when network changes |
Configuration options for the wallet adapter:
interface DappConfig {
network: Network;
transactionSubmitter?: TransactionSubmitter;
aptosApiKeys?: Partial<Record<Network, string>>;
aptosConnectDappId?: string;
aptosConnect?: AptosConnectWalletConfig;
crossChainWallets?: boolean;
}@aptos-labs/wallet-adapter-react- React hooks and context provider@aptos-labs/ts-sdk- Aptos TypeScript SDK
Apache-2.0