Package Exports
- @arbius/aa-wallet
- @arbius/aa-wallet/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@arbius/aa-wallet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AA Wallet
A secure and flexible Account Abstraction wallet implementation for Ethereum applications.
Features
- ๐ Secure key management
- ๐ Transaction mutex queue
- โ๏ธ Ethereum proxy for seamless integration
- ๐จ React hooks and components
- ๐ผ Minimal dependencies
- ๐งช Comprehensive test coverage
Installation
npm install @semperai/aa-wallet
# or
yarn add @semperai/aa-wallet
Quick Start
import { init, AAWalletProvider, useAAWallet } from '@semperai/aa-wallet';
// Initialize the wallet
init({
defaultChainId: 1,
supportedChainIds: [1, 5, 11155111], // Mainnet, Goerli, Sepolia
multicall: { chainId: 1 },
watchERC20s: [
{
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
decimals: 6,
symbol: 'USDC',
name: 'USD Coin',
chainId: 1,
logo: 'https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png'
}
],
ui: {
toastPosition: 'bottom-right',
theme: 'light',
autoConnectOnInit: false,
}
});
// Wrap your app with the provider
function App() {
return (
<AAWalletProvider>
<YourApp />
</AAWalletProvider>
);
}
// Use the wallet in your components
function YourApp() {
const { isConnected, address, connect, disconnect, sendTransaction } = useAAWallet();
const handleConnect = async () => {
try {
await connect();
} catch (error) {
console.error('Failed to connect:', error);
}
};
const handleSendTransaction = async () => {
try {
const txHash = await sendTransaction({
method: 'eth_sendTransaction',
params: [{
to: '0x1234567890123456789012345678901234567890',
value: '0x0',
data: '0x',
}],
chainId: 1,
});
console.log('Transaction sent:', txHash);
} catch (error) {
console.error('Failed to send transaction:', error);
}
};
return (
<div>
{isConnected ? (
<>
<p>Connected: {address}</p>
<button onClick={disconnect}>Disconnect</button>
<button onClick={handleSendTransaction}>Send Transaction</button>
</>
) : (
<button onClick={handleConnect}>Connect Wallet</button>
)}
</div>
);
}
Documentation
Initialization
Initialize the wallet with your configuration:
import { init } from '@semperai/aa-wallet';
init({
defaultChainId: 1,
supportedChainIds: [1, 5, 11155111],
// ... other options
});
React Hooks
useAAWallet
import { useAAWallet } from '@semperai/aa-wallet';
function Component() {
const {
isConnected,
address,
chainId,
connect,
disconnect,
switchChain,
sendTransaction
} = useAAWallet();
// Use these values and functions
}
useTransactions
import { useTransactions } from '@semperai/aa-wallet';
function Component() {
const {
transactions,
pending,
completed,
failed,
isPending,
hasFailed
} = useTransactions();
// Use these values
}
Components
ConnectButton
import { ConnectButton } from '@semperai/aa-wallet';
function Component() {
return (
<ConnectButton
connectText="Connect"
disconnectText="Disconnect"
loadingText="Connecting..."
className="custom-button-class"
/>
);
}
TransactionToast
import { TransactionToast } from '@semperai/aa-wallet';
function Component() {
return (
<>
<YourApp />
<TransactionToast
position="bottom-right"
autoClose={true}
autoCloseTime={5000}
/>
</>
);
}
Security Best Practices
The AA Wallet implements several security best practices:
- Private key encapsulation through closures
- No global exposure of sensitive data
- Secure transaction handling
- Proper error handling
License
MIT