@wallet-abstractor/core
v0.1.1
Published
Core wallet abstraction layer with unified API
Readme
@wallet-abstractor/core
Core wallet abstraction layer for Web3 applications
This is the core package of Wallet Abstractor, providing the unified interface and factory for connecting to blockchain wallets across different chains.
Installation
npm install @wallet-abstractor/coreWhat This Package Provides
- IWalletProvider - Abstract base class for all wallet adapters
- AdapterFactory - Factory for creating chain-specific adapters
- WalletEventEmitter - Unified event system for wallet events
- Error Handling - Standardized error codes (
AbstractorError,ErrorCode)
Quick Start
import { createAdapter } from '@wallet-abstractor/core';
// You also need to install and import chain-specific adapters
import '@wallet-abstractor/evm'; // For Ethereum/EVM
import '@wallet-abstractor/solana'; // For Solana
// Create adapter
const wallet = createAdapter({
chain: 'evm', // or 'solana'
network: 'ethereum',
});
// Connect
const account = await wallet.connect();
console.log('Connected:', account.address);
// Sign message
const signature = await wallet.signMessage('Hello!');
// Send transaction
const txHash = await wallet.sendTransaction({
to: '0x...',
value: 1000000000000000000n,
});API
createAdapter(options)
Creates a wallet adapter for the specified chain.
import { createAdapter } from '@wallet-abstractor/core';
const wallet = createAdapter({
chain: 'evm', // 'evm' | 'solana'
network: 'ethereum', // Optional: specific network
wallet: 'metamask', // Optional: specific wallet
});Events
wallet.on('connect', ({ account }) => {
console.log('Connected:', account.address);
});
wallet.on('accountChanged', ({ account }) => {
console.log('Account changed:', account?.address);
});
wallet.on('networkChanged', ({ network }) => {
console.log('Network:', network.name);
});
wallet.on('disconnect', () => {
console.log('Disconnected');
});Related Packages
- @wallet-abstractor/evm - EVM chain adapter
- @wallet-abstractor/solana - Solana adapter
- @wallet-abstractor/shared - Types and utilities
License
MIT
